Exemplo n.º 1
0
void bot_mtdf::do_move_search(const board* b, board* res)
{
  stats.start_timer();
  last_search_exact = exact;
 
  board children[32];
  int child_count = b->get_children(children) - children;
  
  output() << "bot_" << get_name() << " searching ";
  if(exact){
    output() << "perfectly at depth " << b->count_empty_fields() << '\n';
  }
  else{ 
    output() << "at depth " << get_search_depth() << '\n';
  }
  
  moves_left = exact ? get_perfect_depth() : get_search_depth();
  
  do_sorting(children,child_count);
  
  
  int best_heur = exact ? MIN_PERFECT_HEURISTIC : MIN_HEURISTIC;
  int first_guess;
  {
    int tmp = moves_left - 6;
    if(tmp < 0){
      first_guess = heuristic();
    }
    else{
      std::swap(tmp,moves_left);
      first_guess = mtdf<false,false>(0,best_heur);
      std::swap(tmp,moves_left);
    }
  }
  
  
  
  
  for(int id=0;id<child_count;++id){
    inspected = children[id];
    moves_left--;
    int cur_heur = mtdf<true,exact>(id==0 ? first_guess  : best_heur,best_heur);
    moves_left++;
    if(cur_heur > best_heur){
      best_heur = cur_heur;
      *res = children[id];
    }
    output() << "move " << (id+1) << "/" << (child_count);
    output() << " (" << board::index_to_position(b->get_move_index(children+id)) << ')';
    
    output() << ": " << best_heur << '\n';    
  }
  
  stats.stop_timer();
  
  output() << big_number(stats.get_nodes()) << " nodes in ";
  output() << stats.get_seconds() << " seconds: ";
  output() << big_number(stats.get_nodes_per_second()) << " nodes / sec\n";
  
}
Exemplo n.º 2
0
big_number block_work(uint32_t bits)
{
    big_number target;
    target.set_compact(bits);
    if (target <= 0)
        return 0;
    return (big_number(1) << 256) / (target + 1);
}