Procedural Generation Overview
Procedural Pac-Man 3D leverages three distinct types of Procedural Content Generation (PCG) to create unique gameplay experiences with every playthrough:- Maze Generation - Tetris-piece-based algorithm for creating playable mazes
- Texture Generation - Voronoi tessellation shaders for wall aesthetics
- AI Behavior - Dynamic pathfinding and adaptive difficulty
Why Procedural Generation?
The use of PCG in this project serves several key purposes:Replayability: Every level features a unique maze layout, ensuring no two games are identical.
- Creative Constraints: The Tetris-piece algorithm generates valid, playable mazes while maintaining the classic Pac-Man gameplay feel
- Visual Variety: Randomized Voronoi shaders create distinctive wall textures for each maze
- Dynamic Challenge: AI behavior adapts based on level progression, with decreasing pathfinding update times and scare durations
PCG Techniques at a Glance
| Technique | Implementation | Purpose |
|---|---|---|
| Maze Generation | Tetris-piece algorithm | Creates unique, playable maze layouts |
| Texture Generation | GLSL Voronoi shaders | Randomizes wall appearance |
| AI Behavior | A* pathfinding | Provides intelligent ghost movement |
Architecture Overview
The procedural generation system is implemented in Three.js and consists of:- MyMaze.js - Contains
mazeGenerator(),tetris3x3Generator(), andtetrisGenerator()methods - index.html - Houses GLSL vertex and fragment shaders for Voronoi patterns
- MyGhost.js - Implements A* pathfinding with multiple behavior states
- MyGame.js - Orchestrates AI pathfinding and difficulty scaling
Learn More
Explore each PCG technique in detail:Maze Generation
Tetris-piece-based maze construction algorithm
Texture Generation
Voronoi tessellation shader implementation
AI Behavior
A* pathfinding and dynamic difficulty
Key Features
Maze Structure
Each maze is generated as a 28x30 grid with symmetrical layout, including ghost spawn areas, portal placements, and dot/pill distribution.
Visual Randomization
Wall textures use randomized shader parameters (hue, border width, cell amount) to create unique visual identities.