Saturday, October 10, 2015
How to convert pgn chess games to video free
1. Download ActivePresenter
- http://atomisystems.com/activepresenter/free-edition/
2. Download Babaschess
- http://www.babaschess.net/download.asp
3. Open ActivePresenter
- new capture
- video
4. Open Babaschess
- open pgn file
- auto-play chess game
5. Press Ctrl + End to finish video capture
6. In ActivePresenter, export video as mp4, AVI, WMV and WebM
Sunday, March 3, 2013
Example of 4-Round Swiss Chess Tournament
Swiss System Chess Tournament Basic Rules
- players with the same score are ranked according to rating
- Top half is paired with the bottom half
- Same two players cannot play twice
- Color alternates in succeeding rounds
- Winners versus winners
- Losers versus losers
- Ties are broken with Swiss tie-breaking systems
Number of Rounds
The number of rounds in a Swiss Chess Tournament is predetermined beforehand. In most occassions, it depends on the rules of the organizer and number of players. As a sample (for illustration purposes only):
up to 20 players --> 5 rounds
20 to 40 players --> 7 rounds
40 to 80 players --> 9 rounds
Number of Games in Tournament
To determine the total number of games (ideally) in the tournament:
Number of Games = [ Number of Players/2 ] x Number of Rounds
Example:
Given:
Number of players = 8
Number of rounds = 4
Using the formula,
Number of Games = 8/2 x 4
Number of Games = 4 x 4
Number of Games = 16 games
Scoring Point System
Win = 1 point
Draw = 0.5 point
Loss = 0
Pairing Procedure
Round 1:
- Pairings drawn randomly
- Pairings according to Chess Rating
- Pairings based on last year's performance.
- Pairings generated by Computer Pairing Software
Round 2:
- Winners in Round 1 play against winners
- Losers in Round 1 play against losers
Subsequent Rounds pairing rules:
- No player faces the same opponent twice
- Players play with opponents with the same or almost the same score
- Players play an equal number of games with the White and Black pieces
- Players' color of pieces alternate in each round
- Same color 3 times in a row is not allowed
Tie-Breaking
- after the last round, players are ranked by total score points
- if there is a tie, it is broken using the Buchholz chess rating (sum of all their opponents' scores) or other chess tie-breaking methods in Swiss system tournaments such as Solkoff, Median (Harkness System), Modified Median, Cumulative, and so on.
---- PAIRING ----
Prepare Table of Players sorted by Rating (descending)
Rating List of Players for Tournament (Masters & Grandmasters Championship)
2650 Players 1
2600 Players 5
2550 Players 2
2500 Players 6
2450 Players 3
2400 Players 7
2350 Players 4
2300 Players 8
Divide the list in two groups (or many groups)
Top Half: (Group I)
2650 Player 1
2550 Player 2
2450 Player 3
2350 Player 4
Bottom Half: (Group II)
2600 Player 5
2500 Player 6
2400 Player 7
2300 Player 8
Standard Swiss System Pairing
Round 1:
Player #1 versus Player #5, Player #1 wins
Player #2 versus Player #6, Player #2 wins
Player #3 versus Player #7, Player #3 wins
Player #4 versus Player #8, Player #4 wins
Winners in Round 1
Players 1
Players 2
Players 3
Players 4
Losers in Round 1
Players 5
Players 6
Players 7
Players 8
Round 2:
Winners vs. Winners
Player #1 plays Player #3, Player #1 wins
Player #2 plays Player #4, Player #2 wins
Losers vs. Losers
Player #5 plays Player #7, Player #5 wins
Player #6 plays Player #8, Player #6 wins
After two rounds, the score standings are:
Player #1: 2-0 (2 wins, no loss)
Player #2: 2-0
Player #3: 1-1 (1 win, 1 loss)
Player #4: 1-1
Player #5: 1-1
Player #6: 1-1
Player #7: 0-2 (no win, 2 loss)
Player #8: 0-2
Round 3:
Winners against Winners
Player #1 against Player #6, Player#1 wins
Player #2 against Player #5, Player#2 wins
Losers against Losers
Player #3 against Player #8, Player#3 wins
Player #4 against Player #7, Player#4 wins
Score sheet after three rounds:
Player #1: 3-0 (3 wins, no loss)
Player #2: 3-0
Player #3: 2-1 (2 wins, 1 loss)
Player #4: 2-1
Player #5: 1-2 (1 win, 2 losses)
Player #6: 1-2
Player #7: 0-3 (no win, 3 losses)
Player #8: 0-3
Round 4:
Winners versus Winners
Player #1 vs. Player #2, Player#1 wins
Player #3 vs. Player #4, Player#3 wins
Losers versus Losers
Player #5 vs. Player #6, Player#5 wins
Player #7 vs. Player #8, Player#7 wins
If the number of rounds established is 4, then Round 4 is the Last Round. A final scoresheet and final crosstable is prepared to declare the clear winner. If there is a tie, and there is no split in the prize fund, then the tie will be broken through Swiss system tie-breaking methods in chess.
On the final round, the final scores are:
Player #1: 4-0 (4 wins, no loss) --> Winner (Champion)
Player #2: 3-1
Player #3: 3-1 (3 wins, 1 loss)
Player #4: 2-2
Player #5: 2-2 (2 wins, 2 losses)
Player #6: 1-3
Player #7: 1-3 (1 win, 3 losses)
Player #8: 0-4
In this example of a 4-round Swiss Chess Tournament,
the winner or champion is Player #1.
---- Example of Chessmaster software Swiss Tourney ----
Example of a 4-round Swiss Chess Tournament Results (Chessmaster 9000):
Name Wins Draws Losses Games Score OPS Bye
Aidan 4 0 0 4 4.0 1454
Niko 3 0 1 4 3.0 927
Ben 2 0 2 4 2.0 1747
Petra 2 0 2 4 2.0 1284
Tex 2 0 2 4 2.0 898
Manny 1 0 3 4 1.0 879
Chessmaster 1 0 3 4 1.0 630
Alekhine 1 0 3 4 1.0 490
Tournament Crosstable results
Name 1 2 3 4 Total
1.Aidan W3:1 B8:1 B7:1 W4:1 4.0/4
2.Niko W6:1 B3:0 W5:1 W8:1 3.0/4
3.Ben B1:0 W2:1 B8:0 W7:1 2.0/4
4.Petra W8:1 B5:0 W6:1 B1:0 2.0/4
5.Tex B7:0 W4:1 B2:0 W6:1 2.0/4
6.Manny B2:0 W7:1 B4:0 B5:0 1.0/4
7.Chessmaster W5:1 B6:0 W1:0 B3:0 1.0/4
8.Alekhine B4:0 W1:0 W3:1 B2:0 1.0/4
Games
=== Round 1 ===
Chessmaster vs Tex -- Black is Checkmated - Game 1
Petra vs Alekhine -- Black is Checkmated - Game 2
Aidan vs Ben -- Black is Checkmated - Game 3
Niko vs Manny -- Black is Checkmated - Game 4
=== Round 2 ===
Alekhine vs Aidan -- White is Checkmated - Game 5
Manny vs Chessmaster -- Black is Checkmated - Game 6
Tex vs Petra -- Black is Checkmated - Game 7
Ben vs Niko -- Black is Checkmated - Game 8
=== Round 3 ===
Chessmaster vs Aidan -- White is Checkmated - Game 9
Petra vs Manny -- Black is Checkmated - Game 10
Niko vs Tex -- Black is Checkmated - Game 11
Alekhine vs Ben -- Black is Checkmated - Game 12
=== Round 4 ===
Ben vs Chessmaster -- Black is Checkmated - Game 13
Tex vs Manny -- Black is Checkmated - Game 14
Niko vs Alekhine -- Black is Checkmated - Game 15
Aidan vs Petra -- Black is Checkmated - Game 16
Sunday, December 16, 2012
How to program a chess engine in C++ language compatible with Xboard/Winboard: Chess Board Representation
Chess Board Representation is a very basic necessity in chess engine programming because it is the way to show the movements of the pieces and to visualize the current position of each player in the game. Some people prefer the use of arrays in C++ but this method below uses no arrays. It is just plain and simple way of representing the chess board. The lowercase letters r, n, b, k, q, and o represent Black's pieces and the uppercase letters R, N, B, K, Q, and P represent White's pieces. The numbers 1, 2, 3, 4, 5, 6, 7, 8 on the left represent the ranks while the letters a, b, c, d, e, f, g, h on the bottom represent the files.
Any suggestions and better ideas about how to represent the chess board for the chess engine program would be much more appreciated for the benefit of those who want to learn how to program their own chess engines. Also, a little sharing of your code would be a big bonus from you (I know you have better ideas, ways and methods in C++ programming to accomplish the same task). Thanks in advance :)
Source code:
/*
PROGRAM 7: Chess - board representation
AUTHOR: eternaltreasures
DATE: 2010 September 22
*/
#include <iostream>
#include <string>
using namespace std;
#define newline '\n'
//border represents the horizontal border lines between the ranks or rows of the chessboard
#define border " +---+---+---+---+---+---+---+---+"
//sp represents the vertical spacer lines between the squares
#define sp " | "
/*
r1 to r8 represents the ranks or rows of the chess board, letters a to h represents the
files. The combination of these letters and numbers will be used in the coordinate
system of representing moves in chess.
*/
#define r8 "8 "
#define r7 "7 "
#define r6 "6 "
#define r5 "5 "
#define r4 "4 "
#define r3 "3 "
#define r2 "2 "
#define r1 "1 "
#define boardfiles " a b c d e f g h"
//ranks 8 and 7 are Black's initial position and ranks 1 and 2 for White.
char a8='r', b8='n', c8='b', d8='q', e8='k', f8='b', g8='n', h8='r';
char a7='o', b7='o', c7='o', d7='o', e7='o', f7='o', g7='o', h7='o';
char a6=' ', b6=' ', c6=' ', d6=' ', e6=' ', f6=' ', g6=' ', h6=' ';
char a5=' ', b5=' ', c5=' ', d5=' ', e5=' ', f5=' ', g5=' ', h5=' ';
char a4=' ', b4=' ', c4=' ', d4=' ', e4=' ', f4=' ', g4=' ', h4=' ';
char a3=' ', b3=' ', c3=' ', d3=' ', e3=' ', f3=' ', g3=' ', h3=' ';
char a2='P', b2='P', c2='P', d2='P', e2='P', f2='P', g2='P', h2='P';
char a1='R', b1='N', c1='B', d1='Q', e1='K', f1='B', g1='N', h1='R';
void introduction ()
{
cout << " Chess Engine Program 1.0";
cout << newline;
cout << " by eternaltreasures";
cout << newline;
cout << " September 2010";
cout << newline;
cout << newline;
}
//function called by main () to display the chess board.
void displayboard ()
{
cout << border;
cout << newline;
cout <<r8<<sp <<a8<<sp <<b8<<sp <<c8<<sp <<d8<<sp <<e8<<sp <<f8<<sp <<g8<<sp <<h8<<sp;
cout << newline;
cout <<border;
cout << newline;
cout <<r7<<sp <<a7<<sp <<b7<<sp <<c7<<sp <<d7<<sp <<e7<<sp <<f7<<sp <<g7<<sp <<h7<<sp;
cout << newline;
cout <<border;
cout << newline;
cout <<r6<<sp <<a6<<sp <<b6<<sp <<c6<<sp <<d6<<sp <<e6<<sp <<f6<<sp <<g6<<sp <<h6<<sp;
cout << newline;
cout <<border;
cout << newline;
cout <<r5<<sp <<a5<<sp <<b5<<sp <<c5<<sp <<d5<<sp <<e5<<sp <<f5<<sp <<g5<<sp <<h5<<sp;
cout << newline;
cout <<border;
cout << newline;
cout <<r4<<sp <<a4<<sp <<b4<<sp <<c4<<sp <<d4<<sp <<e4<<sp <<f4<<sp <<g4<<sp <<h4<<sp;
cout << newline;
cout <<border;
cout << newline;
cout <<r3<<sp <<a3<<sp <<b3<<sp <<c3<<sp <<d3<<sp <<e3<<sp <<f3<<sp <<g3<<sp <<h3<<sp;
cout << newline;
cout <<border;
cout << newline;
cout <<r2<<sp <<a2<<sp <<b2<<sp <<c2<<sp <<d2<<sp <<e2<<sp <<f2<<sp <<g2<<sp <<h2<<sp;
cout << newline;
cout <<border;
cout << newline;
cout <<r1<<sp <<a1<<sp <<b1<<sp <<c1<<sp <<d1<<sp <<e1<<sp <<f1<<sp <<g1<<sp <<h1<<sp;
cout << newline;
cout << border;
cout << newline;
cout << newline;
cout << boardfiles;
cout << newline;
cout << newline;
}
int main ()
{
introduction ();
displayboard ();
//Move entry - it asks the player to enter the move in coordinate system of chess move notations.
string entermove = "e2e4";
cout << newline;
cout << "Enter your move:";
cin >> entermove;
cout << entermove;
}
Saturday, December 15, 2012
How to setup the TCP/IP in Chessmaster 9000 CM LIVE:
This procedure for the TCP/IP setup in Chessmaster Live or CM LIVE in Chessmaster was tested using Chessmaster 9000 in Windows XP with 2 computers in a home network connected by a common router. The procedure for the setup of TCP/IP should be similar in older versions of Chessmaster as well as newer versions such as the Chessmaster 10th edition and the Chessmaster XI or the Grandmaster edition.
How to setup the TCP/IP in Chessmaster 9000 CM LIVE:
Hosting computer:
-----------------------
1. Start Chessmaster 9000
2. CM LIVE
3. TCP/IP
4. In the Create Session Box -> Game Name -- chessmaster
5. Click Host
Joining computer:
----------------------
1. Start Chessmaster 9000
2. CM LIVE
3. TCP/IP
4. In the Create Session Box -> Game Name -- chessmaster
5. In the Join Session Box -> Host IP Address or DNS Name -> 192.168.2.10 (Start -> Run -> cmd -> ipconfig (to obtain ip address)
6. Click Join
Note: chessmaster is a sample of Game Name and 192.168.2.10 is a sample ip address.
Challenge or Starting a chess game:
--------------------------------------------------
1. Windows -> Online Information
2. Right click the Name of the player and click Challenge
3. Send Challenge
4. Other player will Accept the Challenge
5. Play the game
CHESS Puzzles, Problems with solutions - mate in 3 by Two Bishops & King
CHESS Puzzles, Problems with solutions - mate in 3 by Bishop & Knight
CHESS Puzzles, Problems with solutions - mate in 3
CHESS PUZZLE:
![]() |
| White to move and mate in 3 moves. |
In this Chess puzzle, White to move and mates Black in 3 moves. The three pawns in the 7th rank are ready to be promoted. Note that this position is symmetrical. No matter which pawn Black captures, the solution to this chess problem of promoting pieces are the same, i.e. Bishop and then Rook.
SOLUTION:
![]() |
| 1. Bd8=B. |
![]() |
| 1. Kxc6. |
![]() |
| 4. Rb8=R. |
![]() |
| 5. Kd6. |
![]() |
| 6. Rb6 checkmate. |
Top 3 best places to play Free Live Chess online on the internet
There are so many sites to play live chess online on the web but some has too few members and it's hard to find someone to play with (opponent). Some sites has cool features and good interfaces but there are too much annoying ads and longer time to load meaning longer waiting times. Some websites has so small boards that you can't make it larger. Some has problems that I don't want to mention. Some sites are purely PAID (you have to purchase membership). I have tried and played on most of these sites but based on my own experience, these chess sites below are the:
Top 3 best places to play Free Live Chess online on the internet:
1. CHESS.COM ON FACEBOOK http://apps.facebook.com/chessfb/
Chess.com http://www.chess.com/ is the best place to play Chess online on the internet. You can play live chess, correspondence (email) chess, tournaments, chess videos to learn from, chess tactics trainer, chess openings, chess mentor (virtual chess coach). You can also join chess groups, solve the Daily Chess Puzzle, see the Game of the Day, Opening of the Day and much more.
You can either play on the Facebook site or the Chess.com site (bigger board). Lots of available players from all over the world, friendly seek graph, cool interface, play against the computer, play with your friends, chat, chess analysis, select from many chess rooms, put on your flag/country, picture or avatar, has a chess forum and so much more resources. Note that some features are available only for paid members. Also note that being a free member is good enough to enjoy playing chess!
2. Free Internet Chess Server (FICS) http://www.freechess.org/ using BABASCHESS Client http://www.babaschess.net/
Free Internet Chess Server (freechess.org) is a free chess server with over 300,000 registered users. It is one of the oldest and one of the largest internet chess servers in the world. Availability to play various chess variants. Excellent for any level of the player. You can play also against the computer or any player in the world that is available.
BabasChess is a Free Internet Chess Client (Chess GUI - Graphical User Interface) used for playing on the FICS server. BabasChess can run on Windows and Linux operating systems. It has a nice, attractive, fast and customizable playing environment, with chat, emoticons, sound effects and other cool features. It also has a powerful PGN viewer/editor, chess engines support for analyzing positions, solving mates, chess puzzles and other grandmaster or classic games. BabasChess is totally free and supports many different major languages in the world.
3. YAHOO CHESS http://ca.games.yahoo.com/games/login?game=Chess
You need a Yahoo ID and password in order to play. Once logged in, you can select from four rooms namely: Social, Beginner, Intermediate, and Advanced. When you select a room, wait for the Java applet to load. If you click the Play Now button, and an opponent is available, you can then press Start Game to start playing chess. You can also click the Create Table to make ready a table, set time, sound, show last move options. Once a table is created, you can Invite a player or Boot a player. The Sit button will allow you to join the game with the corresponding color (Black or White).
The Yahoo Chess Games site and server has many players from all over the world with different levels of strength. It has also a nice, easy to navigate, friendly, and cool graphical user interface.
Top 10 & Top 20 Greatest, Strongest, Best, Most Brilliant Chess Players in the World of All Time Ever in History
Note: This list is subjective.
Top 10:
1. Garry Kasparov
2. Bobby Fischer
3. Anatoly Karpov
4. Emanuel Lasker
5. Alexander Alekhine
6. Mikhail Botvinnik
7. José Raúl Capablanca
8. Vladimir Kramnik
9. Boris Spassky
10. Tigran Petrosian
Top 20:
11. Wilhelm Steinitz
12. Max Euwe
13. Vasily Smyslov
14. Mikhail Tal
15. Paul Morphy
16. Viswanathan Anand
17. Howard Staunton
18. Siegbert Tarrasch
19. Viktor Korchnoi
20. Paul Keres
Top 10 Chess Players with the Longest Reign of Championship:
Years as
Champion -- Rank ----- Name, Country of the World Champion
27 --------- 1 --- Emanuel Lasker (longest chess champion), Germany
17 --------- 2 --- Alexander Alekhine, Russia, France
16 --------- 3 --- Anatoly Karpov, Russia
15 --------- 4 --- Garry Kasparov, Russia, Azerbaijan, Soviet Union
13 --------- 5 --- Mikhail Botvinnik, Finland, Soviet Union
8 ---------- 6 --- Wilhelm Steinitz, USA & Bohemia *
7 ---------- 7 --- Vladimir Kramnik, Russia, USSR
6 ---------- 8 --- Tigran Petrosian, Georgia, USSR
6 ---------- 9 --- José Raúl Capablanca, Cuba
4 --------- 10 --- Viswanathan Anand, India
Bohemia * --> Czech Republic/Germany/Austria
Top 10 Chess Players with their Highest/Best Elo Ratings Ever Recorded:
Highest/Best
ELO Ratings --- Name of Grandmaster Chessplayer & (Country)
1. 2851 ------- Garry Kasparov (Russia, Azerbaijan, Soviet Union)
2. 2826 ------- Magnus Carlsen (Norway)
3. 2813 ------- Veselin Topalov (Bulgaria)
4. 2809 ------- Vladimir Kramnik (Russia)
5. 2803 ------- Viswanathan Anand (India)
6. 2788 ------- Alexander Morozevich (Russia)
7. 2787 ------- Vassily Ivanchuk (Ukraine)
8. 2786 ------- Levon Aronian (Armenia)
9. 2785 ------- Bobby Fischer (United States of America)
10. 2780 ------ Anatoly Karpov (Russia)
Friday, December 14, 2012
Chess Engine Programming - Checking the legal moves for White and Black on the first move
/*
PROGRAM 9: Chess Engine Programming - Checking the legal moves for White and Black on the first move
PURPOSE: On the first move of White, there are only 4 valid and legal Knight moves and also
4 valid legal Knight moves for Black, making a total of 8 acceptable Knight moves
on the first move. This program checks this validity using a hard coded method
but it can also be done by reading from a file containing a list of all the legal
moves on the first move of White or Black. It can also be tested using a procedure
by coding the rules how the Knight moves in 'L-shaped' fashion, and other methods
such as using a coordinate system and noting the "from square" (previous location)
going to the "to square" (destination location).
Also, on the first move for White, there are 16 legal and valid pawn moves and the
same is true for Black, making a total of 32 acceptable pawn moves on the first
move for White and Black. A total of 40 legal and valid moves (8 Knight moves and 32 Pawn moves)
are possible on the first move of White and Black.
This program assumes White is a Human Player and the Black Player is Computer. The user
(player) enters a move first then the program tests the validity or legality of White's
first move (in this case 20 legal moves). If White's move is acceptable, the Computer
player responds with a move. If White Human Player moves any other move beside the
20 acceptable moves, it will display an error to prompt the player "Illegal move.".
LANGUAGE: C++
AUTHOR: eternaltreasures
DATE: 2010 October 6
*/
#include <iostream>
#include <string>
using namespace std;
#define newline '\n'
string player_move;
string from_valid_move_choices = "e5";
int move_counter = 0;
int main ()
{
cout << endl;
cout << "Computer Chess Engine program 1.0" << endl << endl;
cout << "[Event: Chess Game Match]" << endl;
cout << "[Site: USA]" << endl;
cout << "[Date: 2010 October 6]" << endl;
cout << "[White: Human Player]" << endl;
cout << "[Black: Computer]" << endl << endl;
move_counter = move_counter + 1;
cout << "White Player: Please enter your move. " << move_counter << "."; cin >> player_move;
if ((player_move == "Nf3") || (player_move == "Nh3")
|| (player_move == "Nc3") || (player_move == "Na3")
|| (player_move == "a3") || (player_move == "a4")
|| (player_move == "b3") || (player_move == "b4")
|| (player_move == "c3") || (player_move == "c4")
|| (player_move == "d3") || (player_move == "d4")
|| (player_move == "e3") || (player_move == "e4")
|| (player_move == "f3") || (player_move == "f4")
|| (player_move == "g3") || (player_move == "g4")
|| (player_move == "h3") || (player_move == "h4"))
cout << "Thank you! Computer Player move is " << move_counter << "... " << from_valid_move_choices << endl;
else
cout << "Illegal move." << endl << endl;
}
PROGRAM 9: Chess Engine Programming - Checking the legal moves for White and Black on the first move
PURPOSE: On the first move of White, there are only 4 valid and legal Knight moves and also
4 valid legal Knight moves for Black, making a total of 8 acceptable Knight moves
on the first move. This program checks this validity using a hard coded method
but it can also be done by reading from a file containing a list of all the legal
moves on the first move of White or Black. It can also be tested using a procedure
by coding the rules how the Knight moves in 'L-shaped' fashion, and other methods
such as using a coordinate system and noting the "from square" (previous location)
going to the "to square" (destination location).
Also, on the first move for White, there are 16 legal and valid pawn moves and the
same is true for Black, making a total of 32 acceptable pawn moves on the first
move for White and Black. A total of 40 legal and valid moves (8 Knight moves and 32 Pawn moves)
are possible on the first move of White and Black.
This program assumes White is a Human Player and the Black Player is Computer. The user
(player) enters a move first then the program tests the validity or legality of White's
first move (in this case 20 legal moves). If White's move is acceptable, the Computer
player responds with a move. If White Human Player moves any other move beside the
20 acceptable moves, it will display an error to prompt the player "Illegal move.".
LANGUAGE: C++
AUTHOR: eternaltreasures
DATE: 2010 October 6
*/
#include <iostream>
#include <string>
using namespace std;
#define newline '\n'
string player_move;
string from_valid_move_choices = "e5";
int move_counter = 0;
int main ()
{
cout << endl;
cout << "Computer Chess Engine program 1.0" << endl << endl;
cout << "[Event: Chess Game Match]" << endl;
cout << "[Site: USA]" << endl;
cout << "[Date: 2010 October 6]" << endl;
cout << "[White: Human Player]" << endl;
cout << "[Black: Computer]" << endl << endl;
move_counter = move_counter + 1;
cout << "White Player: Please enter your move. " << move_counter << "."; cin >> player_move;
if ((player_move == "Nf3") || (player_move == "Nh3")
|| (player_move == "Nc3") || (player_move == "Na3")
|| (player_move == "a3") || (player_move == "a4")
|| (player_move == "b3") || (player_move == "b4")
|| (player_move == "c3") || (player_move == "c4")
|| (player_move == "d3") || (player_move == "d4")
|| (player_move == "e3") || (player_move == "e4")
|| (player_move == "f3") || (player_move == "f4")
|| (player_move == "g3") || (player_move == "g4")
|| (player_move == "h3") || (player_move == "h4"))
cout << "Thank you! Computer Player move is " << move_counter << "... " << from_valid_move_choices << endl;
else
cout << "Illegal move." << endl << endl;
}
How to program a chess engine in C++ language compatible with Xboard/Winboard: Selection of player color
This is a function called by the main () function to let the player select the color he/she prefers. Options include 'w' for selecting the White pieces and 'b' for selecting the Black pieces. The program checks the user input with the expected letters w or b. If the user enters any other letters or characters, it will display the valid selection choices.
Source code:
/*
PROGRAM 8: Chess Engine Programming - Selection of player color
AUTHOR: eternaltreasures
DATE: 2010 September 26
TITLE: How to program a chess engine in C++ language compatible with Xboard/Winboard:
Selection of player color
*/
#include <iostream>
#include <string>
using namespace std;
#define newline '\n'
void selectcolor ()
{
char playercolor = 'w';
cout << newline;
cout << "Please choose your color, w or b: ";
cin >> playercolor;
if (playercolor == 'w')
{
cout << "playercolor w=" << playercolor;
}
else if (playercolor == 'b')
{
cout << "playercolor b=" << playercolor;
}
else
{
cout << newline;
cout << "Please select:";
cout << newline;
cout << "w for White";
cout << newline;
cout << "b for Black";
cout << newline;
cout << newline;
cout << "Wrong player color=" << playercolor;
}
}
int main ()
{
selectcolor ();
return 0;
}
How to program a chess engine in C++ language compatible with Xboard/Winboard: New Game or Board Setup
This function lets the user enter n for a new game or s for board setup for analysis, solve for mate, etc. If the user enters any other characters other than n or s, it will display "Invalid entry" and show the correct choices. If the user selects the expected letters n or s, it will just display "New game = n" or "Board Setup = s". If the user enters the correct letters, a series of functions and statements will follow further to proceed to the other validations of the program (which will not be covered in this article). I will try to cover each function in the chess engine program categorically as possible to make it clear and focused to only one topic at a time.
Source code:
/*
PROGRAM 7a: Chess Engine Programming - New Game or Board Setup
AUTHOR: eternaltreasures
DATE: 2010 September 26
TITLE: How to program a chess engine in C++ language compatible with Xboard/Winboard:
New Game or Board Setup
*/
#include <iostream>
#include <string>
using namespace std;
#define newline '\n'
void newgame ()
{
char gamesetup = 'n';
cout << newline;
cout << "Enter n for New Game, s for Board Setup: ";
cin >> gamesetup;
if (gamesetup == 'n')
{
cout << "New Game = " << gamesetup;
}
else if (gamesetup == 's')
{
cout << "Board Setup = " << gamesetup;
}
else
{
cout << newline;
cout << "Invalid entry:";
cout << newline;
cout << newline;
cout << "Please Enter:";
cout << newline;
cout << "n for New Game";
cout << newline;
cout << "s for Board Setup";
cout << newline;
cout << newline;
cout << "Invalid entry = " << gamesetup;
cout << newline;
newgame ();
}
}
int main ()
{
newgame ();
return 0;
}
How to program a chess engine in C++ language compatible with Xboard/Winboard: Event, Site, Date, Game, Player info (pgn)
This function is called by the main () function to get the user input of his/her name and country of origin. An output pgn file is generated according to the standard chess pgn game file format. The date is obtained from the system date and the chess game result is yet unknown and so therefore '-' is placed.
Source code:
/*
PROGRAM 8: Chess Engine Programming - Event, Site, Date, Game, and Player information
AUTHOR: eternaltreasures
DATE: 2010 September 26
TITLE: How to program a chess engine in C++ language compatible with Xboard/Winboard:
Event, Site, Date, Game, and Player information for output pgn file
*/
#include <iostream>
#include <time.h>
#include <fstream>
using namespace std;
#define newline '\n'
void eventgameinfo ()
{
string eventname = "Chess Game Match";
string eventsite = "International";
time_t systemdate;
string whiteplayer = "White Player";
string blackplayer = "Black Player";
string gameresult = " - ";
cout << newline;
//Capture system date and time
time(&systemdate);
//Open the output game.pgn file
ofstream fout;
fout.open ("game.pgn");
cout << "Please enter your name: "; cin >> whiteplayer;
cout << "Your country of origin: "; cin >> eventsite;
cout << newline;
//Information of the Event, Site, Date, Game, Player and Result (for game.pgn file format)
cout << "[Event " << "\"" << eventname << "\"]";
cout << newline;
cout << "[Site " << "\"" << eventsite << "\"]";
cout << newline;
cout << "[Date " << "\"" << ctime(&systemdate) << "\"]";
cout << newline;
cout << "[White " << "\"" << whiteplayer << "\"]";
cout << newline;
cout << "[Black " << "\"" << blackplayer << "\"]";
cout << newline;
cout << "[Result " << "\"" << gameresult << "\"]";
cout << newline;
//Write to the game.pgn file
fout << "[Event " << "\"" << eventname << "\"]";
fout << newline;
fout << "[Site " << "\"" << eventsite << "\"]";
fout << newline;
fout << "[Date " << "\"" << ctime(&systemdate) << "\"]";
fout << newline;
fout << "[White " << "\"" << whiteplayer << "\"]";
fout << newline;
fout << "[Black " << "\"" << blackplayer << "\"]";
fout << newline;
fout << "[Result " << "\"" << gameresult << "\"]";
fout << newline;
}
int main ()
{
eventgameinfo ();
return 0;
}
Chess Engine Programming - the 3 most important elements of a chess engine which enable it to think and decide the best
Legal Move Generator
This chess engine component checks whether the moves are valid or legal. There are certain movement rules for each piece of the board as well as special moves. There are 5 important pawn moves: Promotion, En passant (e.p.), Capture, Two-square move, and one-square move. Knights move in L-shaped squares and can move backwards. Bishops move along diagonals of the same color and can also move backwards. Rooks move any number of squares straight vertically or straight horizontally. Castling is a special rook movement in which it jumps over the King. The Queen moves like a Bishop and a Rook. It moves along diagonals, files, and ranks any number of squares forward or backward. The King can move any direction as long as it is one square only. The only exception to this rule is when it is castling wherein it moves two squares. The Legal Move Generator also checks Draws by three-fold repetition, Draw by 50-move rule, Draw by insufficient material to checkmate, White King checks, Black King checks, Checkmate and more.
Score Evaluation Function
This is the "brain" of the chess engine. It "thinks" and forms the basis for decision of the chess engine. It assigns values for any situation within the board. For every movement of the pieces there is a corresponding score computed. For example a move leading to a checkmate would have a high score, an exchange leading to a material advantage, a pawn promotion, a move making the opponent's pieces in a cramped position, centered pawns, centered Knights, centered Bishops, isolated pawns, rook-pawns, doubled pawns, discovered checks, rook battery, absolute pin, forks, regular pin, etc.
Search Algorithm
Chess engine programmers often use the Minimax algorithm to search the best move possible in a given particular board position and situation. It takes and tests moves from the Legal Move Generator and checks to find the minimum score for the opponent while maximum score for the engine. Minimax can also be understood as an algorithm to search for the best possible move in a given situation. The more move turns (plies) it searches, the deeper and better will be the move that will be generated. Time is also a function to bring out the best move. Transposition tables also provide a superior search return. Searches from a book of similar played games with known variations leading to a win is also a good supplement.
Thursday, December 13, 2012
Chess engine programming: Analysis of legal moves, plies, and total move combinations of chess pieces
Chess is one of the oldest classic games played on a board. The chess board is an 8 x 8 grid consisting a total of 64 equal squares. Chess is a game of perfect information because each player knows and sees all the moves and all the pieces in the board at all times. On the starting position of the game, White has 8 pawns, 2 rooks, 2 knights, 2 bishops, 1 queen, and 1 king for a total of 16 White pieces. Black on the other hand has exactly the same kinds and quantities of pieces but of the opposite color for a total of 16 Black pieces. With all the White and Black pieces combined, the total number of pieces at the start of the game of chess is 32.
On White's first move, there are a total of 20 legal or valid moves. On Black's first move, there are also a total of 20 legal or valid moves. There are a total of 400 possible move combinations (20 x 20) on each player's first moves. In chess engine programming terminologies, a player's turn is called a ply. Thus, 2 plies mean that White has made a move on his turn and Black has replied a move on Black's turn. Another way to understand a ply is to think that a pair of one White and one Black move equals 2 plies.
White's 20 legal moves on the first move:
Pawn moves
1. a3
2. a4
3. b3
4. b4
5. c3
6. c4
7. d3
8. d4
9. e3
10. e4
11. f3
12. f4
13. g3
14. g4
15. h3
16. h4
Knight moves
17. Nf3
18. Nh3
19. Nc3
20. Na3
Black's 20 legal moves on the first move:
Pawn moves
1. a6
2. a5
3. b6
4. b5
5. c6
6. c5
7. d6
8. d5
9. e6
10. e5
11. f6
12. f5
13. g6
14. g5
15. h6
16. h5
Knight moves
17. Nf6
18. Nh6
19. Nc6
20. Na6
Monday, December 10, 2012
How to Play Blindfold Chess: Basic Tips Tricks, Tactics, Techniques, Memory Trainer, Learning Methods to Visualize Board
![]() |
| Bb4 - Black's King Bishop checks the White King |
![]() |
| Bb5 - White's King Bishop checks the Black King |
![]() |
| Dividing the Board into 4 equal parts |
![]() |
| Left diagonals |
![]() |
| Nd5 - Centered Knight controls 8 critical squares on the Queen and King side |
![]() |
| Ne4 - Centered Knight controls 8 critical squares on the King and Queen side |
![]() |
| Nf5 - Control of the Kingside castling enemy territory |
![]() |
| Qa4 - White's Queen checks Black's King on White territory (within 4th rank) |
![]() |
| Qd5 - White's Queen forks Black's Rook and Knight |
![]() |
| Qe4 - White's Queen delivers a forking check on the Black King and Rook |
![]() |
| Qe5 - White's Queen checks Black's King and forks Black's Rook and Knight |
![]() |
| Qh5 - White's Queen checks Black's King on enemy territory (5th rank) |
![]() |
| Queen side (a-file to d-file), King side (e-file to h-file). |
![]() |
| Ranks 1 to 4 is White's territory, Ranks 5 to 8 is Black's territory. |
![]() |
| Right diagonals. |
![]() |
| Two center diagonals - a1h8 and h1a8. |
![]() |
| Upper left diagonals. |
![]() |
| Upper right diagonals. |
Sunday, November 18, 2012
Chess Strategies in the Opening, Middle Game and Endgame
Opening strategy:
- develop or place your pieces on useful squares where they will have superior mobility and maximum control
- control the central squares allowing you to move freely and making your pieces mobile while placing your enemy on a cramped position thereby restricting his piece mobility and delaying his development
- know where and when to castle and assess the overall situation before you even castle, ask yourself "Am I gonna be vulnerable to attack after I castle?", or "Will I castle later?" or "Is it safe not to castle at all?", this needs good judgment to examine the possibilities
- remember, pawns can not retreat or go back, so don't make weak pawn moves. Look for your opponent's weakness on pawn moves in the opening and utilize it to gain advantage or pace
- it pays to study the openings and its variations, sometimes your game is similar and if you happen to have studied or played combinations leading you to a win or gain in material, the better chances for you in winning the game
- if you are playing the White pieces, exploit the initiative and make good use of the advantage of "dictating" where you want the game to lead into
Middle game strategy:
- look for weak spots, exploit and attack it
- in a crowded position, if there's a way to open a file, do it and control it
- in a open position, setting up an attack on both the opponent's kingside and queenside can be a good strategy or focusing on one side can be better
- decoy strategies involve pretending to attack on one side but the overall impact or effect is really attacking the other side
- look for the overall situation on the opponent's kingside and queenside, if you find a weakness or opening, take advantage of it
- if you find a good spot to position your pieces to allow you to make way for a later attack, make good use of it
- if you are attacking, don't take your defense for granted, defensive aggression is the key
- make sure that your attacking forces are sufficient enough to overpower the opponent's defensive pieces, you may end up losing a piece and your attack leads to a failure
- if the opponent queen is restricted in mobility, setup a trap or attack on the side where the opponent queen is helpless
- if you can simplify or make exchanges such that you can predict an advantage on the endgame, do it
- sometimes a sacrifice would lead you to weaken the opponent's defense, thus, allowing your troops to gain mobility and setup for a decisive blow
Endgame strategy:
- pawns and pawn structure is crucial in the endgame, be careful of your pawns while looking for your opponent's weak pawns or pawn structure and exploiting it
- connected pawns are generally better than isolated pawns, but isolated pawns are also vital for a win
- find and exploit a way where you can win by means of a free and unobstructed pawn ready for a promotion
- the queen is generally the choice for a pawn promotion, but in some cases depending on the situation, other pieces than the queen could be better
- be careful of making exchanges, taking into consideration of what's left for the mating piece combinations
- the king is now a strong piece, position it in an advantageous square or on a profitable side
- some king moves and king positionings lead to a draw or a loss instead of a win, so carefully calculate and predict the final outcome
- know when and when not to move a pawn, sometimes the king or a piece should be moved first before a pawn to contribute to a winning strategy
Thursday, November 8, 2012
Chess Tactics part 2 - Undermining, Overloading, Deflection, Interference
UNDERMINING:
Undermining is a chess tactic in which the guard or defender of a piece is captured leaving the piece undefended or underdefended
Also called Removing the Guard or Removal of the Defender
Pieces used: Any piece
OVERLOADING:
Overloading is a chess tactic in which a defender is given another defensive job and thus leaving vulnerabilities
Pieces used: Any piece
DEFLECTION:
Deflection is a chess tactic forcing an enemy piece to leave the square, row or file
Pieces used: Any piece
INTERFERENCE:
Interference is a chess tactic accomplished by placing a piece to block the opponent's defending piece
Pieces used: Any piece except the King
Chess Tactics part 1 - Fork, Pin, Skewer, Battery, Discovered attack
FORK:
A fork is a chess tactic that employs one piece to attack two or more enemy pieces at the same time
Pieces used: Any piece
PIN:
A pin is a chess tactic which prevents the movement of an enemy piece because it exposes the king or another more valueble piece
Pieces used: bishop, rook, queen
SKEWER:
A skewer is a chess tactic that attacks two opponent pieces in a file, rank, or diagonal
Also called thrust, reverse pin
Pieces used: queen, rook, bishop
BATTERY:
A battery is a chess tactic that involves a formation consisting of two or more pieces on the same rank, file, or diagonal
Pieces used: queen, rook, bishop
DISCOVERED ATTACK:
A discovered attack is a chess tactic where in one piece is uncovered or moves out of the way of another attacking piece resulting in discovered check, discovered checkmate or with mate threat, discovered attack or check with capture, or double check
Pieces used: any combination of pieces
Wednesday, October 24, 2012
Black's best opening defence reply moves against White's first moves
This list has been the result of a research from professional competitive chess games which proves and recommends Black's best defense against any of the twenty possible first moves of White. The basis of Black's best reply moves comes from the fact that the games played successfully resulted with most wins by Black.
White's opening first moves ------------- Black's best defense reply moves
[1] 1. a3 (Anderssen's Opening) --------- 1... g6
[2] 1. a4 (Ware Opening) ---------------- 1... d5
[3] 1. b3 (Larsen's Defence) ------------ 1... d5
[4] 1. b4 (Polish Defence) -------------- 1... Nf6
[5] 1. c3 (Saragossa Opening) ----------- 1... d5
[6] 1. c4 (English Opening) ------------- 1... c5
[7] 1. d3 (Mieses Opening) -------------- 1... e5
[8] 1. d4 (Queen's Pawn Opening) -------- 1... Nf6
[9] 1. e3 (Van't Kruijs Opening) -------- 1... d5
[10] 1. e4 (King's Pawn Opening) -------- 1... c5
[11] 1. f3 (Barnes Opening) ------------- 1... d5
[12] 1. f4 (Bird's Opening) ------------- 1... d5
[13] 1. g3 (Benko's Opening) ------------ 1... d5
[14] 1. g4 (Grob Opening) --------------- 1... e5
[15] 1. h3 (Clemenz Opening) ------------ 1... d5
[16] 1. h4 (Desprez Opening) ------------ 1... d5
[17] 1. Na3 (Durkin Opening) ------------ 1... d5
[18] 1. Nc3 (Dunst Opening) ------------- 1... d5
[19] 1. Nf3 (Reti Opening) -------------- 1... g6
[20] 1. Nh3 (Amar Opening) -------------- 1... d5
Subscribe to:
Posts (Atom)

























.png)



.png)
,+King+side+(e-file+to+h-file).png)




