Knowee
Questions
Features
Study Tools

from maze.maze import Maze from maze.util import Coordinates class MazeGenerator: """ Base class for a maze generator. """ def generateMaze(self, maze:Maze): """ Generates a maze. Will update the passed maze. @param maze Maze which we update on to generate a maze. """ pass def addEntrances(self, maze:Maze): """ Add entrance(s) to the maze. @param maze Maze which we update on to generate a maze. """ # when adding the entrances, we need to remove the relevant boundary wall for ent in maze.getEntrances(): # need to figure out which direction to remove wall # entrance is at bottom, need to remove wall in "up" direction if ent.getRow() == -1: maze.removeWall(ent, Coordinates(0, ent.getCol())) # entrance is at top, need to remove wall in "down" direction elif ent.getRow() == maze.rowNum(): maze.removeWall(ent, Coordinates(maze.rowNum()-1, ent.getCol())) # entrace is to the left, need to remove wall in "right" direction elif ent.getCol() == -1: maze.removeWall(ent, Coordinates(ent.getRow(), 0)) # entrance is to the right, need to remove wall in "left" direction elif ent.getCol() == maze.colNum(): maze.removeWall(ent, Coordinates(ent.getRow(), maze.colNum()-1)) def addExits(self, maze:Maze): """ Add exit(s) to the maze. @param maze Maze which we update on to generate a maze. """ # when adding the exits, we need to remove the relevant boundary wall for ext in maze.getExits(): # need to figure out which direction to remove wall # exit is at bottom, need to remove wall in "up" direction if ext.getRow() == -1: maze.removeWall(ext, Coordinates(0, ext.getCol())) # exit is at top, need to remove wall in "down" direction elif ext.getRow() == maze.rowNum(): maze.removeWall(ext, Coordinates(maze.rowNum()-1, ext.getCol())) # exit is to the left, need to remove wall in "right" direction elif ext.getCol() == -1: maze.removeWall(ext, Coordinates(ext.getRow(), 0)) # exit is to the right, need to remove wall in "left" direction elif ext.getCol() == maze.colNum(): maze.removeWall(ext, Coordinates(ext.getRow(), maze.colNum()-1)) # ------------------------------------------------------------------- # DON'T CHANGE THIS FILE. # This is the entry point to run the program. # Refer to usage() for exact format of input expected to the program. # # __author__ = 'Jeffrey Chan' # __copyright__ = 'Copyright 2024, RMIT University' # ------------------------------------------------------------------- import sys import time import json from typing import List from maze.util import Coordinates from maze.maze import Maze from maze.arrayMaze import ArrayMaze from maze.graphMaze import GraphMaze from generation.mazeGenerator import MazeGenerator from generation.recurBackGenerator import RecurBackMazeGenerator # this checks if Visualizer has been imported properly. # if not, likely missing some packages, e.g., matplotlib. # in that

Question

from maze.maze import Maze from maze.util import Coordinates

class MazeGenerator: """ Base class for a maze generator. """

def generateMaze(self, maze:Maze):
	"""
    Generates a maze.  Will update the passed maze.

	@param maze Maze which we update on to generate a maze. 
	"""
	pass



def addEntrances(self, maze:Maze):
	"""
	Add entrance(s) to the maze.

	@param maze Maze which we update on to generate a maze. 
	"""
	
	# when adding the entrances, we need to remove the relevant boundary wall
	for ent in maze.getEntrances():
		# need to figure out which direction to remove wall
		# entrance is at bottom, need to remove wall in "up" direction
		if ent.getRow() == -1:
			maze.removeWall(ent, Coordinates(0, ent.getCol()))
		# entrance is at top, need to remove wall in "down" direction
		elif ent.getRow() == maze.rowNum():
			maze.removeWall(ent, Coordinates(maze.rowNum()-1, ent.getCol()))
		# entrace is to the left, need to remove wall in "right" direction
		elif ent.getCol() == -1:
			maze.removeWall(ent, Coordinates(ent.getRow(), 0))
		# entrance is to the right, need to remove wall in "left" direction
		elif ent.getCol() == maze.colNum():
			maze.removeWall(ent, Coordinates(ent.getRow(), maze.colNum()-1))




def addExits(self, maze:Maze):
	"""
	Add exit(s) to the maze.

	@param maze Maze which we update on to generate a maze. 
	"""
	
	# when adding the exits, we need to remove the relevant boundary wall
	for ext in maze.getExits():
		# need to figure out which direction to remove wall
		# exit is at bottom, need to remove wall in "up" direction
		if ext.getRow() == -1:
			maze.removeWall(ext, Coordinates(0, ext.getCol()))
		# exit is at top, need to remove wall in "down" direction
		elif ext.getRow() == maze.rowNum():
			maze.removeWall(ext, Coordinates(maze.rowNum()-1, ext.getCol()))
		# exit is to the left, need to remove wall in "right" direction
		elif ext.getCol() == -1:
			maze.removeWall(ext, Coordinates(ext.getRow(), 0))
		# exit is to the right, need to remove wall in "left" direction
		elif ext.getCol() == maze.colNum():
			maze.removeWall(ext, Coordinates(ext.getRow(), maze.colNum()-1))

	# -------------------------------------------------------------------

DON'T CHANGE THIS FILE.

This is the entry point to run the program.

Refer to usage() for exact format of input expected to the program.

author = 'Jeffrey Chan'

copyright = 'Copyright 2024, RMIT University'

-------------------------------------------------------------------

import sys import time import json from typing import List

from maze.util import Coordinates from maze.maze import Maze from maze.arrayMaze import ArrayMaze from maze.graphMaze import GraphMaze

from generation.mazeGenerator import MazeGenerator from generation.recurBackGenerator import RecurBackMazeGenerator

this checks if Visualizer has been imported properly.

if not, likely missing some packages, e.g., matplotlib.

in that

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, I can do that. However, you haven't provided any text for me to respond to. Could you please provide the text?

Similar Questions

/. Maze path building// you are given a 2d array of integers// 0 represents a passable walkable spot// 1 is a impassible barrier or wall// return a path from the top left to the bottom right// example…using System;class Solution{ static void Main(string[] args) { }}// Enjoy your interview!

What is a generator function in Python?A function that generates random numbersA function that returns a generator objectA function that generates sequences of values lazilyA function that generates functions

a maze using prepositions to reach the treasure at the end.

In a Python simulation of the Monty Hall problem, what represents the doors and their contents1 pointVariablesFunctionsClassesLists

class Points(object): def __init__(self,x,y): self.x=x self.y=y def print_point(self): print('x=',self.x,' y=',self.y)p1=Points("A","B")p1.print_point()

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.