For my advanced math and game AI coursework, I developed a comprehensive system in Unity that integrates procedural map generation, clustering, and real-time pathfinding to intelligently place objects throughout a game environment.
The project begins with the generation of a 2D grid map using Perlin noise, which creates a naturally varied terrain. I then apply a K-means clustering algorithm to segment this map into distinct sectors. These sectors serve as the basis for distributing different types of objects—such as prey, predators, pickables, and enemies—ensuring that placements are logically grouped and accessible.
To evaluate accessibility, I implemented a custom A* (A-star) pathfinding algorithm that operates at runtime. This approach avoids the limitations of Unity’s baked navigation meshes by dynamically assessing whether agents can reach specific areas. The algorithm also generates path tiles that connect the various sectors, creating coherent navigation routes throughout the procedurally generated map.
Additionally, I developed an interactive user interface that allows users to add different object types to the map, providing a hands-on way to test and visualize the system’s functionality. This framework not only demonstrates the effective integration of clustering and pathfinding techniques but also offers a robust foundation for further exploration of dynamic object placement in game environments.