Chess Pieces
Last updated
Last updated
A generalisation to the 8 Queens Problem, the following images show the ways in which single chess pieces can be placed on increasing board sizes, such that each piece is not being attacked by another. However, unlike the 8 Queens Problem which has a solution, the following images are only coloured by the depth (number of moves), rather than the number of solutions.
The following images show the different ways each piece can be placed on a 3x3 and 4x4 board. You can see them and other variations in the gallery.
The tree painter used is the type PiecesBoardPainter
which converts the game tree into a colour tree using the following code:
First the game tree is converted into a resultTree
. Each node in the tree is either represented by the game's result or, if there are still available moves, the current depth. The result returned by the PiecesBoardState
is a score equal to the number of pieces successfully placed or -1 if placing a piece resulted in an attack.
The result is then turned into a colour by normalising the score against the best possible one and then using a colorInterpolator
(default for PiecesBoardPainter
is GreyscaleInterpolator
)