Chess Programing: Request for Code Review.

Started by
13 comments, last by ashish123 11 years, 3 months ago
Hi Paradigm Shifter,
Thanks for reply.

I planned to keep one say like WHITE_ATTACK_MAPS and so on.
and then update(OR them) the MAPS on move generation as they are the same.
now on second thought, I dont know how to update(XOR) them on make move method and update them back on unmake move.

I consider this scenario
5zcnq6e1n4lp.png
fen=4k3/8/8/5B2/6Q1/8/8/4K3

now g6 square is attacked by Bishop as well as Queen, so even if Queen or bishop moves(one at a time),g6 still remains under threat. So my plan to make or unmake the move fails. So I thought I might keep 12 bit boards and since I know the piece moving, I can just update that single bit board and so on...

would like to know whether this would give me speed up or not.

You can refer to the source code given in above links so that you can give more suggestions.

Thanks.
Advertisement
If you have never written a chess engine before, I think you should stop obsessing about performance at this stage and go on building your engine. Perft is a lousy proxy for engine performance anyway. You don't want to use a data structure that does great at perft but makes evaluation slow.

To first order, all questions about whether some technique will give you a speed up or not can only be answered by testing on your engine.

@Alvaro: Thanks for replying.

I have written two chess engines when I first began to code about year ago.

Both were 0x88 based and I wasnt pleased with the performance I got from them (4 plys in about 4-5 mins).

The first one was horrible, it took 3 hours just to generate moves for 6 plys. later on I found that the bottle neck was the dynamic memory allocation.

The second one was quiet good but then my disk crashed and I lost the source.

This is the third one, but my first one using bit boards.

My idea beyond making a fast perft was some thing like, "If I can get around 2MNPS in perft, they would trim down to 1.5 or 1 MNPS with the evaluation and decision making.

So the faster my perft is, it will help my program be faster."

So from your post I think I am heading the wrong way and attack boards would make my evaluation slow (but I cant see how)

please reply.

Thanks.

I have written two chess engines when I first began to code about year ago.

Both were 0x88 based and I wasnt pleased with the performance I got from them (4 plys in about 4-5 mins).

So you were getting 4 plys in 4 or 5 minutes, when it should have taken a fraction of a second. Then you must have decided that the problem was the board representation, but this is not correct. You can make 0x88-based engines that are really fast.
So from your post I think I am heading the wrong way and attack boards would make my evaluation slow (but I cant see how)
You are reading too much into my post. I was just pointing out that you are going about this the wrong way, and you shouldn't try to optimize the speed of perft. You should find out why your engine was taking minutes to reach 4 plys. Dynamic memory allocation is an obvious thing to get rid of, but I guess you were doing something else completely wrong.
I have written two chess engines when I first began to code about year ago.

Both were 0x88 based and I wasnt pleased with the performance I got from them (4 plys in about 4-5 mins).

So you were getting 4 plys in 4 or 5 minutes, when it should have taken a fraction of a second. Then you must have decided that the problem was the board representation, but this is not correct. You can make 0x88-based engines that are really fast.
So from your post I think I am heading the wrong way and attack boards would make my evaluation slow (but I cant see how)
You are reading too much into my post. I was just pointing out that you are going about this the wrong way, and you shouldn't try to optimize the speed of perft. You should find out why your engine was taking minutes to reach 4 plys. Dynamic memory allocation is an obvious thing to get rid of, but I guess you were doing something else completely wrong.

Yes, its just that I have lost the code, so as it is I was trying to code something new. I have never felt or mentioned that 0x88 engines are slow or something like that.

The main reason of shifting to bitboards was the thrill. The thrill in representing entire chess board in just one unsigned long. Another reason for myt 0x88 engine was slow because I scanned for material (looped the board) everytime, rather I could just keep count and so on.. 0x88 is an excellent scheme for representation (at first I was pleasantly surprised with the idea alone of sq&0x88.)

Ok then I think I should go on writing this as complete chess engine and then come back for optimization.

PS: Its just that I am not schooled formally in computer, I developed liking for computers and studied through books like Introduction to Algorithms during spare time.

So there might me some issues with the way I think. I hope I am not asking too much.

Thanks.

This topic is closed to new replies.

Advertisement