How to Start Your First Computer Chess Program
Under Construction: lots of work to do here
We are in the process of creating two equally strength very very
beginner programs. The programs will not have much in them but they
will play a legal match and interface with winboard. One program will
be based on simplistic data structures and written in C. The other will be based on
bitboards and written in C++.
We thank James Swafford for providing the alpha version of his program Prophet for this.
- Take atleast two programming classes and a data structures class
- Learn C or C++ before starting this.
- Learn to compile and build multifile programs.
- Learn to use a debugger. There might be times when the one in your head is overtaxed by a problem.
- Taking an algorithms class and an AI class would be a good idea.
- Read a book on computer chess programming.
- After reading the book, review some of the recommended instructional websites.
- A little theory: Would a chess program developer toss some NPS when improving the search and why?
- The Gui:
- Understand the Winboard Protocol: read the design document.
- Ask questions on the various forums.
- Create a very simple small program that barely interfaces with Winboard? It should simply recieve moves and interactively send 4 preprogrammed moves to winboard to be made on the screen.
- The Chess Program:
- Pick one of the two beginner programs as your base.
- Create a design document for the program (You will need this again and again)
- Look over the code. Which platform is it designed for? Unix, MicroSoft, MAC or is it portable?
- Review every line of it and understand how it works as a whole. Create a flow diagram or state chart.
- The flow diagram should document the different procedures/functions and the flow between them (not every detail of every function).
- Understand and know the data structures and/or classes.
- Understand and know how the different parts work together and communicate with each other.
- How does the interface to Winboard work? Know each command.
- Does the program support interrupting the search from Winboard? What are the implications to that?
- How does the legal move generator work? How is the data collected and used in making a move?
- Which winboard commands are unsupported? Does Analyze mode work? How about force and go or move now?
- Does the program support a opening book?
- Does the program have a benchmarking mechanism? Yes, how do you run it?
- Does it support loading position files or whole games?
- Are there any debugging features built into the program? A trace facility for the search?
- What is in the position evaluator (PE)? Write down what it considers and its bonuses and penalties in chess terms not programming terms.
- If you don't know much about chess position evaluation, read a good book on chess strategy or position analysis.
- What techniques are used in the search procedures? Any extensions, reductions or prunnings?
- What is missing from the program?
- Create a list of what can be improved or is missing before coding. (This is where the chess programming book and instructional web pages come in. You did do that didn't you?)
- Create a journal of your work.
- Run the benchmarks and document the speed and node counts for each of several forced ply searches.
- Run a gauntlet with several opponents at blitz time controls. Record the results in your journal.
- Also, record your thoughts on the draws and losses as to why they were so. Was your program outsearched?
- Get your feet wet on the less tricky stuff first:
- Move Ordering
- Improve the move ordering. There are many ways to achieve this. Use your own thoughts first.
- Rerun the benchmarks, document and compare the results. Did it work? No, try again.
- You made it faster!! Now, rerun and record the results in your journal.
- Search Algorithm Improvements:
- The programs only have minimax/negamax. Implement alpha/beta pruning. That should produce a 6x speed up in time to ply.
- Test to see that you implemented it properly.
- Run and record the benchmark results.
- Run the guantlet again with the same opponents (make sure your opponents don't have any kind of learning) and record the results.
- Did it perform better? Do you need weaker sparring partners?
- Simple improvements to the PE.
- Bonus for the two bishops.
- Penalty for doubled pawns.
- Bonus for rooks on the 7th rank.
- The tricky stuff:
- Advanced Move Ordering techniques (Killer Moves, History Heuristic)
- Null Move Pruning
- PV Search
- Aspiration Windows
- Pawn Hash
- Transposition Tables
- Improvements to the P.E. (That book you read on human chess strategy or pawn structure)
- Lazy Evaluation
- Improve the Quiesence search
- King Safety
- The very tricky stuff:
- Thread or multiprocess your program. If you don't know the difference, then don't try either of them.
- Maybe join the ICGA (International Computer Games Association) and read the quarterly journals
- Look over the online table of contents from past issues. Purchase the ones interesting to you (if you can't find a reprint on the web).
Copyright Charles Roberson