fredster64 / randomly-generated-maze Goto Github PK
View Code? Open in Web Editor NEWA randomly-generated maze created in Python.
License: MIT License
A randomly-generated maze created in Python.
License: MIT License
Need to reduce the amount of code in the main loop. This could be done by moving inline code into function calls, and placing these function calls in appropriate files.
Should create a graph class for more efficient and well-organised storage of a graph. This could involve use of an adjacency matrix to store graph data.
This will help with implementing Dijkstra's algorithm, since this will be made easier by access to organised graph data. It will also improve the speed of graph searching and drawing.
The opponent always moves in the optimal direction. This often makes the game impossibly difficult. Possible solutions are:
The following error occurs sometimes he game works.
Traceback (most recent call last):
File "Maze.py", line 14, in
main()
File "Maze.py", line 10, in main
gameLoop(gameEngine)
File "/home/itadmin/Desktop/DSA project/Randomly-Generated-Maze-master (1)/GameEngine.py", line 95, in gameLoop
self.opponent.currentDirection = getOpponentDirection(self.player.pos, self.opponent.pos, self.maze, opponentMoveCount )
File "/home/itadmin/Desktop/DSA project/Randomly-Generated-Maze-master (1)/MazeIncludes.py", line 177, in getOpponentDirection
return moveList[randint(0, 2)]
IndexError: list index out of range
The movement of both game characters is quick and responsive in the early stages of the game. However, when the player is nearing the endpoint of the maze, gameplay slows down dramatically.
When the opponent is near (i.e. adjacent to, or occupying the same position as) the player, the game often crashes.
For 10x10 mazes and above, creation and drawing is slow. This needs to be attended to.
Sometimes, the opponent will randomly move off the screen, crashing the game.
Branch: master
After creating the maze, the program throws an Exception:
File "/home/alfro/projects/Randomly-Generated-Maze/Objects.py", line 138, in centre
return v(0.5*(self.v1[0]+self.v2[0]), 0.5*(self.v1[1]+self.v2[1]), s)
NameError: name 's' is not defined
The function "centre" does not have an 's' variable, and neither is present as a global.
Full output:
pygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html
Welcome to the maze!
You start in the top-left corner and can move left, right, up or down.
Please choose how long and wide you want the maze to be.
What length? 10
What width? 10
Would you like to play as a cat or a dog?
dog
Loading...
Traceback (most recent call last):
File "Maze.py", line 14, in <module>
main()
File "Maze.py", line 9, in main
gameEngine = GameEngine()
File "/home/alfro/projects/Randomly-Generated-Maze/GameEngine.py", line 44, in __init__
dm.drawMaze(self.maze, s, self.gameDisplay, self.surface)
File "/home/alfro/projects/Randomly-Generated-Maze/Drawing_Maze.py", line 45, in drawMaze
rotv1 = rot(pi/2, v1, centre(edgeToAdd))
File "/home/alfro/projects/Randomly-Generated-Maze/Objects.py", line 138, in centre
return v(0.5*(self.v1[0]+self.v2[0]), 0.5*(self.v1[1]+self.v2[1]), s)
NameError: name 's' is not defined
The game errors when selecting the character, if using Python 2.7. This is due to the use of "input()".
File "/home/alfro/projects/Randomly-Generated-Maze/MazeIncludes.py", line 202, in getSprites
answer = input()
This didn't take long to figure out, but maybe the README should have a note pointing that this is meant to be run on python 3
Full error (for completion's sake):
(venv2) ➜ Randomly-Generated-Maze master ✗ python Maze.py
pygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html
Welcome to the maze!
You start in the top-left corner and can move left, right, up or down.
Please choose how long and wide you want the maze to be.
What length? 20
What width? 20
Would you like to play as a cat or a dog?
cat
Traceback (most recent call last):
File "Maze.py", line 14, in <module>
main()
File "Maze.py", line 9, in main
gameEngine = GameEngine()
File "/home/alfro/projects/Randomly-Generated-Maze/GameEngine.py", line 24, in __init__
playerSpriteDict = getSprites(0)
File "/home/alfro/projects/Randomly-Generated-Maze/MazeIncludes.py", line 202, in getSprites
answer = input()
File "<string>", line 1, in <module>
NameError: name 'cat' is not defined
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.