Skip to Main Content
Mazes for Programmers
book

Mazes for Programmers

by Jamis Buck
July 2015
Intermediate to advanced content levelIntermediate to advanced
286 pages
6h 31m
English
Pragmatic Bookshelf
Content preview from Mazes for Programmers

Introducing Our Basic Grid

The examples in this and later chapters will all build on one particular grid implementation, so we’ll spend a few pages on it here. This will be the tool we’ll use to build out our mazes, either by using this Grid class directly, or by subclassing it and adding more specific functionality. Seeing how it’s put together ought to make things clearer. We’ll start simple, and in the next few chapters we’ll add to it and extend it as needed.

What we want is to be able to instantiate the grid and operate on the cells that it contains. In pseudocode, something like this:

 
# instantiate a 10x10 grid
 
grid = Grid.new(10, 10)
 
 
# get the cell at row 1, column 2
 
cell = grid[1, 2]
 
 
# iterate over all the cells in the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Exercises for Programmers

Exercises for Programmers

Brian P. Hogan

Publisher Resources

ISBN: 9781680501315Errata Page