ProblemDescription: Thiscourseworkwillconstitute40%ofthefinalmodulemark,andmustbesubmittedbyTuesday July 13, 2021. Mark penalties will be applied for late submission (5% per working...

1 answer below »
ProblemDescription: Thiscourseworkwillconstitute40%ofthefinalmodulemark,andmustbesubmittedbyTuesday July 13, 2021. Mark penalties will be applied for late submission (5% per working day), and extensionsareonly allowedincasesofbonefide anddocumentedextenuatingcircumstances. Writeagameprogramtoimplementamaze.Theprogramshouldallowausertonavigatefromone room (R1,R3,R5,R6,R7 and R8) to another to find an exit (E2 or E4). A maze is a collections of rooms connected by corridors. Itmay have several exits (assume that exits are a special kind of room).Onecanonlygetfromoneroomtoanotherbyfollowingthezeros.Thebordersareobstacles thatarerepresentedbyones.Theaimoftheprogramistofindanddisplaytheshortestpathtaken toexitthemaze. MAJORPROJECT 2 |Page 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 R1 1 0 0 0 0 1 R3 1 0 0 0 0 1 R5 1 0 0 0 0 1 2 1 0 1 0 0 0 0 1 0 1 0 0 0 0 1 0 1 0 0 0 0 1 3 1 0 1 1 1 1 0 1 0 1 1 1 1 0 1 0 1 0 1 1 1 1 4 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 R7 1 5 1 1 1 1 1 0 1 1 1 1 0 1 0 0 0 0 0 0 1 1 1 1 6 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 7 1 1 1 1 1 0 1 0 1 0 0 1 0 1 1 1 1 1 1 1 0 1 8 E2 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 1 0 1 9 1 1 1 1 1 0 1 0 1 0 0 1 0 1 0 0 0 0 0 1 R6 1 10 1 0 0 0 1 0 1 0 1 0 0 1 0 1 0 0 0 0 0 1 1 1 11 1 0 0 0 0 0 1 0 1 0 0 1 0 1 0 0 0 0 0 0 0 1 12 1 1 1 1 1 1 1 0 1 0 0 1 0 1 0 0 0 0 0 0 0 1 13 1 R8 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 0 0 0 0 1 14 1 1 1 1 1 1 1 1 1 1 1 1 E4 1 1 1 1 1 1 1 1 1 Theprogramshouldallowyoutomoveinfourdirectionsatanypointintime- right,left,up,down- butnotdiagonally. Movingrightmeansadding{Row,1}tothecurrentcoordinates. Movingleftmeansadding{Row,-1}tothecurrentcoordinates. Movingupmeansadding{-1,Column}tothecurrentcoordinates. Movingdownmeansadding{1,Column}tothecurrentcoordinates. Zero(0)indicates thatacellis freeandone(1)indicatesanobstacle.Theprogram triesall the4 directions one-by-one, tillit findsanempty cell. Ifit finds one,itmoves to that cellandmarksit witha2(sayingithasvisiteditonce).Thenitcontinuestomoveaheaduntilanexitisfound.
Answered Same DayJul 14, 2021

Answer To: ProblemDescription:...

Swapnil answered on Jul 15 2021
150 Votes
import PySimpleGUI as sg
import numpy as np
import math
import random
AppFont = 'Any 16'
sg.theme('DarkGrey5')
_VARS = {'cellCount': 10, 'gridSize': 400
, 'canvas': False, 'window': False,
'playerPos': [0, 0], 'cellMAP': False}
cellSize = _VARS['gridSize']/_VARS['cellCount']
exitPos = [_VARS['cellCount']-1, _VARS['cellCount']-1]
def makeMaze(dimX, dimY):
starterMap = np.zeros((dimX, dimY), dtype=int)
for x in range(2):
randRow = random.randint(1, dimX)
randColumn = random.randint(1, dimY)
starterMap[randRow-1:randRow] = 1
starterMap[:, randColumn-1] = 1

for x in range(4):
starterMap[randRow-1][random.randint(0, dimY-1)] = 0
starterMap[random.randint(0, dimX-1)][randColumn-1] = 0

starterMap[0][0] = 0
starterMap[0][1] = 0
starterMap[1][0] = 0
starterMap[dimX-1][dimY-1] = 0
starterMap[dimX-1][dimY-2] = 0
starterMap[dimX-2][dimY-1] = 0
starterMap[dimX-2][dimY-2] = 0
return starterMap
_VARS['cellMAP'] = makeMaze(_VARS['cellCount'], _VARS['cellCount'])
def drawGrid():
cells = _VARS['cellCount']
_VARS['canvas'].TKCanvas.create_rectangle(
1, 1, _VARS['gridSize'], _VARS['gridSize'], outline='BLACK', width=1)

for x in range(cells):

_VARS['canvas'].TKCanvas.create_line(
((cellSize * x), 0), ((cellSize * x), _VARS['gridSize']),
fill='BLACK', width=1)

_VARS['canvas'].TKCanvas.create_line(
(0, (cellSize * x)),...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here