Generate pacman labyrinth

Let’s say my labyrinth it’s a bidimensional array (35x25). I need an algorithm to generate that array … can you give me some hints ?

in my array i have 0 - walkable space, 1- wall, 2- coin…and so on

There is a lot of different algorithms and tutorials around the web on this topic, google is full of results, one of them: http://weblog.jamisbuck.org/2011/2/7/maze-generation-algorithm-recap

I don’t think any of those algorithms would generate a fun, playable game of Pac-Man @max. Are you sure you want to randomly generate the labyrinth? Or are you just asking how you could define a map somehow and then generate the play area from that in the game? If it’s the latter, you could check out ‘Zombie Pac-Man’:

https://playcanvas.com/project/331628/overview/Zombie%20Pac-man

The script which defines the map and then generates the level from it is here:

https://playcanvas.com/editor/code/331628/map.js

It sort of does what you describe. Defines a two dimensional array of IDs which correspond to a ‘tile type’ (space, wall, etc). It’s quite an old game and I would probably code it differently today, but it might be useful for you to reference. :smile: