Re: How Many Pac-Man Mazes Are There?
Posted: Sun Jul 19, 2020 2:21 pm
Nah, it's cleverer than that.
Here's an updated algorithm and some tests. It now includes all four long L-shapes. Because of the longer shape list, the random selector now picks a number from 0..31 (it was 0..15) and mods it, so you get 0..16 or 0..14 out of it. That way, the last two shapes (short vertical and horizontal bars) are half as likely to be picked first compared to the other more interesting shapes. And the long horizontal and vertical bars are now only tried if all else fails. There's also a secondary set of checks that makes it try it all again a couple of times if (a) there aren't enough vertical walls in the maze or (b) there's no vertical wall at all between the tunnel entrances. Makes the mazes more interesting.
Download: http://railtron.com/files/spectrum/PacM ... mo_002.zip
I think that's coming up with some pretty interesting mazes, and doing some fairly smart shape-fitting along the way. I'm not sure I'd have tried some of those concepts manually, particularly the fourth one there. Looks like it might be fun to play though.
And here's how the dots are done:
In the original Pac-Man the dots are at the centre of the character cells, and the sprites are centred on them. It's the walls that bridge over multiple cells.
In my version, I've shifted all the graphics up-and-left by 1 pixel. Thus each dot is in the bottom-right of a single character cell. The walls are 6 pixels wide and the sprites are 14x14, so they can all be shifted up-left.
Now I only have to navigate the sprites around one-cell-wide passageways (shown in blue) using their top-left point as a reference. This makes their movement much easier to deal with, particularly at junctions. The sprites treat the black areas as solid walls they can't pass through (except for exiting the ghost house), but the body of the sprite can still be drawn over the black areas.
Here's an updated algorithm and some tests. It now includes all four long L-shapes. Because of the longer shape list, the random selector now picks a number from 0..31 (it was 0..15) and mods it, so you get 0..16 or 0..14 out of it. That way, the last two shapes (short vertical and horizontal bars) are half as likely to be picked first compared to the other more interesting shapes. And the long horizontal and vertical bars are now only tried if all else fails. There's also a secondary set of checks that makes it try it all again a couple of times if (a) there aren't enough vertical walls in the maze or (b) there's no vertical wall at all between the tunnel entrances. Makes the mazes more interesting.
Download: http://railtron.com/files/spectrum/PacM ... mo_002.zip
I think that's coming up with some pretty interesting mazes, and doing some fairly smart shape-fitting along the way. I'm not sure I'd have tried some of those concepts manually, particularly the fourth one there. Looks like it might be fun to play though.
And here's how the dots are done:
In the original Pac-Man the dots are at the centre of the character cells, and the sprites are centred on them. It's the walls that bridge over multiple cells.
In my version, I've shifted all the graphics up-and-left by 1 pixel. Thus each dot is in the bottom-right of a single character cell. The walls are 6 pixels wide and the sprites are 14x14, so they can all be shifted up-left.
Now I only have to navigate the sprites around one-cell-wide passageways (shown in blue) using their top-left point as a reference. This makes their movement much easier to deal with, particularly at junctions. The sprites treat the black areas as solid walls they can't pass through (except for exiting the ghost house), but the body of the sprite can still be drawn over the black areas.