Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Problem Description: This coursework will constitute 40% of the final module mark, and must be submitted by Tuesday July 13, 2021. Mark penalties will be applied for late submission (5% per working...

1 answer below »
Problem Description: This coursework will constitute 40% of the final module mark, and must be submitted by Tuesday July 13, 2021. Mark penalties will be applied for late submission (5% per working day), and extensions are only allowed in cases of bone fide and documented extenuating circumstances. Write a game program to implement a maze. The program should allow a user to navigate from one 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. It may have several exits (assume that exits are a special kind of room). One can only get from one room to another by following the zeros. The borders are obstacles that are represented by ones. The aim of the program is to find and display the shortest path taken to exit the maze. MAJOR PROJECT 2 | Page XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXXR XXXXXXXXXXR XXXXXXXXXXR XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXXR XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX1 8 E XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX0 0 1 R XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXXR XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXXE XXXXXXXXXXThe program should allow you to move in four directions at any point in time - right, left, up, down - but not diagonally. Moving right means adding {Row,1} to the current coordinates. Moving left means adding {Row,-1} to the current coordinates. Moving up means adding {-1,Column} to the current coordinates. Moving down means adding {1,Column} to the current coordinates. Zero (0) indicates that a cell is free and one (1) indicates an obstacle. The program tries all the 4 directions one-by-one, till it finds an empty cell. If it finds one, it moves to that cell and marks it with a 2 (saying it has visited it once). Then it continues to move ahead until an exit is found.
Answered Same Day Jul 14, 2021

Solution

Swapnil answered on Jul 15 2021
152 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