Robots! is a multi-round, completely autonomous game played by two robots taking turns moving across a 7x7 game board in search of a randomly placed prize token.
• UIKit • Swift • Protocols and delegates • MVC • Threads and Grand Central Dispatch • Graphs, nodes, and queues • Breadth First Search Algorithm • XCTest and UITest
You can change the target by tapping one of the available nodes, so the robots change the path and try to reach the new goal.
A dungeon has a board size of R x C and you start at cell ’0,0’ and there’s an exit at cell ‘4,3’. Blockers are indicated by a ’#’ and empty cells are represented by a ’.’.
Start at the start node coordinate by adding (sr, sc) to the queue:
Keep adding to the queue:
We have reached the end, and if we had a 2D prev matrix we could regenerate the path by retracing our steps: