It looks at the place above it to see what kind of fruit is being held, then the ai looks for a fruit of the same color in the box. Also, if the box does not contain the color, the ai will drop the fruit off at a random location. Use this link to decrease lag somewhat: https://turbowarp.org/1061727728
I added some ai and remapped the controls to be compatible with the ai. If the game lags, that just means the ai is looking for fruit. (It lags often, even with some optimizations. Sorry.)