View our C++ code or the Pre Compiled Windows EXE or our Interactive C code.preconditions
-robot starts in bottom left corner, facing up (this assumes the adjacent squares are empty)
-mark starting square & two adjacent squares w/ "known empty" flag
-label squares in a grid by row & column
0 1 2 3
0 * * * *
1 * * * *
2 * * * *
3 * * * * → start at [3][0]
- array of structs, containing flag variables corresponding to the state(s) of the square (blank, possible_wumpus, known_pit, etc.)
-initially, have all squares except start & two adjacent ones marked with all "possible" flags, then unmark them as the robot progresses and gathers information
first move
-move up a square (to [2][0]), get inputs from IR remote (breeze, stench, glitter)
-see RemoteCodes.doc file for codes that will be used & their meanings
-flag adjacent squares ([1][0] and [2][1], but not [3][0] since it's "known empty") to indicate possibility of containing above inputs (unknown at this point which square has it)
-move back a square ([3][0]), go 1 square right([3][1]), get inputs from IR remote
-if an input from ([2][0]) is not present in the set from ([3][1]), we know that the square above the first move ([1][0]) had that input, and any other input from ([2][0]) was in the square to the right ([2][1])
-similarly, any new input in ([3][1]) not in ([2][0]) is in the square to its right ([3][2])
-one of the squares should evaluate to a blank square, indicating the next move
-continue in this manner, retracing steps and investigating other paths
-never move into a square with an unknown, unless the unknown is the gold
-store path used, except retracing of steps, to get back to the beginning once we get the gold
-or use another variable ("path" or similar) for each square to mark a safe route home
Wumpus/gold check
-if the Wumpus' location is known, go to an adjacent square and shoot it
-if the gold's location is known, go to its square
-if a square is either blank or gold, go to it
-if it's gold, go back to the beginning using the stored path
-if it's possible_gold (no other flags), go to it
©2008-2009