void restore(bool allow_exception=true) {
     if (safety)
         return;        
     if (allow_exception)
         init_safety();
     else
         try {
             safety=::operator new(safety_size);
         } catch(...) {
             safety=0;
         }
 }
Exemplo n.º 2
0
void read_evaluation_uci_options(Color us) {

    // King safety is asymmetrical. Our king danger level is weighted by
    // "Cowardice" UCI parameter, instead the opponent one by "Aggressiveness".
    const int kingDangerUs   = (us == WHITE ? KingDangerUs   : KingDangerThem);
    const int kingDangerThem = (us == WHITE ? KingDangerThem : KingDangerUs);

    Weights[Mobility]       = weight_option("Mobility (Middle Game)", "Mobility (Endgame)", WeightsInternal[Mobility]);
    Weights[PassedPawns]    = weight_option("Passed Pawns (Middle Game)", "Passed Pawns (Endgame)", WeightsInternal[PassedPawns]);
    Weights[Space]          = weight_option("Space", "Space", WeightsInternal[Space]);
    Weights[kingDangerUs]   = weight_option("Cowardice", "Cowardice", WeightsInternal[KingDangerUs]);
    Weights[kingDangerThem] = weight_option("Aggressiveness", "Aggressiveness", WeightsInternal[KingDangerThem]);

    // If running in analysis mode, make sure we use symmetrical king safety. We do this
    // by replacing both Weights[kingDangerUs] and Weights[kingDangerThem] by their average.
    if (Options["UCI_AnalyseMode"].value<bool>())
        Weights[kingDangerUs] = Weights[kingDangerThem] = (Weights[kingDangerUs] + Weights[kingDangerThem]) / 2;

    init_safety();
}
 reserved_memory(std::size_t safety_size=GRAEHL__DEFAULT_SAFETY_SIZE) : safety_size(safety_size)
 {
     init_safety();
 }