top of page

The Algorithm

We have two main functions. The first function is for determining the state of the board that the program perceives. The second function is for actually moving the character. We need both functions so that the program has information from the first function that it can then use on moving. The second function instantiates every index in the 2 dimensional array containing the board layout as it knows of right now. It instantiates the array with all “?” and fills out the board as it goes on. If it steps on a smell it either marks the index as “STENCH”, “BREEZE”, or “GLITTER”. If a square is surrounded by one of these smells disregarding a square that if it’s out of bounds and if it is then it declares it either “Wumpus”, “Pit”, or “Gold” respectively.The second function is the moving algorithm which under normal circumstances would move right until it reaches the end in which case it would move up. If the square has a smell that isn’t glitter then it would move back then move up and continue moving right. If it finds out that the square was a wumpus then it would shoot it. If it finds glitter then it would move to the square that has the gold, after it finds the gold it will completely backtrack it steps because it stored all of its moves in an array already.

bottom of page