LT chess. A free clearly written, and fully commented chess program written in Pascal
ELOIf you are interested in programming a computer to play chess, you have probably searched the net for example code and discovered that the large majority of examples are written in C, C++, Java, C# etc, etc. Well C and its derivatives are designed to write operating systems, Pascal was designed as a teaching language that could express algorithms in a clear concise way.
You can download and study the source code and learn how a chess program typically works. I have avoided a lot of the tricks that make a better program, they make the source code more complex and harder to understand. You can add those yourself when you get a better understanding of how things work. At the moment it has a simple text style interface that I used while I was writting the code. An obvious addition would be to add one of the chess GUI's that are available on the net. To compile it use either freepascal or virtualpascal.
This software was written for my own education and satisfaction, so you are free to download it and use it in anyway you like. It plays at about 1800 Elo (I think) so it will probably beat about 95% of players.
I'm still testing the code against my table top chess computer collection, tuning things and fixing bugs, so check in every so often and see whats changed.
A great place to learn about Alpha/Beta pruning is http://www.cs.ucla.edu/~rosen/161/notes/alphabeta.html
TSCP RULES NO MORE !!!
21/11/2013: Now added Null Move to the search.
23/11/2013: Fixed a dumb thing in the Swap Off function.
28/11/2013: Added 3 fold repetition code.
30/11/2013: Added passed pawn reward in the evaluation function.
1/12/2013: Added checkmate code.
18/12/2013: Bit of a code tidy up.
21/12/2013: Tinkered with move time control.
27/12/2013: Added a seperate capture move generator to streamline the quiescent search.
5/1/2014: Fully implemented Castling OK function.
7/1/2014: Added "Forced Mate" anouncement.
19/1/2014: Tinkered with time control again.
1/2/2014: After a bit of testing it seems a version WITHOUT nullmove pruning performs better than with it.
10/2/2014: Added History Heuristic for move ordering. With an improvement in play.
15/3/2014: Added Late Move Reduction.....Coooool. Searches and extra 2 ply.
11/4/2014: Fixed a few bugs.
4/5/2014: Fixed some bugs and added Futility Pruning.
5/6/2014: Fixed bug in opening library.
10/8/2014: Added 64 bit compile of source. Now using Free Pascal for Linux
5/4/2015: Added Null move back in.
30/9/2015: Code tidy up.
09/2/2016: removed history heuristic.......seemed to play worse with it ???
3/3/2016: Added killer moves.
9/5/2016: Fixups and tinkering
17/5/2016: After some study and testing I have.....removed killer moves and put back in History Heuristic.
Removed LMR.
13/6/2016: Bug fixes
22/6/2016: Still more tinkering...added transportation table and put back LMR
24/7/2016: Updated movegen after some profiling.
05/8/2016: more testing/debugging/rewriting/checking/profiling etc
Hoping now NullMove/Transposition Table/LMR/Killer Moves now work correctly
28/9/2016: Bug fixes.
ANNOUNCING LTCHESS2
3/12/2016. I have rewritten ltchess and made lots of improvements. It now uses X088 and piecelists.
It is more bug free and NPS is about 5 or 6 times faster than the first version. I think it is a lot clearer than the first version. So download ltchess2. ELO is now somewhere around 2000.
BEGIN
InitGame;
DisplayTheBoard;
REPEAT
{-- get a move from either the user or the computer }
IF HumansMove THEN
Cmd := GetCmd
ELSE
Cmd := CalcMove; {-- checks in library for a move, else searches }
CASE Cmd OF {-- process the command }
NewGameCmd : InitGame; {-- start a new game }
MoveCmd : DoMoveCmd; {-- process the move }
PlayCmd : PlayMove; {-- force computer move }
BackCmd : TakeBackMove; {-- take back last move }
ReadCmd : ReadBoard; {-- read a saved board from disk }
WriteCmd : WriteBoard; {-- save a board position to disk }
SetupCmd : SetUpBoard; {-- set a position on the board }
EvalCmd : WriteEval; {-- write some evaluation info to screen }
DebugCmd : Debug; {-- run a debug routine }
END; {-- case}
DisplayTheBoard;
UNTIL Cmd = Quitcmd;
END.
Contact me at: laurietunnicliffe@gmail.com
You can download and study the source code and learn how a chess program typically works. I have avoided a lot of the tricks that make a better program, they make the source code more complex and harder to understand. You can add those yourself when you get a better understanding of how things work. At the moment it has a simple text style interface that I used while I was writting the code. An obvious addition would be to add one of the chess GUI's that are available on the net. To compile it use either freepascal or virtualpascal.
This software was written for my own education and satisfaction, so you are free to download it and use it in anyway you like. It plays at about 1800 Elo (I think) so it will probably beat about 95% of players.
I'm still testing the code against my table top chess computer collection, tuning things and fixing bugs, so check in every so often and see whats changed.
A great place to learn about Alpha/Beta pruning is http://www.cs.ucla.edu/~rosen/161/notes/alphabeta.html
TSCP RULES NO MORE !!!
21/11/2013: Now added Null Move to the search.
23/11/2013: Fixed a dumb thing in the Swap Off function.
28/11/2013: Added 3 fold repetition code.
30/11/2013: Added passed pawn reward in the evaluation function.
1/12/2013: Added checkmate code.
18/12/2013: Bit of a code tidy up.
21/12/2013: Tinkered with move time control.
27/12/2013: Added a seperate capture move generator to streamline the quiescent search.
5/1/2014: Fully implemented Castling OK function.
7/1/2014: Added "Forced Mate" anouncement.
19/1/2014: Tinkered with time control again.
1/2/2014: After a bit of testing it seems a version WITHOUT nullmove pruning performs better than with it.
10/2/2014: Added History Heuristic for move ordering. With an improvement in play.
15/3/2014: Added Late Move Reduction.....Coooool. Searches and extra 2 ply.
11/4/2014: Fixed a few bugs.
4/5/2014: Fixed some bugs and added Futility Pruning.
5/6/2014: Fixed bug in opening library.
10/8/2014: Added 64 bit compile of source. Now using Free Pascal for Linux
5/4/2015: Added Null move back in.
30/9/2015: Code tidy up.
09/2/2016: removed history heuristic.......seemed to play worse with it ???
3/3/2016: Added killer moves.
9/5/2016: Fixups and tinkering
17/5/2016: After some study and testing I have.....removed killer moves and put back in History Heuristic.
Removed LMR.
13/6/2016: Bug fixes
22/6/2016: Still more tinkering...added transportation table and put back LMR
24/7/2016: Updated movegen after some profiling.
05/8/2016: more testing/debugging/rewriting/checking/profiling etc
Hoping now NullMove/Transposition Table/LMR/Killer Moves now work correctly
28/9/2016: Bug fixes.
ANNOUNCING LTCHESS2
3/12/2016. I have rewritten ltchess and made lots of improvements. It now uses X088 and piecelists.
It is more bug free and NPS is about 5 or 6 times faster than the first version. I think it is a lot clearer than the first version. So download ltchess2. ELO is now somewhere around 2000.
BEGIN
InitGame;
DisplayTheBoard;
REPEAT
{-- get a move from either the user or the computer }
IF HumansMove THEN
Cmd := GetCmd
ELSE
Cmd := CalcMove; {-- checks in library for a move, else searches }
CASE Cmd OF {-- process the command }
NewGameCmd : InitGame; {-- start a new game }
MoveCmd : DoMoveCmd; {-- process the move }
PlayCmd : PlayMove; {-- force computer move }
BackCmd : TakeBackMove; {-- take back last move }
ReadCmd : ReadBoard; {-- read a saved board from disk }
WriteCmd : WriteBoard; {-- save a board position to disk }
SetupCmd : SetUpBoard; {-- set a position on the board }
EvalCmd : WriteEval; {-- write some evaluation info to screen }
DebugCmd : Debug; {-- run a debug routine }
END; {-- case}
DisplayTheBoard;
UNTIL Cmd = Quitcmd;
END.
Contact me at: laurietunnicliffe@gmail.com

ltchess2.zip | |
File Size: | 1716 kb |
File Type: | zip |