Lab 2: Maze Generation

Due: Tuesday 9/21/2021 by 11:59pm

Description

The purpose of this lab is to learn more about the use of geometry, transformations, and hierarchies in computer graphics and gain exposure to topics in procedural content generation.
This lab will focus on the creation of a scene consisting of a maze.
A future lab will move a character within the scene.

Learning Objectives 


VISUAL EXAMPLES:

 

IMPLEMENTATION - GRADING, RESTRICTIONS, AND TASKS:

Write C# code that will create a maze consisting of GameObjects or prefabs. 

Higher-level tasks:

  1. Create a logical grid (call it GridGraph to avoid name conflict with Unity) that implements the IEnumerable<T> interface and can be queried for:
    1. Current cell value at a position (i,j). 
    2. Number of rows
    3. Number of columns
  2. In a separate "decorator" class (SpatialGridGraph) implement a spatial mapping from cell space (i,j) to model space (x,z) and its inverse mapping, (x,y)->(i,j) . Pass i to the contructor and/or have a property setter that takes two Func<Vector2,Vector2>'s.
    1. Current cell value at a position (i,j). 
    2. Current cell value at a position (x,y). - new!
    3. Number of rows
    4. Number of columns
  3. One grid will be a grid of Booleans that will indicate whether the cell is "occupied" or not. In this case, the grid cell dat, T,  is a bool.
  4. Create and try to only use an interface for this class (IGridGraph<T>) Hint: In Visual Studio you can use Edit->Refactor->Extract Interface (you may need to deselect the GetEnumerator and then derive this interface from IEnumerable<T>). Actually, I will provide this.
  5. Now add a SetCell(T dataValue) method to the implementations (not the interface as this allows for immutable implementations).   
  6. (optional) Write a GridTest Monobehaviour script that creates a GridGraph<bool>, sets some values and then using the Enumerator to print out all of the values to the Console. 
  7. Create a Flag Enum for your Maze (or a grid of enum Directions).
  8. (optional) Write a GridTest Monobehaviour script that creates a GridGraph<Direction>, where Direction is your Flag Enum, and sets some values. Print these out as above (should be able to use the same method).
  9. Create an interface to create new GameObjects (aka a Factory). The simpliest one will take a GameObject and create new copies. More sophisticated would take a List of GameObjects and return one from the list (perhaps randomly or controlled).
  10. Create a class that will take a list of points (origins), a factory, and perhaps other PCG data which then creates game objects. Note: For GridGraph<bool> if you call this once for all points that are false ("empty") with one factory and again for all points that are true ("occupied") with another factory you can control the floor and wall creation.
  11.  Implement a maze generation algorithm that uses your new GridGraph<Direction> class.
  12. Write a class or static method that will convert your a GridGraph<Direction> of size NxM to a GridGraph<bool> of larger size (3Nx3M or 9Nx5M, ...)       
  13. Import a package or two to use as floors/platforms, walls, lava, etc.  
  14. Create prefabs for the occupied cells and unoccupied cells for your maze. Some free assets with some nice blocks.  
  15. Generate a Maze and move the camera to get several good images, or have several cameras and add the camera switch input (without a Follow script).
  16. Using your classes, create a level from the GridGraph<bool> using the prefabs and your factory.    
  17. Write a report similar to Lab1 and export your Scene keeping your project fairly small (<20MB)  

Grading

The lab is graded out of 35 points. Points will be allocated based on the following features:

Extra credit features (each worth 1 point. Score may only go as high as 40):

Submitting your work:

Similar to what you did for lab 1, you will submit this work on Carmen as a Unity package. Once you are done you should have assets including a scene file and script(s) - select your scene (in the Project window), then right-click and select export package, and name the package something like yourlastname_lab2.unitypackage. As in lab 1, you can test to determine if your package can be graded by making a new Unity project, importing the package, installing the Input System package, opening the scene file, and running the game. You must submit work that runs in order to receive any credit.