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. If the fruit is the same as the one placed before, it will place the fruit at the same location. If not, it will look for a column that contains the fruit. Then, it will look down the column to find the fruit. Then, it will look up and see if there is another fruit above it. Once it finds a suitable location, it will drop off the fruit. 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/1062152778
The ai assumes that none of the fruit are moving. I fixed the ai, and added a small safeguard so the ai doesn't crash. The game is still laggy.