Documentation
Key:
0 - Empty
1 - Pit
2 - Gold
3 - Wumpus
Overview:
A few visuals are shown to the right and below, depicting our initial plans for updating the grid and developing our algorithm
Final algorithm is shown below visuals
Final Algorithm
Condition for various possibilities:
If current location state = breeze/stench
Save information in history
Move back a space
Check history set to see if it's safe before moving
Proceeds to the new location
If current location state = glitter
Save information in history
Move forward
Check history set to see if it's safe before moving
Proceeds to the new location
If current location state = continue
Save information
Continue moving forward
Check history set to see if safe
If the location to the right is not safe, then the robot will backup all the way to the left until it is safe
If the robot backed up to the left edge of the board, it will attempt to move up and continue the algorithm
If the robot cannot move up, it will move to the right and attempt to move up again until the location is safe
Proceeds to the new location
isSafe Function
Each space in the grid holds information about what we have discovered and changes it accordingly. This information is then used to determine the robot's next moves.
If new location is within border edges :
Change values to Wumpus/pit/gold
If there are two breezes adjacent to a particular square, mark the square as a pit
Mark other locations pit could be in as safe
If there are two stenches that are adjacent to a particular square, mark the square as a Wumpus
Mark other possible locations as safe
If there are two glitters that are adjacent to a particular square, mark the square as a gold
Move to get it
If can move forward → move forward (also must be safe)
Else --> move back
Stench - 2 neighbors - confirms - Wumpus - (two of the same # neighbor)
If Wumpus marked in the grid, our robot must be in an adjacent space
Shoot Wumpus and continue algorithm, whether through where the Wumpus was or not
Wumpus location will be considered safe in our check grid function after shooting it and the stench spots will be marked as safe
Two breeze - 2 neighbors - confirms - breeze (two of the same # neighbor)
Mark the the pit through our check grid function
Other possible spaces can then be ruled out, mark those as safe
If state = glitter
Function to get gold will be enacted, checking safe locations around the glitter to get the robot to the gold
Once gold found
The robot will retrace it's steps and return to the starting location
Success!!