22 lines
598 B
Go
22 lines
598 B
Go
// Package cell represents a single cell in a maze grid.
|
|||
|
|
package cell
|
||
|
|
|
||
|
|
import (
|
||
|
|
"code.chimeric.al/dwrz/minotaur/pkg/maze/direction"
|
||
|
|
)
|
||
|
|
|
||
|
|
// Cell is a bitmask of open passages from a cell to its neighbors.
|
||
|
|
// Bit d (1 << d) is 1 when the passage in direction d is open, and 0 when a
|
||
|
|
// wall blocks that direction.
|
||
|
|
type Cell uint8
|
||
|
|
|
||
|
|
// HasDirection reports whether the passage in direction d is open.
|
||
|
|
func (c Cell) HasDirection(d direction.Direction) bool {
|
||
|
|
return c&(1<<d) != 0
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetDirection opens the passage in direction d.
|
||
|
|
func (c *Cell) SetDirection(d direction.Direction) {
|
||
|
|
*c |= 1 << d
|
||
|
|
}
|