A Maze Room : In this lab, we will make a maze game. The maze is based on Linked Lists. Instead of having one possible direction (next), we will have 4 possible directions. Rooms: Use the below code as a basis to build your own room class.  Implement this class in the file room.py A room will be the basic object for our maze game. A room can have 4 doors (pertaining to north, south, east, and west).   Attached to each these directions we have either another room or None (we could also imagine that the None doors are just walls). We want the player to be able to tell what room they are in. Each room will have a unique description. When the player enters a room, the program will describe the room. This way the player will know if they went back to a room that have already been to. You MAY NOT change the method's arguments/names in ANY way. class Room():def __init__(self, descr):#Description of the room to print out#These should be unique so the player knows where they areself.descr = descr#These either tell us what room we get to if we go through the door#or they are None if the "door" can't be taken.self.north = Noneself.south = Noneself.east = Noneself.west = None #Access#Return the correct valuesdef __str__(self):#implement me def getNorth(self):#implement me def getSouth(self):#implement me def getEast(self):#implement me def getWest(self):#implement me #Mutators#Update the Valuedef setDescription(self,d):#implement me def setNorth(self, n):#implement me def setSouth(self, s):#implement me def setEast(self, e):#implement me def setWest(self, w):#implement me Maze: A maze is just a bunch of rooms! There are three things we need to know in order to make a maze. We need to know what room the player starts in. We need to know where the exit is. This will allow us to tell the player that they won. We also need to know what room the player is currently in. Create a file maze.py and complete the below code in it. You MAY NOT change the method's arguments/names in ANY way. class Maze:#Inputs: Pointer to start room and exit room#Sets current to start roomdef __init__(self, st = None, ex = None): #room the player starts inself.start_room = st #if the player finds this room they winself.exit_room = ex #what room is the player currently in?self.current = st #Return the room the player is in(current)def getCurrent(self):#implement me #The next four all have the same idea#See if there is a room in the direction#If the direction is None, then it is impossible to go that way#in this case return false#If the direction is not None, then it is possible to go this way#Update current to the new move (move the player)#then return true so the main program knows it worked.def moveNorth(self):#implement me def moveSouth(self):#implement me def moveEast(self):#implement me def moveWest(self):#implement me #If the current room is the exit,#then the player won! return true#otherwise return falsedef atExit(self):#implement me #If you get stuck in the maze, you should be able to go#back to the start#This sets current to be the start_roomdef reset(self):#implement me Make a Maze: Create a lab7.py file and create a very simple maze in it. This maze has three rooms. The player walks north from the start room gets to a middle room. The middle room leads to the exit. An easy way to connect all the rooms is to put them into a list of reference variables. my_rooms = [] my_rooms.append(Room("This room is the entrance.")) my_rooms.append(Room("This room has a table. Maybe a dinning room?")) my_rooms.append(Room("This room is the exit. Good Job.")) #room 0 is south of room 1 my_rooms[0].setNorth(my_rooms[1]) my_rooms[1].setSouth(my_rooms[0]) #Room 2 is east of room 1 my_rooms[1].setEast(my_rooms[2]) my_rooms[2].setWest(my_rooms[1]) #Make a maze! #Set the start and exit rooms. my_maze = Maze(my_rooms[0],my_rooms[2]) Create an interface for the player. Print a description of the room. Next, ask the player what direction to move. Either move into the next room, or stay in the same place if the path is blocked. Here is an example walk through the above maze. This room is the entrance Enter direction to move north west east south restart west Direction invalid, try again This room is the entrance. Enter direction to move north west east south restart north You went north This room has a table. Maybe a dining room? Enter direction to move north west east wouth restart reset You went back to the start! This room is the entrance Enter direction to move north west east south restart  north  You went north This room has a table. Maybe a dining room? Enter direction to move north west east south restart west Direction invalid, try again This room has a table. Maybe a dining room? Enter direction to move north west east south restart  east  You went east  You found the exit Make real maze: Make a real maze. Your maze must have AT LEAST 10 rooms and there must be at least 1 way to get from the start to the exit. As comments at the top of the lab7.py file, give instructions to walk both paths in the maze.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

A Maze Room :

In this lab, we will make a maze game. The maze is based on Linked Lists. Instead of having one possible direction (next), we will have 4 possible directions.

Rooms:

Use the below code as a basis to build your own room class.  Implement this class in the file room.py

A room will be the basic object for our maze game. A room can have 4 doors (pertaining to north, south, east, and west).   Attached to each these directions we have either another room or None (we could also imagine that the None doors are just walls).

We want the player to be able to tell what room they are in. Each room will have a unique description. When the player enters a room, the program will describe the room. This way the player will know if they went back to a room that have already been to.

You MAY NOT change the method's arguments/names in ANY way.

class Room():
def __init__(self, descr):

#Description of the room to print out
#These should be unique so the player knows where they are
self.descr = descr

#These either tell us what room we get to if we go through the door
#or they are None if the "door" can't be taken.
self.north = None
self.south = None
self.east = None
self.west = None

#Access
#Return the correct values
def __str__(self):
#implement me

def getNorth(self):
#implement me

def getSouth(self):
#implement me

def getEast(self):
#implement me

def getWest(self):
#implement me

#Mutators
#Update the Value
def setDescription(self,d):
#implement me

def setNorth(self, n):
#implement me

def setSouth(self, s):
#implement me

def setEast(self, e):
#implement me

def setWest(self, w):
#implement me

Maze:

A maze is just a bunch of rooms! There are three things we need to know in order to make a maze.

  1. We need to know what room the player starts in.
  2. We need to know where the exit is. This will allow us to tell the player that they won.
  3. We also need to know what room the player is currently in.

Create a file maze.py and complete the below code in it. You MAY NOT change the method's arguments/names in ANY way.

class Maze:

#Inputs: Pointer to start room and exit room
#Sets current to start room
def __init__(self, st = None, ex = None):

#room the player starts in
self.start_room = st

#if the player finds this room they win
self.exit_room = ex

#what room is the player currently in?
self.current = st

#Return the room the player is in(current)
def getCurrent(self):
#implement me

#The next four all have the same idea
#See if there is a room in the direction
#If the direction is None, then it is impossible to go that way
#in this case return false
#If the direction is not None, then it is possible to go this way
#Update current to the new move (move the player)
#then return true so the main program knows it worked.
def moveNorth(self):
#implement me

def moveSouth(self):
#implement me

def moveEast(self):
#implement me

def moveWest(self):
#implement me

#If the current room is the exit,
#then the player won! return true
#otherwise return false
def atExit(self):
#implement me

#If you get stuck in the maze, you should be able to go
#back to the start
#This sets current to be the start_room
def reset(self):
#implement me

Make a Maze:

Create a lab7.py file and create a very simple maze in it. This maze has three rooms. The player walks north from the start room gets to a middle room. The middle room leads to the exit.

An easy way to connect all the rooms is to put them into a list of reference variables.

my_rooms = [] my_rooms.append(Room("This room is the entrance.")) my_rooms.append(Room("This room has a table. Maybe a dinning room?")) my_rooms.append(Room("This room is the exit. Good Job.")) #room 0 is south of room 1 my_rooms[0].setNorth(my_rooms[1]) my_rooms[1].setSouth(my_rooms[0]) #Room 2 is east of room 1 my_rooms[1].setEast(my_rooms[2]) my_rooms[2].setWest(my_rooms[1]) #Make a maze! #Set the start and exit rooms. my_maze = Maze(my_rooms[0],my_rooms[2])

Create an interface for the player. Print a description of the room. Next, ask the player what direction to move. Either move into the next room, or stay in the same place if the path is blocked.

Here is an example walk through the above maze.

This room is the entrance

Enter direction to move north west east south restart

west

Direction invalid, try again

This room is the entrance.

Enter direction to move north west east south restart

north

You went north

This room has a table. Maybe a dining room?

Enter direction to move north west east wouth restart

reset

You went back to the start!

This room is the entrance

Enter direction to move north west east south restart 

north 

You went north

This room has a table. Maybe a dining room?

Enter direction to move north west east south restart

west

Direction invalid, try again

This room has a table. Maybe a dining room?

Enter direction to move north west east south restart 

east 

You went east 

You found the exit

Make real maze:

Make a real maze. Your maze must have AT LEAST 10 rooms and there must be at least 1 way to get from the start to the exit.

As comments at the top of the lab7.py file, give instructions to walk both paths in the maze.

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 6 steps

Blurred answer
Knowledge Booster
Generic Type
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education