Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Perft 5

Author: Zach Wegner

Date: 18:47:50 05/07/03

Go up one level in this thread


On May 07, 2003 at 05:01:21, Magoo wrote:

>int perft_doit(position pos, int depth){
>  int best=-100, value=0;
>  move_list moves;
>  move mov;
>  nodes++;
>
>  moves = move_generator(pos);
>
>  if (!all_moves_legal(moves)) {
>    nodes--;
>    free_move_list(moves);
>    return INFINITY; //position is illegal
>  }
>  if (depth <= 0) {
>    free_move_list(moves);
>    return 0;
>  }
>
>  mov = pop(moves);
>  while (mov!=NULL_MOVE){
>    do_move(pos, mov);
>    value=-perft_doit(pos, depth-1);
>    undo_move(pos, mov);
>    if (value > best) best=value;
>    mov = pop(moves);
>  }
>  free_move_list(moves);
>  if (best==-INFINITY &#38;&#38; // NO legal moves
>      !draw_or_checkmate(pos)) {
>    best=0; //DRAW
>    nodes--;
>  }
>  return best;
>}

Along with not generating moves at the leaves/using the in_check that I see
youve already implemented, you should try to pass the position as a pointer
instead of a local variable. Depending on the size of your board (my prototype
engine has a board size of 51184 bytes, and I have yet to implement many
features), this could take a _very_ long time and a lot of ram. It is also
faster to access with a pointer than a variable.



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.