示例#1
0
文件: evaluate.cpp 项目: xman/reversi
evaluate::score evaluate::end_eval(const board&b , int turn)
{
  score s ;
  location_list::location move ;
  location_list::iterator iter ;
  location_list move_list ;
  board buffer_b ;

  #pragma omp atomic
  evaluate::ecount++ ;

  gen_move::generate_move(b, turn, move_list) ;
  if(move_list.is_empty()) {
    gen_move::generate_move(b, (turn+1)%2, move_list) ;
    if(move_list.is_empty()) {    
      if(side == board::BLACK) 
        return b.get_black_count() >= b.get_white_count() ? 9999990 : -9999990 ;
      else 
        return b.get_white_count() >= b.get_black_count() ? 9999990 : -9999990 ;
    } else {
      turn = (turn + 1) % 2 ;
    }
  }

  if(side == turn) {
    for(iter = move_list.begin() ; iter != move_list.end() ; iter++) {
      buffer_b = b ;
      move = *iter ;
      buffer_b.move_at(move, turn)  ;
      s = end_eval(buffer_b, (turn+1)%2) ;
      if(s > 0) return s ;
    }
    return -9999990 ;
  } else {
    for(iter = move_list.begin() ; iter != move_list.end() ; iter++) {
      buffer_b = b ;
      move = *iter ;
      buffer_b.move_at(move, turn)  ;
      s = end_eval(buffer_b, (turn+1)%2) ;
      if(s < 0) return s ;
    }
    return 9999990 ;
  }
}
示例#2
0
文件: evaluate.cpp 项目: xman/reversi
evaluate::score evaluate::eval(const board& b, board::piece side, int turn)
{
  score s ;
  int turn_num ;

  assert(side == board::BLACK || side == board::WHITE) ;

  turn_num = b.get_black_count() + b.get_white_count() ;
  this->side = side ;
  if(turn_num >= 48) return end_eval(b, turn) ;
  s = recur_eval(b, turn, level, turn_num, -9999999) ;
  return s ;
}
示例#3
0
文件: evaluate.cpp 项目: xman/reversi
evaluate::score evaluate::piece_count(const board& b, int turn_num)
{
  int count, count2 ;
  score s ;

  if(side == board::BLACK) {
    count  = b.get_black_count() ;
    count2 = b.get_white_count() ;
  } else if(side == board::WHITE) {
    count  = b.get_white_count() ;
    count2 = b.get_black_count() ;
  } else {
    return -9999991 ;
  }

  if(count == 0) return -9999994 ;
  if(count2 ==0) return 9999994  ;

  if(turn_num == 64) {
    if(count > count2) {
      return 9999994 ;
    } else if(count < count2) {
      return -9999994;
    } else {
      return 0 ; 
    }
  }
  s = count - count2 ;
  if(turn_num < 40) {
    if((count+count2) / count > count + count2 - 10) {
      s *= 2 ;
    } else {
      s *= -2 ;
    }
  } else {
    s *= 3 ;
  } 
  return s ;
}