Concept of a Move Array

In a chess game it is sometimes convenient to view the history of the game, previous moves made and so forth. The user may want to take back all the moves that he's made so far and make new moves, or just browse through the whole game itself. This is where the concept of a move array comes into play. The move arrray consist of several things. First, an array with the actual moves in it

    [Move1, Move2, Move3, Move, ...Move n-1]


The Moves are objects that contain all the information the board needs to make a move. If you give the board the first move object in the array, it will make the first move. You can make the move be taken back by switching the stat row and end row and the start col and end col. In this way the board can iterate through game history in any direction.

Captures in the Move Array

During the course of the game captures may be made. When a capturing move is taken back we must account for this because that means we have to add an extra piece to the board. Therefore in the move array it is critical to know where capturing moves were made in order to handle them appropriately. For this, we use another array that uses the same structure as the array containing moves but contains info on captures. The array is simple. If a capture is made it contains a true value otherwise it contains a false. If you want to know where captures are made you can call the array at a certain point.

    [true, false, true, false, false, false....]


Castling in the Move Array

In the course of a chess game two castles can be made, one by black and one by white. In order take it back we simply need to know where it occured. Then we can handle it accordingly. Therefore, this array is simple. It only contains the point where a castling move occured. One for white and one for black.

    [whiteCasltingPoint, blackCastlingPoint]

back    next