Implementing the Grid Class
Explore how to create and implement the Grid class, which organizes cells into a two-dimensional array, assigns neighbors, and prepares the structure necessary for generating and displaying mazes. Understand methods for accessing and iterating through cells to set a foundation for maze algorithms.
We'll cover the following...
Implementing the Grid class
As seen in the previous lesson, the Grid class is essentially just a wrapper around a two-dimensional array of cells. Let’s add the following code into a file named grid.rb, making sure it’s in the same directory as the cell.rb file we created earlier so the grid can find the Cell class that it needs. Let's walk through this together, one piece at a time.
First, we require the Cell class that we just wrote since the grid depends on it. Note also that the grid keeps track of the ...