Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Perft 5

Author: Magoo

Date: 02:01:21 05/07/03

Go up one level in this thread


On May 06, 2003 at 20:56:57, Zach Wegner wrote:

>On May 06, 2003 at 19:24:23, Magoo wrote:
>
>> 66.51     42.12    42.12  5087588     0.00     0.00  move_generator
>>  3.21     58.71     2.03  5087587     0.00     0.00  do_move
>
>As I said before, I think you are regenerating moves after each make/undo move.
>I could probably help you more if you post the code for perft

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 && // NO legal moves
      !draw_or_checkmate(pos)) {
    best=0; //DRAW
    nodes--;
  }
  return best;
}



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.