Skip to content

Input representation

QueensGambit edited this page Dec 27, 2018 · 6 revisions

Input representation

The overall input representation can be seen as a hybrid between chess and shogi compared to to the Alpha-Zero paper the main difference for both CrazyAra 0.1 and CrazyAra 0.2 is the avoidance of a history of past board representations.

This has several motivations:

  • Crazyhouse, as well as chess is a full information game. In theory the history isn't needed to find the best possible move.
  • The avoidance of the history allows better compatibility as an analysis uci engine. Otherwise one would have to add dummy layers which will distort the network predictions.
  • Avoiding the history reduces model parameters, storage for saving the dataset and allows higher batch-sizes during training
  • The en-passent capture possibility has been included in the input representation as an additional layer -> this allows fen-conversion capability while maintaining a small input shape.
  • Deep Mind mentioned that the history acts as an attention mechanism. If one is interested in this attention mechanism one could also only highlight only the last move squares.

Overview of the full input-plane representation:

Crazyhouse

Feature Planes Comment
P1 piece 6 pieces are ordered: PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING
P2 piece 6 pieces are ordered: PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING
Repetitions 2 two planes (full zeros/ones) indicating how often the board positions has occurred
P1 prisoner count 5 pieces are ordered: PAWN, KNIGHT, BISHOP, ROOK, QUEEN) (excluding the KING)
P2 prisoner count 5 pieces are ordered: PAWN, KNIGHT, BISHOP, ROOK, QUEEN) (excluding the KING)
P1 Promoted Pawns Mask 1 binary map indicating the pieces which have been promoted
P2 Promoted Pawns Mask 1 binary map indicating the pieces which have been promoted
En-passant square 1 Binary map indicating the square where en-passant capture is possible
Colour 1 all zeros for black and all ones for white
Total move count 1 integer value setting the move count (uci notation))
P1 castling 2 One if castling is possible, else zero
P2 castling 2 One if castling is possible, else zero
No-progress count 1 Setting the no progress counter as integer values, (described by uci halfmoves format)

The history list of the past 7 board states have been removed

The total number of planes is calculated as follows:

27 + 7 = 34 planes total

  • All Input planes are scaled to the linear range of [0.,1].

For this several constants are introduced MAX_NB_PRISONERS, MAX_NB_MOVES, MAX_NB_NO_PROGRESS. See crazyhouse/constants.py for more details.

This was essential when training with Stochastic Gradient Descent. The Adam optimizer could handle un-normalized input features better, but converged overall to a worse local minimum compared to SGD Nesetrov Momentum on normalized features.

A demonstrative visualization of this input representation, can be found here.

Clone this wiki locally