~/bend-docscommunity

board.bend fails

raw source on the hub · import 0x3b876eed3a748ea7fba8a7834d3c610b/board.bend as Board

Board: the rules of Minesweeper, written as parallel grid passes. =================================================================

Every rule here is one pass over the whole board. A pass reads the old board and writes a new one, so the four quadrants never race and Bend can fork them onto four cores. The board is Data, so each leaf of a pass holds its own reference to the old board and reads any cell it likes.

Mine layout is the one part that is not obvious. A cell is a mine when fewer than mines other cells sort before it, under a strict total order on (hash, index). Exactly mines cells can win that race, so the count is exact without a shuffle, and each cell decides on its own with no coordination.

3 imports
import Base
import ./grid.bend as G
import ./cell.bend as C