I also placed 4 ais once and saw which one won hahaha
Yes, I didn't have time to optimize. In general, I tested with smaller grids, when I went to test with the larger one it was already delivery day. :/ At least for me, even the 8x8 works ok, the 9x9 takes about 2~3 seconds to calculate, but I thought it was an acceptable time and kept it.
But anyway, the AI first looks to see if there is someone in front of it due to some difference (I had put 3 at first, but it was too easy, so I lowered it to 1). If so, it tries to erase an adjacent tile between that piece and its objective. If it is in front or it is not possible to erase a tile, it looks for the shortest path to its objective and moves.