edwarfmartinez / Robots

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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Robots!

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.

ezgif com-optimize

1. Used Stack and Concepts

• UIKit • Swift • Protocols and delegates • MVC • Threads and Grand Central Dispatch • Graphs, nodes, and queues • Breadth First Search Algorithm • XCTest and UITest

2. Bonus

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.

3. Architecture

Screen Shot 2023-03-31 at 12 28 36 AM

4. Breadth First Search Algorithm

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 ’.’.

Screen Shot 2023-03-31 at 12 29 14 AM

Start at the start node coordinate by adding (sr, sc) to the queue:

Screen Shot 2023-03-31 at 12 29 43 AM

Keep adding to the queue:

Screen Shot 2023-03-31 at 12 30 07 AM

Screen Shot 2023-03-31 at 12 30 31 AM

We have reached the end, and if we had a 2D prev matrix we could regenerate the path by retracing our steps:

Screen Shot 2023-03-31 at 12 30 57 AM

About

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.


Languages

Language:Swift 100.0%