Author: Bruce Moreland
Date: 16:45:21 10/26/99
Go up one level in this thread
On October 26, 1999 at 19:05:32, Nicolas Carrasco wrote:
>Dear Guys,
>
>I am still haveing problems storeing the PV data at this simple Alpha-Beta
>Algorim.
>
>int AlphaBeta (depth, alpha, beta)
>{
> int score;
>
> if (depth == 0)
> return Evaluate(pos);
>
> succ = Successors(pos);
> i = 0;
>
> while (i<succ)
> {
> i++;
> if (make_move(move_list[i])) {
> score = -AlphaBeta (-depth, -beta, -alpha);
> unmake_move();
>
> if(score>alpha){
> if (score>beta)
> return beta;
> alpha = score;
> }
> }
> return alpha;
>}
>
>
>Many arrays programs put something like this:
>
>pv[ply][ply] = move[ply].b[i];
>
>for(j=ply+1;j<pv_length[ply+1];j++)
> pv[ply][j] = pv[ply+1][j];
>pv_length[ply] = pv_length[ply+1];
>
>Where I have to put that? How it works?
>
>Thanks
There comes a point where you have to read the code and understand it for
yourself. If you are just typing in a chess program, you aren't writing it.
Instead of "pv_length[ply] = pv_length[ply+1];" you need "pv_length[ply] =
pv_length[ply+1] + 1;". The arrary needs to be dimensioned pretty big in both
directions or you'll corrupt memory and puke.
The implementation wastes have of the elements in this array, which you may wish
to consider if you're trying to save space. It might not make sense to save
space, I don't know.
The PV at a leaf-node is nothing, so before you do "return Evaluate(pos)" you
can set the PV length to zero there.
The PV at any other node is the move that resulted in a PV score, plus the PV
for the node that was just searched. You do this computation right after "alpha
= score;".
There are some other bugs:
1) You have "if (score > beta)" and it should be "if (score >= beta)". This is
a serious bug. You have to very carefully check stuff like that.
2) You have "score = -AlphaBeta (-depth, -beta, -alpha);" and you should have
"score = -AlphaBeta (depth - 1, -beta, -alpha);"
3) That "i++" is in a funny place if you are following the normal C practice of
using zero-based arrays.
You also aren't managing the "ply" variable, and you have to get that right as
well.
I don't guarantee that I found all the bugs.
bruce
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.