Vazno / minesweeper-board

Minesweeper board generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Minesweeper board generator

Usage is simple:

b = Board(8, 6, 5)
b.generate()
[[*, 3, *, 1, 0, 0, 0, 0],
 [2, *, 2, 1, 0, 0, 0, 0],
 [1, 1, 2, 1, 1, 0, 0, 0],
 [0, 0, 1, *, 1, 1, 1, 1],
 [0, 0, 1, 1, 1, 1, *, 1],
 [0, 0, 0, 0, 0, 1, 1, 1]]

Board contains Cell objects

print(type(b.generate()[0][0])) # -> <class '__main__.Cell'>

Cell object has these attributes:

  • state (UnopenedCell, OpenedCell, FlaggedCell)
  • contain (Empty, Bomb)

Empty object has num attribute. (Increments by __add_nums() private function)

About

Minesweeper board generator

License:MIT License


Languages

Language:Python 100.0%