A Battlestar (region-less Star Battle) puzzle generator. It samples a uniform random legal star configuration, then repeatedly places blocks on an empty board until the star configuration is the unique solution to the board. Blocks are sampled according to a Boltzmann distribution over the star frequencies of all alternative solutions to the current board.
- NumPy
- PIL (for generating images)
- S: Board side-length
- N: Stars per row and column
- temperature: Boltzmann distribution (inverse) temperature- higher produces boards with fewer, but more structured clues, and vice-versa.
- n_puzzles: Number of puzzles to generate
# Generate 2 8x8 1★ boards with (inverse) temperature 20
python3 battlestar_generator.py 8 1 20 2
> loading star configs...
> processing star configs...
> generating...
board:
░░░░░░░░░░░░░░░░
░░▓▓▓▓▓▓▓▓▓▓░░░░
░░░░░░░░░░░░░░░░
░░░░░░░░░░▓▓░░░░
░░░░▓▓░░▓▓▓▓▓▓▓▓
░░░░░░▓▓▓▓▓▓▓▓░░
░░░░▓▓░░▓▓▓▓▓▓▓▓
░░░░░░░░░░▓▓▓▓░░
solution:
. . . . . * . .
* . . . . . . .
. . * . . . . .
. . . . . . * .
. . . * . . . .
. . . . . . . *
. * . . . . . .
. . . . * . . .
> saved battlestar_8_1_20_1.png
board:
░░░░░░░░░░░░░░░░
░░▓▓▓▓▓▓░░░░░░░░
░░▓▓░░▓▓░░░░▓▓░░
░░░░░░░░░░▓▓▓▓▓▓
░░▓▓░░░░░░▓▓▓▓▓▓
░░▓▓░░░░░░▓▓▓▓▓▓
░░░░░░░░░░░░▓▓▓▓
░░▓▓▓▓░░░░▓▓▓▓▓▓
solution:
. . . . . . * .
* . . . . . . .
. . . . . . . *
. * . . . . . .
. . . . * . . .
. . * . . . . .
. . . . . * . .
. . . * . . . .
> saved battlestar_8_1_20_2.png