Chess Board Square

In this post I will discuss the chess board square representation. Before we can discuss the chess board we need to model how each of the chess board squares will be represented on our board. The chess board square will be declared as an internal struct. I have found that small structs seem to perform better then small classes. Also making objects internal or even better private, tends to increase performance.

internal struct Square 

Each chess board square can contain a chess piece.

internal Piece Piece;

Each Board Square will also have the following copy constructor that will copy the chess piece from the copied chess board square or set the chess piece to null, signifying that the current square is empty.

internal Square(Piece piece) 
{  
    Piece = new Piece(piece); 
}

Want to skip to the end, download the full chess engine source code on GitHub