Sign in to follow this  
Followers 0
6105

how to choose a point that is closest?

10 posts in this topic

#1 ·  Posted (edited)

I have this theorem for selection and the nearest point, but I do not understand how to work with her who can give an example or explain?

Func Pixel_Distance($x1, $y1, $x2, $y2);Pythagoras theorem for 2D
    Local $a, $b, $c
    If $x2 = $x1 And $y2 = $y1 Then
        Return 0
    Else
        $a = $y2 - $y1
        $b = $x2 - $x1
        $c = Sqrt($a * $a + $b * $b)
        Return $c
    EndIf
EndFunc;==>Pixel_Distance

Thank you guys in advance

how to choose a red points that is closest to the black?

post-50212-1244246836_thumb.gif

Edited by toader

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Share this post


Link to post
Share on other sites



You pass the function two sets of X/Y coordinates, and it will return the distance between them.

Your topic title is: "how to choose a point that is closest?"

Closest to what?


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

This function returns the distance in pixels from one point ($x1,$y1) to another Point ($x2,$y2)

If the x coords and y coords are equal Then
        Return 0 ; Point1 and Point2 have the same coords, distance 0
    Else
        $a = $y2 - $y1 ; get x distance between Points
        $b = $x2 - $x1 ; get y distance between Points
        $c = Sqrt($a * $a + $b * $ B) ; do pythagoras to get length
        Return $c ; return length
    EndIf

Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite

Share this post


Link to post
Share on other sites

You pass the function two sets of X/Y coordinates, and it will return the distance between them.

Your topic title is: "how to choose a point that is closest?"

Closest to what?

"how to choose a red points that is closest to the black? "

Updated post updated :D


[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Share this post


Link to post
Share on other sites

This function returns the distance in pixels from one point ($x1,$y1) to another Point ($x2,$y2)

If the x coords and y coords are equal Then
        Return 0 ; Point1 and Point2 have the same coords, distance 0
    Else
        $a = $y2 - $y1 ; get x distance between Points
        $b = $x2 - $x1 ; get y distance between Points
        $c = Sqrt($a * $a + $b * $ B) ; do pythagoras to get length
        Return $c ; return length
    EndIf

yes i know what is do but i dont understand how to use it :D


[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

well you have problem with your approach to the whole task.

You have an image with an black dot and some random red dots.

You want to get the coordiantes of that red dot that is closest to the black dot.

So using a function which gets you the distance from two coords requires that you already know the coords of the points.

To make it complicated you would have to store every points coords in an array and make a loop where you get the distance to every point, store the distance with the coords, and in the end compare all distances to get the closest coords.

A bit complicated :D

I suggest you do a more "radar" style approach.

Use PixelGetColor to find the black dot.

Then run PixelGetColor in circles around the black with increasing the radius of the "scan" every turn.

If you find your first red pixel, thats the closest one :D

By the way: What game is that again? I remember that i've played it once ^^

Edited by qsek

Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

well you have problem with your approach to the whole task.

You have an image with an black dot and some random red dots.

You want to get the coordiantes of that red dot that is closest to the black dot.

So using a function which gets you the distance from two coords requires that you already know the coords of the points.

To make it complicated you would have to store every points coords in an array and make a loop where you get the distance to every point, store the distance with the coords, and in the end compare all distances to get the closest coords.

A bit complicated :D

I suggest you do a more "radar" style approach.

Use PixelGetColor to find the black dot.

Then run PixelGetColor in circles around the black with increasing the radius of the "scan" every turn.

If you find your first red pixel, thats the closest one :D

By the way: What game is that again? I remember that i've played it once ^^

$coord = PixelSearch( 170, 126, 960, 390, 0xFFFFFF );hero
$left = $coord[0]-100
$top = $coord[1]-100
$right = $coord[0]+100
$buttom = $coord[1]+100
$coord1 = PixelSearch( $left, $top, $right, $buttom, 0xFEAE2C );monster
If Not @error Then
     Send("{SHIFTDOWN}")
     MouseClick("primary", $coord1[0]+30, $coord1[1]+15, 1)
     Send("{SHIFTUP}")
     Send("d")
     Send("{SHIFTDOWN}")
     MouseClick("primary", $coord1[0]+30, $coord1[1]+15, 1)
     Send("{SHIFTUP}")
     Send("d")
EndIf

and I also use Square bc cant do circle in order to atack if monstar within a radius of 100 pixels to click on it 10 races

but how to make the radar does not come to mind: (

more Square? checkpixel in 1Square if in Square1 no redpixel checkpixel in 2Square if in Square2 no redpixel check..... y?

Edited by toader

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Share this post


Link to post
Share on other sites

and I also use Square bc cant do circle in order to atack if monstar within a radius of 100 pixels to click on it 10 races

but how to make the radar does not come to mind: (

more Square? checkpixel in 1Square if in Square1 no redpixel checkpixel in 2Square if in Square2 no redpixel check..... y?

lol do you use google translator? i can not really read what you say :D

Anyway i think this one will be used for making a bot, so good luck


Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite

Share this post


Link to post
Share on other sites

lol do you use google translator? i can not really read what you say :D

Anyway i think this one will be used for making a bot, so good luck

sry(( y i use google)) and y i wanna do bot but im in AutoIt 4 days and dont have big experience in this((


[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Share this post


Link to post
Share on other sites

well you have problem with your approach to the whole task.

You have an image with an black dot and some random red dots.

You want to get the coordiantes of that red dot that is closest to the black dot.

So using a function which gets you the distance from two coords requires that you already know the coords of the points.

To make it complicated you would have to store every points coords in an array and make a loop where you get the distance to every point, store the distance with the coords, and in the end compare all distances to get the closest coords.

A bit complicated :D

I suggest you do a more "radar" style approach.

Use PixelGetColor to find the black dot.

Then run PixelGetColor in circles around the black with increasing the radius of the "scan" every turn.

If you find your first red pixel, thats the closest one :D

By the way: What game is that again? I remember that i've played it once ^^

How to find all red points? if i searchpixel it find 1 point but how to find all?


[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0