Author: Robert Hyatt
Date: 18:47:06 12/27/98
Go up one level in this thread
On December 27, 1998 at 10:11:54, syed wrote:
>
> The following is a portion of source code taken from TSCP. I am trying to
>go through the source code and find out how a chess program works. I have been
>having a tough time trying to understand the move ordering process. Could some
>one please explain the code under the section titled '/*update the pv*/':
>
>/* loop through the moves */
> for(i=gen_begin[ply];i<gen_end[ply];i++) {
> sort(i);
> if(!makemove(gen_dat[i].m.b))
> continue;
> f=TRUE; /* we found a legal move! */
> x=-quiesce(-beta,-alpha);
> takeback();
> if(x>alpha) {
> if(x>=beta)
> return(beta);
> alpha=x;
>
> /* update the PV */
> pv[ply][ply]=gen_dat[i].m;
> for(j=ply+1;j<pv_length[ply+1];j++)
> pv[ply][j]=pv[ply+1][j];
> pv_length[ply]=pv_length[ply+1];
what this does is put the current move at the current ply into pv[ply][ply],
then copies the stuff *after* that move from the ply below this one since the
score and stuff gets backed up from that ply. pv_length is simply a counter
that is backed up along with the PV to tell how many moves are actually in the
PV.
> }
> }
>
>I have the following questions:
>
>1.) How does this move ordering array pv[][] work?
pv isn't really a "move ordering" thing. It is an array used so that
when we back a score up to the root of the tree, we also back up the complete
set of moves that lead to that position/score, so that we can see what is going
on in the search...
>
>2.) Why do we need to store the whole sequence of moves, since we select only
>the best one? i.e pv[0][0]
so that you can see the path the program intends to follow. Useful for
debugging/testing, and to let you know what is going on.
>
>3.) Why do we store the pv_length?
because there is no other easy way to know how many moves are in the path,
unless you store a "0" at the end. You have to have some way to determine
how long this PV path really is.
>
>4.) Where could I find some more information on coding alpha-beta, PV etc.
>
most any good AI book that covers tree searching should cover alpha/beta
as well when it talks about minimax...
>thanks in advance,
>syed
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.