Artificial intelligence : Grid solver autonomous bot

Project on Artificial intelligence:

It is an autonomous bot which executes the below algorithm-

1. Traverse through the entire Gride of coordinate.
2. Identify the 2 coordinates (X1,Y1) and (X2,Y2) with black dot they are (1,3) and (2,0) and stops at those coordinate.
3. Start again and now it will go to the coordinate whose X is smaller i.e (X1,Y1) = (1,3).
at this coordinate it will calculate another coordinate (X3,Y3) based upon the
color of surrounding boxes so 1 white and 3 black box at current coordinate so X3 = 1 and Y3 = 2

4. Now it goes to (X2,Y2) at (2,0) and here it calculates another cordinate (X4,Y4) based upon
the colour of surrounding boxes, so 4 White so X4 = 3, Y4=0

5. Now it will go to X3,Y3, here it gets X5 from front two box color i.e 1

6. Now it will go to X4,Y4, here it gets Y5 from back two box color i.e 1

7 It will go to X5, Y5 i.e. 1,1