Closed emiln closed 8 years ago
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.
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.
After some deliberation and a chat with @PoliGamiOn, I'm actually leaning towards a percentage-based solution again.
Some thoughts on actually finding the game window's borders:
Take a screenshot and pick n random coordinates within it.
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.
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.
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.
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]
.