Monday, April 23, 2007

Chess computer

I mentioned briefly that I'm working on a chess computer. I do, and I've come this far:

I've implemented most rules, so it can tell the difference between valid and invalid moves, including recognizing mate and castling (but not promotion or en passant yet). Getting all the rules right was more tricky and time-consuming than I would have thought. Some day I'll look up how others have done and compare notes.

I have a graphical interface using numbers as pieces. Same numbers the pieces are represented by internally (1 for white pawns, 2 for knights and so on, and the corresponding negative number for black's pieces.) Pieces are moved by clicking the board (not drag'n'drop yet, but clicking on the start and the end square.)

I have created a simple Ai. It can either choose randomly between the available moves (not too interesting...) or look into the future any arbitrary number of plys (half-moves) and choose move in accordance with material gain. So it should in principle be able to find any forced material gain however many moves into the future, except that the code is in such a weak state right now that anything beyond 3 (maybe 4) plys is simply too time-consuming. I also have some problem with memory leaks and my next task is to find and correct that. But still, it's really cool seeing my creation come to life like this. One day when it begins to beat me I'll pat it on the head and say "I'm proud over you" and "you've come so far".

I intend to make this a highly configurable chess program, the user will be able to in detail decide how the chess computer is going to play. Whether it should sacrifice a lot for an attack, or play quickly, or tend to do long castling and pawn storms, what opening to play, or even make it value knights more than bishops (or queens...). That way it will be a nice and adaptable chess training tool, I think. However, don't hold your breath. It may take some time to get there.

.

2 comments:

Blue Devil Knight said...

Cool. What language?

It would be really fun to tweak various parameters and see how well it does.

XY said...

Delphi! Or I guess technically the answer is Object Pascal, with the Delphi environment.

I'm guessing it won't be that strong compared to freely available alternatives, but for most players it doesn't really matter whether the chess computer is rated 2100 or 2600 -- either way it's good enough. Its main strength will lie in other things (such as its configurability).

 
Locations of visitors to this page