Fred’s starting position is always safe which means that the squares adjacent to that position are always safe to enter. This allows Fred to learn a little bit about the board and use some logic to guide his movement. Fred’s algorithm always consists of him moving to the right and then up. That is, he will always try the square to the right of his current position (if applicable) and if that isn’t a good choice, he will go back and try the square above his current position. To successfully traverse the Wumpus world, Fred has a log for keeping track of visited locations, an array for keeping track of his current knowledge of the board (Wumpus world) and also an array for his path taken.
​
Each time Fred moves to a new square, he adds that location to his log of visited locations and demands input on what is in that square. Once he gets the input he updates his knowledge of the board and uses a logic function to try and determine where a pit or the Wumpus or the gold might be based on his current input and current knowledge of the board. If Fred determines that his current location is a dangerous location (meaning one or all of the squares he could go to possibly have pits or the Wumpus), he goes back to his previous location and goes in another safe direction. Also, if Fred can determine where the Wumpus is with his current knowledge of the board, he kills it as it opens up more locations for Fred to enter. If Fred only gets glitter as input, then he knows that one of the squares surrounding his current location is gold and they are all safe to enter. So, he will just go to each square and get the input on that square until he gets the input for gold after which he backtracks through his route taken to reach the gold in order to get home safely.