Two Kings on a Board


The Interface



The Board

The board is where all the fun is!
It is the battlefield where you can compete with your friends or an AI to prove your chess skills.
It is a pretty simple board of chess. The only thing is Pieces need to be dragged always!
There is no simple mechanism for touching a piece and the next square to automatically move the piece (I'm still working on it)

Status Bar

The status bar is where the current game status is displayed.
The status row shows the current status of the game (colour to play, whether there is a check, if the game is over).
The moves row shows the PGN output of the moves played in the game.

Undo Button

The Undo button is the recently added feature.
It takes back the last two moves from the game.
The initial thought was to take back one move, but it seemed like a futile effort when playing agaisnt the AI.
Be careful when you use it in your normal two player games though (I won't really recommend using this button at all).

Buttons and AI


Buttons

Reset Board

Resets the board and game to the initial position.
Effectively reloads the page.

Flip Board

Flips the orientation of the board (which colour is facing down).
Helpful to get the POV of the AI or when playing with a friend.

Simulate Random Game

Simulates a game between two AI players that play random moves.
Not really useful for the general public, but maybe helpful to carry out some simulations for theorists and mathematicians.

Show Position in Console

Shows the current board position as a FEN string, PGN values and a Position object in the console.
Useful if you want to save a game for later analysis (particularly the FEN string).

Play against Level 0 AI

Level 0 AI is basically just a stupid RNG (Random Number Generator).
It chooses a random move from the list of valid moves given the game configuration.
It should be pretty easy to win against this, if you are still losing, you should consider changing your hobby of playing chess.

Play against Level 1 AI

Level 1 AI is still a RNG but it has a special weapon,
It will always capture one of your pieces if it can.
It can also distinguish between the value of pieces and capture the more valued piece given a choice.

Play against Level 2 AI

Level 2 AI knows a bit of chess.
It uses an algorithm known as Minimax search to search a tree of moves (and scenarios) and then "decides" the best move to play.
You can adjust the depth of move search using the selection box in the paragrph above the buttons.
More depth = better moves, but it also takes longer time to arrive at the best move.

Play against Level 3 AI

Level 3 AI uses the Minimax algorithm, but it is better equipped to disregard some parts of the analysis.
It implements something called alpha-beta pruning to reduce the size of tree that it has to traverse, thus, making faster moves than AI Level 2.

Performance Index

For AI levels 2 and 3 (also implemented for level 1, but it doesn't make much sense), this part of the webpage shows the performance metrics of each move as the AI plays.
The search depth option can be set to any value from 1 to 5, and it denotes the strength of the AI player (in increasing order).
The AI performs almost all the best moves at depth level 5, where as depth level 1 plays almost like AI level 1.
Positions evaluated shows the number of board positions that were evaluated before making the move.
Time shows the move time in seconds.
Positions/sec shows the approximate number of board positions evaluated per second by the CPU.