Guide me through building a chess program

Discussion of chess software programming and technical issues.

Moderator: Ras

Sapta

Guide me through building a chess program

Post by Sapta »

Hello everyone, I along with some of my friends am trying to build a chess program that can at least beat one of us :D Detailed information about how to proceed on this is not present on one site, so I am hoping this thread will organize everything I need.

First of all, the language to work with- java. Will that be a problem if we use bitboards?

Secondly the board representation - bitboards. Are there different types of bitboards? This term "magic bitboard" keeps coming up on different sites. If there are different bitboards, which one to go for and some links on that type will be appreciated.

Ok thirdly, a sketch of the steps-

1. Board representation.
2. Moves generation functions for the pieces(which is basically board updation?).
3. minmax tree and algos on it, alpha-beta pruning and some others it seems.
4. Evaluation of board(no idea but this is much later).
5. ...

So the steps are rather sketchy and may even be jumbled up. I would really appreciate if someone gives a detailed(exhaustive) list of steps we need to do, so we can at least start and work on them. Right now, we're thinking too much with no result and working too less. :(

Hopefully this thread will stay alive till we finish the project :?
schlucke
Posts: 58
Joined: Thu Apr 09, 2009 1:38 pm

Re: Guide me through building a chess program

Post by schlucke »

User avatar
hgm
Posts: 28387
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Guide me through building a chess program

Post by hgm »

Fguy64
Posts: 814
Joined: Sat May 09, 2009 4:51 pm
Location: Toronto

Re: Guide me through building a chess program

Post by Fguy64 »

Saptarshi, you haven't said how advanced your programming skills are. I'm no expert, but my impression is that bitboards is perhaps the best of several types of representation in terms of performance, but also the most difficult to implement.

Other than that, your outline seems fine to me.

As a non-expert, I found the following web page easier to understand than some of the others I looked at.

http://web.archive.org/web/200404032117 ... /index.htm

p.s. as for your lack of an idea on evaluation, well some kind of evaluation is necessary for your algorithm to work, I would suggest a simple adding up of the material balance will allow you to progress in other areas.
MattieShoes
Posts: 718
Joined: Fri Mar 20, 2009 8:59 pm

Re: Guide me through building a chess program

Post by MattieShoes »

http://www.tckerrigan.com/Chess/TSCP

Simple engine that has easy to understand board representation, move generation, makemove, and takeback.
Sapta

Re: Guide me through building a chess program

Post by Sapta »

Fguy64 wrote:Saptarshi, you haven't said how advanced your programming skills are.
Right, I forgot to say. We all are amateurs in programming. You can categorize us in the not-so-studious undergraduate students :roll: But hopefully we can manage bitboards, can't say until we try :? or do you suggest to use something else? After all, we just want something stable and good. If we have to start all over again, that would be a nightmare. We wanted bitboards because they are interesting and this seems for the future, so someone can work on it later if they want. But if we can't even make a working program, then that's no use :D What is the most difficult step/thing associated with bitboards?


Another question is about the GUI. We haven't done any GUI applications. We are keeping it as the last step. Is there something we have to keep in mind while programming the other stages if we want to use xboard/WinBoard/UCI(no idea what they really are)?

Thanks for the links everyone :) I'll go through them tonight. And try to calm yourselves if I keep asking silly questions :oops:
Fguy64
Posts: 814
Joined: Sat May 09, 2009 4:51 pm
Location: Toronto

Re: Guide me through building a chess program

Post by Fguy64 »

Sapta wrote:
Fguy64 wrote:Saptarshi, you haven't said how advanced your programming skills are.
Right, I forgot to say. We all are amateurs in programming. You can categorize us in the not-so-studious undergraduate students :roll: But hopefully we can manage bitboards, can't say until we try :? or do you suggest to use something else? After all, we just want something stable and good. If we have to start all over again, that would be a nightmare. We wanted bitboards because they are interesting and this seems for the future, so someone can work on it later if they want. But if we can't even make a working program, then that's no use :D What is the most difficult step/thing associated with bitboards?


Another question is about the GUI. We haven't done any GUI applications. We are keeping it as the last step. Is there something we have to keep in mind while programming the other stages if we want to use xboard/WinBoard/UCI(no idea what they really are)?

Thanks for the links everyone :) I'll go through them tonight. And try to calm yourselves if I keep asking silly questions :oops:
You should be able to read about the different board types in the getting started link that was provided above. I'll let someone else provide a recommendation.

As for GUI, well if you want to write your own GUI, then consider that your board representation directly or directly, will be used to display the pieces.

If you want to use an existing GUI, such as winboard or Xboard, then your engine should be designed according to the Winboard specification. There is also the UCI specification. Here is the specification that works with the Winboard/XBoard GUI.

http://www.tim-mann.org/xboard/engine-intf.html
zamar
Posts: 613
Joined: Sun Jan 18, 2009 7:03 am

Re: Guide me through building a chess program

Post by zamar »

Personally I'd suggest you to take look at some existing strong open source engine and try to understand how it works. I think that fx. Fruit 2.1 could serve as good starting point.
Joona Kiiski
jwes
Posts: 778
Joined: Sat Jul 01, 2006 7:11 am

Re: Guide me through building a chess program

Post by jwes »

One thing to add is a debug/test harness at each step. It can be very difficult to debug one step if a previous one is not bug free.
User avatar
hgm
Posts: 28387
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Guide me through building a chess program

Post by hgm »

Sapta wrote:Right, I forgot to say. We all are amateurs in programming. You can categorize us in the not-so-studious undergraduate students :roll: But hopefully we can manage bitboards, can't say until we try :? or do you suggest to use something else?
Well, I would certainly not advise bitboards for your first chess program. You would most likely still be debugging your move generator where the program would already have been able to beat you had you equiped it with a straightforward 12x16 mailbox board...

I also would not advice studying the source of an advanced and super-strong engine like Fruit until you master the basics of negamax and alphabeta, from looking at TSCP or micro-Max.

Beware that for the first program you write, you can be 99% certain that by the time you get it running, you will not be happy with any part of it, because the skill you have acquired in the process of building it will now enable you to see how you should have approached each part of it in a fundamentally better way. And then you will re-write everything. So why spend a lot of time on something you will discard almost immediately when it is finished? Try to keep it as simple as possible.