2016-06-13 8 views
0

전치 테이블에 결과를 추가하는 알파 베타 검색을 구현했습니다. 그런 다음 전치 테이블에서 주요 변형을 추출합니다.Alpha-Beta 검색에서 본인 편차가 잘리지 않습니다.

이것은 얕은 깊이의 분석에는 문제가없는 것으로 보입니다. 그러나 깊이 7 plies에서 분석을 요청하면 다음과 같이 나타납니다.

7 [+1.00] 1.b1c3 a7a6 2.g1f3 a6a5 3.a6a5 

마지막으로 이동이 반복됩니다. 이 최종 이동은 가지 치기의 결과로 테이블에 배치되지만 흰색의 법적 이동조차되지 않습니다. 분명히 인쇄 된 플라이가 7 개 미만입니다.

내 알파 베타 검색 코드에서 오해가 있습니까?

int ab_max(board *b, int alpha, int beta, int ply) { 
    if (ply == 0) return evaluate(b); 
    int num_children; 
    move chosen_move = no_move; 
    move *moves = board_moves(b, &num_children); 
    assert(num_children > 0); 
    for (int i = 0; i < num_children; i++) { 
     apply(b, moves[i]); 
     int score = ab_min(b, alpha, beta, ply - 1); 
     if (score >= beta) { 
      tt_put(b, (evaluation){moves[i], score, at_least, ply}); 
      unapply(b, moves[i]); 
      free(moves); 
      return beta; // fail-hard 
     } 
     if (score > alpha) { 
      alpha = score; 
      chosen_move = moves[i]; 
     } 
     unapply(b, moves[i]); 
    } 
    tt_put(b, (evaluation){chosen_move, alpha, exact, ply}); 
    free(moves); 
    return alpha; 
} 

int ab_min(board *b, int alpha, int beta, int ply) { 
    if (ply == 0) return evaluate(b); 
    int num_children; 
    move chosen_move = no_move; 
    move *moves = board_moves(b, &num_children); 
    assert(num_children > 0); 
    for (int i = 0; i < num_children; i++) { 
     apply(b, moves[i]); 
     int score = ab_max(b, alpha, beta, ply - 1); 
     if (score <= alpha) { 
      tt_put(b, (evaluation){moves[i], score, at_most, ply}); 
      unapply(b, moves[i]); 
      free(moves); 
      return alpha; // fail-hard 
     } 
     if (score < beta) { 
      beta = score; 
      chosen_move = moves[i]; 
     } 
     unapply(b, moves[i]); 
    } 
    tt_put(b, (evaluation){chosen_move, beta, exact, ply}); 
    free(moves); 
    return beta; 
} 

이 내 평가 인쇄 기능의 흥미로운 부분 :

내 주요 변화의 어떤 이동이 지금까지 정리되지 않아야
do { 
     if (!b->black_to_move) printf("%d.", moveno++); 
     char move[6]; 
     printf("%s ", move_to_string(eval->best, move)); 
     apply(b, eval->best); 
     eval = tt_get(b); 
    } while (eval != NULL && depth-- > 0); 

, 맞죠?

답변