48 hour chess

Discussion of chess software programming and technical issues.

Moderator: Ras

tpetzke
Posts: 686
Joined: Thu Mar 03, 2011 4:57 pm
Location: Germany

Re: 48 hour chess

Post by tpetzke »

Hi,

yes the new version plays much better than the older one. Good job.

Two things I noticed you might want to fix

1) The engine does not detect 3fold repetition
2) The move generator seems to work not fully correctly. I recommend to verify it with some perft runs.

In this position

[d]1rb2rk1/2pp3p/2p2np1/p4p2/2PB4/5N1P/P1P1BPP1/R3K2R w KQ - 0 1

the move O-O-O (white castle queenside) is missing.

Thomas...
mike_bike_kite
Posts: 98
Joined: Tue Jul 26, 2011 12:18 am
Location: London

Re: 48 hour chess

Post by mike_bike_kite »

tpetzke wrote:Two things I noticed you might want to fix

1) The engine does not detect 3fold repetition
2) The move generator seems to work not fully correctly...In this position
the move O-O-O (white castle queenside) is missing.
1) You're right regards repitition - I'm still working on this.
2) Ooops - I've corrected this. The bug was in my understanding of the rules rather than in my code. I'll release a correction shortly. Thanks for highlighting this.

Mike
tpetzke
Posts: 686
Joined: Thu Mar 03, 2011 4:57 pm
Location: Germany

Re: 48 hour chess

Post by tpetzke »

Hi,

getting the move generator right is the first real challenge for every engine programmer. There are so many pitfalls that without extensive testing it is very difficult to get it working 100% correctly. The good thing is that it's very easy to test and debug it.

If you not have done this add a perft function to your code. It looks something like this

Code: Select all

/***************************************************
 run a perft search on the current board to the given level
 this validates the move generator
****************************************************/
int64 TBoard::perft(int level)
{
	int i;
	int64 result = 0;
	TMoveList *ml;

     if (level<=0) return 0;

     ml = getAllMoves();
     if (level==1)
	 {
		result = ml->moveCnt;
		delete ml;
		return result;
	 }

     for (i=0;i<ml->moveCnt;i++)
	 {

		makeMove(ml->moves[i]);
		result += perft(level-1);
		unmakeMove(ml->moves[i]);
	 }

	 delete ml;
	 return result;
}
This function counts the possible leaf nodes from the current position with the given depth. If you use a position where the correct number of leafs is known and this function reports a different number you know you still have an error.

From the initial position you get the following values

Code: Select all

iCE 0.2 build 889 [2011.8.5]
perft 6
perft        Nodes    Time
  1             20    0 sec
  2            400    0 sec
  3          8.902    0 sec
  4        197.281    0.032 sec
  5      4.865.609    0.265 sec
  6    119.060.324    4.453 sec
Other useful positions with their perft scores are in the wiki

Thomas...
mike_bike_kite
Posts: 98
Joined: Tue Jul 26, 2011 12:18 am
Location: London

Re: 48 hour chess

Post by mike_bike_kite »

Thanks for that - that also explains what all those posts are in the forum regarding perft. I'm pretty sure that the move generator is correct though but it was my understanding of the rules that was wrong :oops: I'll include an info page in the program that details all these values for any position and provide other interesting info. At the moment the only thing I know is missing is promoting a pawn to something other than a queen.

I've just released a new version (10.3) of the program which plays a little better and fixes various small issues.
tpetzke
Posts: 686
Joined: Thu Mar 03, 2011 4:57 pm
Location: Germany

Re: 48 hour chess

Post by tpetzke »

yeah, you should not call perft with 13 as argument as a start, your little engine will probably take longer than Deep Thought took for its calculation of 42 :lol:

I think the current estimate for the perft 13 calculation running on multiple systems in parallel is several month.

Thomas...