It takes a screenshot, first finds colors by scanning at the center of each gem, finds shapes by getting unique not overlapping pixels. Reconstructs game`s grid, and then finds longest chain with dfs (depth first search) Also Piggy Bank sells for more than it costs to buy. So it breaks the game