Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating Pacman Labyrinth
#1
Hello. I am going to make Pacman in pygame. So, what is the best way(algorythm) to realize labyrinth in Pacman. I would like to have it like a graph, to use further. Thank you for your advices.
Reply
#2
I'd divide your play surface into a grid of cells, each with 4 sides and a center color. Each side is a line that is either on or off and each cell gets redrawn when it is crossed by a character sprite. In that each sprite needs to report each cell that it crosses, it should report it to the board, and the board should redraw that cell.
Reply
#3
If you want to create a random graph, there is an algorithm by David Wilson that creates a random graph such that all possible graphs have an equal chance of being chosen. Pick a random node to start with. Then pick another random node, and add an edge to the current node if it is not already in the graph. The second random node becomes the current node whether or not it was already in the graph. Repeat this process until all of the possible nodes are in the graph. At that point you have a random spanning graph. You can now add edges to that graph randomly until you have the number of edges you want.

Since pacman labyrinths tend to be symmetrical, you might want to generate a random graph and then reflect it once or twice.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Multiple wall collision in pacman rustyjoe 4 4,029 Aug-11-2019, 08:08 AM
Last Post: rustyjoe

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020