Step 4: Vision
🌐 English · Dansk · Bahasa Malaysia
Milestone MIL-004. Branch and pull request: one for this step.

What was done
The part of the bot that looks: Box and Frame value objects, find_game_area (the ground line gives the position and the scale), GameArea.detection_box and is_collision (is an obstacle in the pixels?). Unit tests use pictures generated in the test, so no screen is needed.
What was gained
- A screenshot in grey is only a list of numbers; the ground line is the row with the most dark pixels, and its width tells the scale of the screen.
- Taking the most common grey value as the background makes one rule work in day mode (dark on white) and night mode (light on black).
- Because the rules work on plain bytes, tests can draw a cactus in three lines and check the bot without opening the game.