package knights_tour
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=4c693ffd5554cdbb064b0aa2ec104ec1831d3abd077ea2cec0a52922ebdc2212
sha512=f3cd71b81c7e44e7186e43c407ee679a2fede799a8aa07c495932a1a7469c5cc80a32f28eaa0b2868d195e64896802baf7959bae5b3466f777279fa1500f3e60
doc/knights_tour.pentominos/Pentominos/Board/index.html
Module Pentominos.Board
Source
A Polyomino board is a grid of squares that need to be covered by Polyomino puzzle pieces. It is possible for some parts of the grid to be blocked off.
For example in the classical Pentomino puzzle, the board is an 8x8
chessboard, with a 2x2
grid at the center of the board blocked of. This leaves 8x8-2x2 = 64 - 4 = 60
squares to be filled. The 60 remaining squares need to be covered up by fitting all of the 12 pentomino shapes, which are 5 squares each.
The Board.t data structure keeps track of the current state of the board. This means that it provides a way to:
- determine which squares are still vacant
- for occupied squares, determine which puzzle piece has been placed to cover that square.
- count the number of vacant spots (to determine if the puzzle is solved)
A value of type square
indicates the state of a square at a given board {x;y}
coordinate.
A square can be in either one of the following states:
Blocked
: a square that is not meant to be covered. Either the square is not within the bounds of the board, or it is one of the squares on the board that are blocked from the start. (e.g. the 4 center squares in the classic board)Occupied
: a polyomino was placed on the board and it covers the square.Vacant
: no polymino has been placed that covers the square yet.
A constant to gives the size in pixels of a polyomino square.
Initialize the graphic module to draw boards in a window on the screen. This function should only be called once, and should be called before drawing the first board on the screen. It requires the dimensions of the board as an input parameter (needed to open a window of the appropriate size)
Each board has a size consisting of a width and height. All non-blocked board coordinates are contained within the range 0..width
for the x
coordinate and 0..height
for the y
coordinate.
This function returns the size of the board as a point {x=width;y=height}
Get the state of a square at a given {x;y}
coordinate.
Initialize a Polyomino board starting state from a 'string image'. The string image represents the vacant squares by `#`
characters and any other sqaures by '.'. Note that the dimensions of the board are implied. So for example the classic pentomino board is initialized like so:
let classic_board = Board.of_string "
########
########
########
###..###
###..###
########
########
########
"
Loads a board from a string image. This requires a function that interprets the characters of the string, mapping each char to square
state
rectangle w h
creates a plain rectangular board of given dimensions. All squares in this board are vacant (so there are no blocked areas inside the rectangle)
Place a polyomino on the board. It is assumed that the given PointSet is a rotated / mirrored / translated variant of the given Polyomino.
Gets all vacant points on the board (i.e. any point that is not occupied and is not blocked)
Convert board into a two-dimensional 'string image'. Each square on the board is represented by a single character:
- `.`: a vacant square
- a capital letter: square occupied by polyomino with that name
- #: a blocked square