Computer Chess VII: User Interface

Before diving into making the UI, we need to have a list of specifications. I finalized upon the following: Ability to switch/select the sideComputer mode/2 player modeAsk the computer to play/think for youBasic options such as printing the board, displaying help, exiting etc. We'll not develop any fancy UI here, but just interact through the…

Advertisements

Computer Chess VI: End of Game Conditions

Like any other game, we need to know if our game has ended. There can be various reasons for this: Checkmate, stalemate, draw by insufficient material, draw by repetition of the same position 3 times and the rare case when no piece is captured for more than 50 moves. We implement a function which tells…

Computer Chess IV: Special Moves Continued…

I left out en passant last time. After trying for some time, I came up with a rather ugly way of implementing it(look here). Nevertheless, here is it. We modify the chessboard and move classes as follows: class move { public: ... bool do_enpassant; ... move(bool do_enpassant, std::pair<int, int> init_pos, std::pair<int, int> final_pos, int captured_piece)…

Computer Chess IV: Special Moves

Today, let us cover pawn promotion, castling, and en passant. First, let's begin with pawn promotion. Take a look at the existing move class, and the make_move and undo_move functions: class move { public: std::pair<int, int> init_pos; std::pair<int, int> final_pos; int captured_piece; move(std::pair<int, int> init_pos, std::pair<int, int> final_pos, int captured_piece) { this->init_pos = init_pos; this->final_pos…

Computer Chess III: Move generation for knights, kings and pawns

Hey folks! Last time we dealt with move generation for sliders. This time, we'll see how to generate good old knight moves. We've actually gone through the more arduous part of slider move generation first, so the following code snippet should be a piece of cake for you: // Move generation for knights - both…

Computer Chess II: Move Generation

In the previous article, we saw a simple way to represent the board and associated details in memory. Now, we'll deal with move playing and generation. Specifically, this time, we'll only deal with slider moves. Chess pieces can be classified as sliders and leapers. For example, rooks and bishops are sliders whereas the knight is…