Lyto Different Color AI

Lyto Different Color is a color differentiation game on Facebook. Each level, there are NxN circles on a board, with one circle having a color slightly different from all the others. The player must find the circle with different color and click on it in order to go to the next level. During the early stage of the game, the difference between the color of the unique circle and the color of the other circles gets smaller, and N gets larger, making it become more difficult. For most people, level 50 is considered a high score, and it is almost impossible for a normal human to reach level 100.

I simply wanted to break this limit, so I wrote a Python script for continuously taking a snapshot of the section of the game screen, find the circles, reading their color, and pressing on the circle with unique color. It is comparatively easy for the AI to recognize the differences, since it reads the colors as an RGB value, where any difference in the values represents a difference in color.

Python Imaging Library (PIL) is used for capturing the game screen, which approximate takes a screenshot every 0.7 seconds. Afterwards, the boundary of the circles is found by finding pixels that have a different color compared with the plain background color. Then, N is found by counting continuous blocks of identical colors from a 1D diagonal slice of array from the top-left to bottom-right corner of the boundary. By finding these values, the center of every circle can be located, which the program retrieves the colors from and compare them. At last, the circle with unique color is found, and the program sends a signal to the mouse for pressing on the target position. Fig. 1 illustrates a graphical description of the program algorithm.

Figure 1. Graphical description of the algorithm for Lyto Different Color AI.

Here’s a clip of the program playing the game (2x speed):

[Source code for Lyto Different Color AI]