Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locate upper-left corner of ClickerHeroes window #19

Closed
emiln opened this issue Sep 4, 2015 · 6 comments
Closed

Locate upper-left corner of ClickerHeroes window #19

emiln opened this issue Sep 4, 2015 · 6 comments

Comments

@emiln
Copy link
Owner

emiln commented Sep 4, 2015

It would be great to have the bot locate the upper left corner of the Clicker Heroes window. This would allow movement commands relative to the inside of the game frame. I imagine the commands [:relative-move-to 100 100] and [:absolute-move-to 100 100] to replace the current [:move-to 100 100].

@emiln
Copy link
Owner Author

emiln commented Sep 12, 2015

What's preferable, come to think of it: pixel coordinates inside the window or a percentage of the width and height? The former avoids issues of precision, while the latter scales obviously to different resolutions. I would really like to have both properties. My 4k monitor allots twice the amount of pixels in both directions for the game window due to high-DPI scaling compared to a regular monitor, and ideally a script should work flawlessly on both.

All of the above pertains to relative coordinates of course.

@emiln
Copy link
Owner Author

emiln commented Sep 12, 2015

I think it is preferable to work with pixels, so perhaps a sort of "normalized pixel" coordinate is tolerable to work with. You'll use coordinates as if the window was scaled normally, and the bot will know how to scale the coordinates to possibly bigger or smaller actual game windows. I can't think of a better way of doing it at this point.

@emiln
Copy link
Owner Author

emiln commented Sep 29, 2015

After some deliberation and a chat with @PoliGamiOn, I'm actually leaning towards a percentage-based solution again.

@emiln
Copy link
Owner Author

emiln commented Oct 1, 2015

Some thoughts on actually finding the game window's borders:

Take a screenshot and pick n random coordinates within it.

  1. Calculate the fitness of each coordinate. If the best coordinate has optimal fitness, assume we've found the point we're looking for and stop.
  2. Pick the n/3 best coordinates so far ranked by fitness + n/3 random coordinates + mutations of the n/3 best coordinates. Repeat 1.

An idea for fitness could be the following:

Sample both a horizontal and vertical line centered on the pixel and see how many pixels match the background color of the area around the game window. The contributes positively to fitness.

Sample the pixels below and to the right of the pixels. These should not match the background color above.

Assuming we find a pixel of optimal fitness, it should be the pixel next to the top left corner of the game window. From here it should be easy to trace the outline of the game window.

@emiln
Copy link
Owner Author

emiln commented Oct 12, 2015

The approach described above almost works. When hitting the left side of the game window border, however, there is no increase in fitness by moving slightly up towards the upper left corner, so the generations don't gravitate towards the corner. They remain somewhere on the left border unless you're really lucky. Fitness should have added how many pixels down there's a game window to the immediate right of the coordinate, perhaps.

@emiln
Copy link
Owner Author

emiln commented Feb 21, 2016

This is proving a fairly large task, which is something I by no means have the time for at the moment. I'm closing this for now due to lack of time.

@emiln emiln closed this as completed Feb 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant