A map is only interesting once some cells are blocked. Today you let a cell be marked as a wall and ask whether a cell is walkable, which is the single distinction every search in this project will branch on.
Mark a cell as a wall and report whether a given cell is walkable.
A grid of open cells is just an empty field. What turns it into a map worth
searching is obstacles: cells you cannot enter. We represent that with a single
bit per cell, a wall flag, stored in a flat slice indexed by y*W + x. Every
cell starts open, and marking a wall sets its bit.
The one question every search asks about a cell is walkable: can I stand here?
For now that is simply the opposite of being a wall. Next lesson we fold in bounds
checking so that stepping off the edge of the grid counts as not walkable too, but
the shape is already here: walls carve the searchable space, and Walkable is the
gate every neighbor step will pass through.
// name the (x,y) pair now; it will be a map key and path element latertype Coord struct{ X, Y int }// store one bool per cell; index it as Y*W + Xtype Grid struct {W, H intwalls []bool}func NewGrid(w, h int) *Grid { return &Grid{W: w, H: h, walls: make([]bool, w*h)} }func (g *Grid) SetWall(c Coord) { g.walls[c.Y*g.W+c.X] = true }func (g *Grid) Wall(c Coord) bool { return g.walls[c.Y*g.W+c.X] }// Walkable is just: not a wall (bounds come next lesson)