Wumpus World The wumpus.py file is not a true inferencing engine. It is something used to work along this problem and this problem only. It still needs some work and improvements to make it even a good inferencing engine for this problem. But we're going to work with what is here for now. your job: Implement the checkThree and setValue functions. They're described in some detail below. checkThree is extensively described in the python file. Here's what you need to know: There are two classes in the file. 1) The Wumpus class. This class is responsible for keeping the true state of the board. You can call functions from the Wumpus class, but largely the code that I've left for you calls all the functions you need to know about Wumpus and you shouldn't mess with any of the internals of this class at all. It is responsible for understanding what the current percepts are in the room you're in, whether your character has died or not, and whether you succesfully killed the wumpus or not. 2) The second class is the class you're allowed to edit. It is the "knowledge" class and it is meant to be the knowledge base and inferencing engine for this problem. Let's look at the individual functions in this class. a) display - displays what is currently known about the world. 'Y' in squares that it knows are safe. 'M' in squares it thinks might be a wumpus 'B' in squares it thinks might be a pit '.' in squares it knows nothing about 'X' for squares beyond walls b) valueAt(i,j) - tells you what is known about the room at coordinates (i,j) c) setValue(x,y,value) - sets the value at coordinate (x,y) to value - some caveats include: - You'll be setting the value in self.wumpsWorld[y][x] and checking values in that cell too. I realize the x and y are backwards, but that's because of the ordering of lists in python and not because I'm a royal pain! Just be aware of it and correctly index into your world or things will not work. - If the current value to set is a '.' and the value to be set is an 'M' but the wumpus was already found, then a 'Y' will be written instead. This is to indicate that the knowledge base already KNOWS exactly where 'M' must be, and so other squares that are going to be labeled by 'M' should instead be labeled as safe. - If the current value in the knowledge base is a 'Y', then it shouldn't be changed. If that square is known to be safe, it will remain safe. - If the current value is a 'M' and we're trying to set it to a 'B' then don't. This is a huge restriction on the class of problems our particular engine can solve with the way it is written, but we're going to run with it this way unfortunately. d) north, south, east, and west functions with value - If value is 'Move' it moves the hero in the knowledge base in the given direction. - Else if the value is '?' it simply reports the value in the given direction from the current location. - Otherwise, it changes the knowledge base value in the given direction e) fire - fires an arrow in the given direction. This function is only called if the wumpus is known to exist at some location. Utilizing this knowledge, we know that it will always kill the wumpus and thus all 'M's in the board can be rewritten as safe squares. (This is an assumption that an an 'M' can never actually be a pit. This is the restriction on our problem set given by this particular solution.) f) checkThree - describes if the wumpus has been found and labeled or not. If the wumpus location is definitely known and is already labeled, this function returns False. This function only returns true if the wumpus location is determined but was never marked. If the wumpus location is determined and IS marked it should change the wumpusFound variable to True. - This function returns False if the wumpus was already found. - Otherwise, it goes through all locations that were ever smelly. If those smelly locations have three neighboring squares that are safe, then the wumpus has been found. But, we must know if the wumpus's location has been marked or not. If NONE of the neighboring squares were an 'M' then the location was not marked, the wumpusFound variable should be left alone and the function should return True. Otherwise, the location is marked and the wumpusFound variable should be labeled as true and the function should return False. Other functions: selectMove - will select a move from a list of valid moves from the knowledge base randomly. If neighboring squares are safe, they're valid moves. If the wumpus is found and it is in a straight line, that is av alid move. the "main" loops forever until the gold is found: - this gets the percepts from the world - if shiny is true, then grats, we win! - Otherwise, if no percepts are true, surrounding squares are safe - If breezy, mark neighbors as maybe pits 'B' - If smelly, mark neighbors as maybe Wumpus 'M' and add this to the list of smelly squares for the checkThree function. - If checkThree returns true, it means wumpus was found and we should mark that in our knowledge base. (This is done in this order for a reason) - Select a random move - Make that move in the knowledge base and the world. - The world file is stored in wump.txt A sample file might be: 4 H..S ..W. .... Y... It turns out that this knowledge base only handles 4x4 worlds, but the 4 is left in the world file in case I want to expand this in the future.