Chess

I’ve always liked playing Chess, however i’ve never been very good, I only think a few moves ahead, if that. Usually I go on instinct. Computers go the opposite way, calculating which moves would be the best by looking ahead and seeing which one would result in a win.

The game of Chess has been made into computer programs countless times already. However I wanted to try it myself, mainly because if I want to make TimeChess, I’m going to need a good understanding of how it works. The WPF Grid element was excellent at making the chess board. The difficult part was creating the game logic which would allow the pieces to make their moves. The piece that proved most difficult was the ‘Pawn’, it’s the only one which requires the game logic to know what team it’s on, as the direction it moves depends on the team it’s on. Also it has a number of special moves like it capture and it’s starting move. The rest of the pieces (apart from Castling) are pretty simple to implement, even the knight moves.

case Piece.Knight :
                    if (
                        (
                        (thisX == lastX + 1 || thisX == lastX - 1)
                        &&
                        (thisY == lastY + 2 || thisY == lastY - 2)
                        )
                        ||
                        (
                        (thisX == lastX + 2 || thisX == lastX - 2)
                        &&
                        (thisY == lastY + 1 || thisY == lastY - 1)
                        )
                        )
                    {                        
                        moveVaild = true;
                    }
                    break;
This entry was posted in Game Development and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *