Example #1
0
/*
 *******************************************************************************
 *                                                                             *
 *   Interrupt() is used to read in a move when the operator types something   *
 *   while a search is in progress (during pondering as one example.)  This    *
 *   routine reads in a command (move) and then makes two attempts to use this *
 *   input:  (1) call Option() to see if the command can be executed;  (2) try *
 *   InputMove() to see if this input is a legal move;  If so, and we are      *
 *   pondering see if it matches the move we are pondering.                    *
 *                                                                             *
 *******************************************************************************
 */
void Interrupt(int ply) {
  int temp, i, left = 0, readstat, result, time_used;
  int save_move_number;
  TREE *const tree = block[0];

/*
 ************************************************************
 *                                                          *
 *   If trying to find a move to ponder, and the operator   *
 *   types a command, exit a.s.a.p.                         *
 *                                                          *
 ************************************************************
 */
  if (puzzling)
    abort_search = 1;
/*
 ************************************************************
 *                                                          *
 *   First check to see if this is a command by calling     *
 *   Option().  Option() will return a 0 if it didn't       *
 *   recognize the command; otherwise it returns a 1 if     *
 *   the command was executed, or a 2 if we need to abort   *
 *   the search to execute the command.                     *
 *                                                          *
 ************************************************************
 */
  else
    do {
      readstat = Read(0, buffer);
      if (readstat <= 0)
        break;
      nargs = ReadParse(buffer, args, " 	;");
      if (nargs == 0) {
        Print(128, "ok.\n");
        break;
      }
      if (strcmp(args[0], ".")) {
        save_move_number = move_number;
        if (!wtm)
          move_number--;
        if (root_wtm)
          Print(128, "Black(%d): %s\n", move_number, buffer);
        else
          Print(128, "White(%d): %s\n", move_number, buffer);
        move_number = save_move_number;
      }
/*
 ************************************************************
 *                                                          *
 *   "." command displays status of current search.         *
 *                                                          *
 ************************************************************
 */
      if (!strcmp(args[0], ".")) {
        if (xboard) {
          end_time = ReadClock();
          time_used = (end_time - start_time);
          printf("stat01: %d ", time_used);
          printf(BMF " ", tree->nodes_searched);
          printf("%d ", iteration_depth);
          for (i = 0; i < n_root_moves; i++)
            if (!(root_moves[i].status & 128))
              left++;
          printf("%d %d\n", left, n_root_moves);
          fflush(stdout);
          break;
        } else {
          end_time = ReadClock();
          time_used = (end_time - start_time);
          printf("time:%s ", DisplayTime(time_used));
          printf("nodes:" BMF "\n", tree->nodes_searched);
          DisplayTreeState(block[0], 1, 0, ply);
        }
      }
/*
 ************************************************************
 *                                                          *
 *   "mn" command is used to set the move number to a       *
 *   specific value...                                      *
 *                                                          *
 ************************************************************
 */
      else if (!strcmp("mn", args[0])) {
        if (nargs == 2) {
          move_number = atoi(args[1]);
          Print(128, "move number set to %d\n", move_number);
        }
      }
/*
 ************************************************************
 *                                                          *
 *   "?" command says "move now!"                           *
 *                                                          *
 ************************************************************
 */
      else if (!strcmp(args[0], "?")) {
        if (thinking) {
          time_abort = 1;
          abort_search = 1;
        }
      }
/*
 ************************************************************
 *                                                          *
 *   Next see if Option() recognizes this as a command.     *
 *                                                          *
 ************************************************************
 */
      else {
        save_move_number = move_number;
        if (!analyze_mode && !wtm)
          move_number--;
        result = Option(tree);
        move_number = save_move_number;
        if (result >= 2) {
          if (thinking && result != 3)
            Print(128, "command not legal now.\n");
          else {
            abort_search = 1;
            input_status = 2;
            break;
          }
        } else if ((result != 1) && analyze_mode) {
          abort_search = 1;
          input_status = 2;
          break;
        }
/*
 ************************************************************
 *                                                          *
 *   Now, check to see if the operator typed a move.  If    *
 *   so, and it matched the predicted move, switch from     *
 *   pondering to thinking to start the timer.  If this     *
 *   is a move, but not the predicted move, abort the       *
 *   search, and start over with the right move.            *
 *                                                          *
 ************************************************************
 */
        else if (!result) {
          if (pondering) {
            nargs = ReadParse(buffer, args, " 	;");
            temp = InputMove(tree, args[0], 0, Flip(root_wtm), 1, 1);
            if (temp) {
              if ((From(temp) == From(ponder_move)) &&
                  (To(temp) == To(ponder_move)) &&
                  (Piece(temp) == Piece(ponder_move)) &&
                  (Captured(temp) == Captured(ponder_move)) &&
                  (Promote(temp) == Promote(ponder_move))) {
                predicted++;
                input_status = 1;
                pondering = 0;
                thinking = 1;
                opponent_end_time = ReadClock();
                program_start_time = ReadClock();
                Print(128, "predicted move made.\n");
              } else {
                input_status = 2;
                abort_search = 1;
                break;
              }
            } else if (!strcmp(args[0], "go") || !strcmp(args[0], "move") ||
                !strcmp(args[0], "SP")) {
              abort_search = 1;
              break;
            } else
              Print(4095, "Illegal move: %s\n", args[0]);
          } else
            Print(4095, "unrecognized/illegal command: %s\n", args[0]);
        }
      }
    } while (1);
  if (log_file)
    fflush(log_file);
}
Example #2
0
void ConfigurationManager::bind(const QString &optionKey, QCheckBox *obj, bool defaultValue)
{
    m_options[optionKey] = Option(defaultValue, "checked", obj);
}
Example #3
0
void init(OptionsMap& o) {

  // at most 2^32 clusters.
  const int MaxHashMB = Is64Bit ? 131072 : 2048;

  o["Debug Log File"]        << Option("", on_logger);
  o["Contempt"]              << Option(0, -100, 100);
  o["Threads"]               << Option(1, 1, 512, on_threads);
  o["Hash"]                  << Option(16, 1, MaxHashMB, on_hash_size);
  o["Clear Hash"]            << Option(on_clear_hash);
  o["Ponder"]                << Option(false);
  o["MultiPV"]               << Option(1, 1, 500);
  o["Skill Level"]           << Option(20, 0, 20);
  o["Move Overhead"]         << Option(100, 0, 5000);
  o["nodestime"]             << Option(0, 0, 10000);
  o["UCI_Chess960"]          << Option(false);
  o["SyzygyPath"]            << Option("<empty>", on_tb_path);
  o["SyzygyProbeDepth"]      << Option(1, 1, 100);
  o["Syzygy50MoveRule"]      << Option(true);
  o["SyzygyProbeLimit"]      << Option(6, 0, 6);
}
Example #4
0
/*
 *******************************************************************************
 *                                                                             *
 *   Analyze() is used to handle the "analyze" command.  This mode basically   *
 *   puts Crafty into a "permanent pondering" state, where it reads a move     *
 *   from the input stream, and then "ponders" for the opposite side.          *
 *   Whenever a move is entered, Crafty reads this move, updates the game      *
 *   board, and then starts "pondering" for the other side.                    *
 *                                                                             *
 *   The purpose of this mode is to force Crafty to follow along in a game,    *
 *   providing analysis continually for the side on move until a move is       *
 *   entered, advancing the game to the next position.                         *
 *                                                                             *
 *******************************************************************************
 */
void Analyze() {
  int i, v, move, back_number, readstat = 1;
  TREE *const tree = block[0];

/*
 ************************************************************
 *                                                          *
 *  Initialize.                                             *
 *                                                          *
 ************************************************************
 */
  int save_swindle_mode = swindle_mode;

  swindle_mode = 0;
  ponder_move = 0;
  analyze_mode = 1;
  if (!xboard)
    display_options |= 1 + 2 + 4;
  printf("Analyze Mode: type \"exit\" to terminate.\n");
/*
 ************************************************************
 *                                                          *
 *  Now loop waiting on input, searching the current        *
 *  position continually until a move comes in.             *
 *                                                          *
 ************************************************************
 */
  do {
    do {
      last_pv.pathd = 0;
      last_pv.pathl = 0;
      input_status = 0;
      pondering = 1;
      tree->status[1] = tree->status[0];
      Iterate(game_wtm, think, 0);
      pondering = 0;
      if (book_move)
        moves_out_of_book = 0;
      if (!xboard) {
        if (game_wtm)
          printf("analyze.White(%d): ", move_number);
        else
          printf("analyze.Black(%d): ", move_number);
        fflush(stdout);
      }
/*
 ************************************************************
 *                                                          *
 *  If we get back to here, something has been typed in and *
 *  is in the command buffer normally, unless the search    *
 *  terminated naturally due to finding a mate or reaching  *
 *  the max depth allowable.                                *
 *                                                          *
 ************************************************************
 */
      if (!input_status)
        do {
          readstat = Read(1, buffer);
          if (readstat < 0)
            break;
          nargs = ReadParse(buffer, args, " \t;");
          Print(32, "%s\n", buffer);
          if (strstr(args[0], "timeleft") && !xboard) {
            if (game_wtm)
              printf("analyze.White(%d): ", move_number);
            else
              printf("analyze.Black(%d): ", move_number);
            fflush(stdout);
          }
        } while (strstr(args[0], "timeleft"));
      else
        nargs = ReadParse(buffer, args, " \t;");
      if (readstat < 0)
        break;
      move = 0;
      if (!strcmp(args[0], "exit"))
        break;
/*
 ************************************************************
 *                                                          *
 *  First, check for the special analyze command "back n"   *
 *  and handle it if present, otherwise try Option() to see *
 *  if it recognizes the input as a command.                *
 *                                                          *
 ************************************************************
 */
      if (OptionMatch("back", args[0])) {
        if (nargs > 1)
          back_number = atoi(args[1]);
        else
          back_number = 1;
        for (i = 0; i < back_number; i++) {
          game_wtm = Flip(game_wtm);
          if (Flip(game_wtm))
            move_number--;
        }
        if (move_number == 0) {
          move_number = 1;
          game_wtm = 1;
        }
        sprintf(buffer, "reset %d", move_number);
        Option(tree);
        display = tree->position;
      } else if (Option(tree)) {
        display = tree->position;
      }
/*
 ************************************************************
 *                                                          *
 *  If InputMove() can recognize this as a move, make it,   *
 *  swap sides, and return to the top of the loop to call   *
 *  search from this new position.                          *
 *                                                          *
 ************************************************************
 */
      else if ((move = InputMove(tree, 0, game_wtm, 1, 0, buffer))) {
        char *outmove = OutputMove(tree, 0, game_wtm, move);

        if (history_file) {
          fseek(history_file, ((move_number - 1) * 2 + 1 - game_wtm) * 10,
              SEEK_SET);
          fprintf(history_file, "%9s\n", outmove);
        }
        if (game_wtm)
          Print(32, "White(%d): ", move_number);
        else
          Print(32, "Black(%d): ", move_number);
        Print(32, "%s\n", outmove);
        if (speech) {
          char announce[64];

          strcpy(announce, "./speak ");
          strcat(announce, outmove);
          strcat(announce, " &");
          v = system(announce);
          if (v != 0)
            perror("Analyze() system() error: ");
        }
        MakeMoveRoot(tree, game_wtm, move);
        display = tree->position;
        last_mate_score = 0;
        if (log_file)
          DisplayChessBoard(log_file, tree->position);
      }
/*
 ************************************************************
 *                                                          *
 *  If Option() didn't handle the input, then it is illegal *
 *  and should be reported to the user.                     *
 *                                                          *
 ************************************************************
 */
      else {
        pondering = 0;
        if (Option(tree) == 0)
          printf("illegal move: %s\n", buffer);
        pondering = 1;
        display = tree->position;
      }
    } while (!move);
    if (readstat < 0 || !strcmp(args[0], "exit"))
      break;
    game_wtm = Flip(game_wtm);
    if (game_wtm)
      move_number++;
  } while (1);
  analyze_mode = 0;
  printf("analyze complete.\n");
  pondering = 0;
  swindle_mode = save_swindle_mode;
}
Example #5
0
void 
init(OptionsMap& o) 
{
  o["BookFile"]                    = Option("book.bin");
  o["Contempt"]                    = Option(0, -kValueMate, kValueMate);
  o["Threads"]                     = Option(1, 1, 128, on_threads);
  o["USI_Hash"]                    = Option(32, 1, 16384, on_hash_size);
  o["Clear_Hash"]                  = Option(on_clear_hash);
  o["USI_Ponder"]                  = Option(true);
  o["OwnBook"]                     = Option(true);
  o["MultiPV"]                     = Option(1, 1, 500);
  o["ByoyomiMargin"]               = Option(0, 0, 5000);
#ifdef APERY_BOOK
  o["Best_Book_Move"] = Option(false);
  o["Min_Book_Score"] = Option(-180, -kValueInfinite, kValueInfinite);
#endif
}
Example #6
0
constexpr Option get_enum_max_value(Option) { return Option(0xffff); }
Example #7
0
void init(OptionsMap& o) {

  o["Write Debug Log"]          << Option(false, on_logger);
  o["Contempt Factor"]          << Option(0, -100,  100);
  o["Min Split Depth"]          << Option(0, 0, 12, on_threads);
  o["Threads"]                  << Option(1, 1, MAX_THREADS, on_threads);
  o["Hash"]                     << Option(16, 1, 1024 * 1024, on_hash_size);
  o["Clear Hash"]               << Option(on_clear_hash);
  o["Ponder"]                   << Option(true);
  o["MultiPV"]                  << Option(1, 1, 500);
  o["Skill Level"]              << Option(20, 0, 20);
  o["Emergency Move Horizon"]   << Option(40, 0, 50);
  o["Emergency Base Time"]      << Option(60, 0, 30000);
  o["Emergency Move Time"]      << Option(30, 0, 5000);
  o["Minimum Thinking Time"]    << Option(20, 0, 5000);
  o["Slow Mover"]               << Option(80, 10, 1000);
  o["UCI_Chess960"]             << Option(false);
  o["SyzygyPath"]               << Option("<empty>", on_tb_path);
  o["SyzygyProbeDepth"]         << Option(1, 1, 100);
  o["Syzygy50MoveRule"]         << Option(true);
  o["SyzygyProbeLimit"]         << Option(6, 0, 6);
}
Example #8
0
void ConfigurationManager::bind(const QString &optionKey, QComboBox *obj, int defaultValue)
{
    m_options[optionKey] = Option(defaultValue, "currentIndex", obj);
}
Example #9
0
/**
    \internal
*/
bool GetOpt::parse( bool untilFirstSwitchOnly )
{
    // qDebug( "parse(%s)", args.join( QString( "," ) ).toLocal8Bit().constData() );
    // push all arguments as we got them on a stack
    // more pushes might following when parsing condensed arguments
    // like --key=value.
    QStack<QString> stack;
    {
        QStringList::const_iterator it = args.isEmpty() ? args.end() : --args.end();

        while ( it != args.constEnd() )
        {
            stack.push( *it );

            if ( it == args.begin() )
            {
                it = args.constEnd();
            }
            else
            {
                --it;
            }
        }
    }

    //qWarning() << stack;

    enum { StartState, ExpectingState, OptionalState } state = StartState;
    enum TokenType { LongOpt, ShortOpt, Arg, End } t, currType = End;

    const OptionConstIterator obegin = options.begin();
    const OptionConstIterator oend = options.end();
    Option currOpt;
    bool extraLoop = true; // we'll do an extra round. fake an End argument

    while ( !stack.isEmpty() || extraLoop )
    {
        QString a;
        QString origA;

        // identify argument type
        if ( !stack.isEmpty() )
        {
            a = stack.pop();
            currArg++;
            origA = a;

            // qDebug( "popped %s", a.toLocal8Bit().constData() );
            if ( a.startsWith( QLatin1String( "--" ) ) )
            {
                // recognized long option
                a = a.mid( 2 );

                if ( a.isEmpty() )
                {
                    qWarning( "'--' feature not supported, yet" );
                    //exit( 2 );
                    return false;
                }

                t = LongOpt;
                int equal = a.indexOf( '=' ); // split key=value style arguments

                if ( equal >= 0 )
                {
                    stack.push( a.mid( equal +1 ) );
                    currArg--;
                    a = a.left( equal );
                }
            }
            else if ( a.length() == 1 )
            {
                t = Arg;
            }
            else if ( a[ 0 ] == '-' )
            {
#if 0 // compat mode for -long style options
                if ( a.length() == 2 )
                {
                    t = ShortOpt;
                    a = a[ 1 ];
                }
                else
                {
                    a = a.mid( 1 );
                    t = LongOpt;
                    int equal = a.find( '=' ); // split key=value style arguments

                    if ( equal >= 0 )
                    {
                        stack.push( a.mid( equal +1 ) );
                        currArg--;
                        a = a.left( equal );
                    }
                }
#else
                // short option
                t = ShortOpt;

                // followed by an argument ? push it for later processing.
                if ( a.length() > 2 )
                {
                    stack.push( a.mid( 2 ) );
                    currArg--;
                }

                a = a[ 1 ];
#endif
            }
            else
            {
                t = Arg;
            }
        }
        else
        {
            // faked closing argument
            t = End;
        }

        // look up among known list of options
        Option opt;
        if ( t != End )
        {
            OptionConstIterator oit = obegin;

            while ( oit != oend )
            {
                const Option &o = *oit;

                if ( ( t == LongOpt && a == o.lname ) || ( t == ShortOpt && a[ 0 ].unicode() == o.sname ) )
                {
                    opt = o;
                    break;
                }

                ++oit;
            }

            if ( t == LongOpt && opt.type == OUnknown )
            {
                if ( currOpt.type != OVarLen )
                {
                    qWarning( "Unknown option --%s", a.toLocal8Bit().constData() );
                    return false;
                }
                else
                {
                    // VarLength options support arguments starting with '-'
                    t = Arg;
                }
            }
            else if ( t == ShortOpt && opt.type == OUnknown )
            {
                if ( currOpt.type != OVarLen )
                {
                    qWarning( "Unknown option -%c", a[ 0 ].unicode() );
                    return false;
                }
                else
                {
                    // VarLength options support arguments starting with '-'
                    t = Arg;
                }
            }

        }
        else
        {
            opt = Option( OEnd );
        }

        // interpret result
        switch ( state )
        {
        case StartState:
            if ( opt.type == OSwitch )
            {
                setSwitch( opt );
                setOptions.insert( opt.lname, 1 );
                setOptions.insert( QString( QChar( opt.sname ) ), 1 );
            }
            else if ( opt.type == OArg1 || opt.type == ORepeat )
            {
                state = ExpectingState;
                currOpt = opt;
                currType = t;
                setOptions.insert( opt.lname, 1 );
                setOptions.insert( QString( QChar( opt.sname ) ), 1 );
            }
            else if ( opt.type == OOpt || opt.type == OVarLen )
            {
                state = OptionalState;
                currOpt = opt;
                currType = t;
                setOptions.insert( opt.lname, 1 );
                setOptions.insert( QString( QChar( opt.sname ) ), 1 );
            }
            else if ( opt.type == OEnd )
            {
                // we're done
            }
            else if ( opt.type == OUnknown && t == Arg )
            {
                if ( numReqArgs > 0 )
                {
                    if ( reqArg.stringValue->isNull() )
                    {
                        *reqArg.stringValue = a;
                    }
                    else
                    {
                        qWarning( "Too many arguments" );
                        return false;
                    }
                }
                else if ( numOptArgs > 0 )
                {
                    if ( optArg.stringValue->isNull() )
                    {
                        *optArg.stringValue = a;
                    }
                    else
                    {
                        qWarning( "Too many arguments" );
                        return false;
                    }
                }
            }
            else
            {
                qFatal( "unhandled StartState case %d",  opt.type );
            }
            break;
        case ExpectingState:
            if ( t == Arg )
            {
                if ( currOpt.type == OArg1 )
                {
                    *currOpt.stringValue = a;
                    state = StartState;
                }
                else if ( currOpt.type == ORepeat )
                {
                    currOpt.listValue->append( a );
                    state = StartState;
                }
                else
                {
                    abort();
                }
            }
            else
            {
                QString n = currType == LongOpt ? currOpt.lname : QString( QChar( currOpt.sname ) );
                qWarning( "Expected an argument after '%s' option", n.toLocal8Bit().constData() );
                return false;
            }
            break;
        case OptionalState:
            if ( t == Arg )
            {
                if ( currOpt.type == OOpt )
                {
                    *currOpt.stringValue = a;
                    state = StartState;
                }
                else if ( currOpt.type == OVarLen )
                {
                    currOpt.listValue->append( origA );
                    // remain in this state
                }
                else
                {
                    abort();
                }
            }
            else
            {
                // optional argument not specified
                if ( currOpt.type == OOpt )
                {
                    *currOpt.stringValue = currOpt.def;
                }

                if ( t != End )
                {
                    // re-evaluate current argument
                    stack.push( origA );
                    currArg--;
                }

                state = StartState;
            }
            break;
        }

        if ( untilFirstSwitchOnly && opt.type == OSwitch )
        {
            return true;
        }

        // are we in the extra loop ? if so, flag the final end
        if ( t == End )
        {
            extraLoop = false;
        }
    }

    if ( numReqArgs > 0 && reqArg.stringValue->isNull() )
    {
        qWarning( "Lacking required argument" );
        return false;
    }

    return true;
}
Example #10
0
void init(OptionsMap& o) {

  o["Write Debug Log"]             = Option(false, on_logger);
  o["Write Search Log"]            = Option(false);
  o["Search Log Filename"]         = Option("SearchLog.txt");
  o["Book File"]                   = Option("book.bin");
  o["Best Book Move"]              = Option(false);
  o["Contempt Factor"]             = Option(0, -50,  50);
  o["Mobility (Midgame)"]          = Option(100, 0, 200, on_eval);
  o["Mobility (Endgame)"]          = Option(100, 0, 200, on_eval);
  o["Pawn Structure (Midgame)"]    = Option(100, 0, 200, on_eval);
  o["Pawn Structure (Endgame)"]    = Option(100, 0, 200, on_eval);
  o["Passed Pawns (Midgame)"]      = Option(100, 0, 200, on_eval);
  o["Passed Pawns (Endgame)"]      = Option(100, 0, 200, on_eval);
  o["Space"]                       = Option(100, 0, 200, on_eval);
  o["Aggressiveness"]              = Option(100, 0, 200, on_eval);
  o["Cowardice"]                   = Option(100, 0, 200, on_eval);
  o["Min Split Depth"]             = Option(0, 0, 12, on_threads);
  o["Max Threads per Split Point"] = Option(5, 4,  8, on_threads);
  o["Threads"]                     = Option(1, 1, MAX_THREADS, on_threads);
  o["Idle Threads Sleep"]          = Option(true);
  o["Hash"]                        = Option(32, 1, 8192, on_hash_size);
  o["Clear Hash"]                  = Option(on_clear_hash);
  o["Ponder"]                      = Option(true);
  o["OwnBook"]                     = Option(false);
  o["MultiPV"]                     = Option(1, 1, 500);
  o["Skill Level"]                 = Option(20, 0, 20);
  o["Emergency Move Horizon"]      = Option(40, 0, 50);
  o["Emergency Base Time"]         = Option(60, 0, 30000);
  o["Emergency Move Time"]         = Option(30, 0, 5000);
  o["Minimum Thinking Time"]       = Option(20, 0, 5000);
  o["Slow Mover"]                  = Option(70, 10, 1000);
  o["UCI_Chess960"]                = Option(false);
  o["UCI_AnalyseMode"]             = Option(false, on_eval);
}
Example #11
0
void init(OptionsMap& o) {

  o["Write Debug Log"]          << Option(false, on_logger);
  o["Write Search Log"]         << Option(false);
  o["Search Log Filename"]      << Option("SearchLog.txt");
  o["Contempt Factor"]          << Option(0, -50,  50);
  o["Min Split Depth"]          << Option(0, 0, 12, on_threads);
  o["Threads"]                  << Option(1, 1, MAX_THREADS, on_threads);
  o["Hash"]                     << Option(32, 1, 16384, on_hash_size);
  o["Clear Hash"]               << Option(on_clear_hash);
  o["Ponder"]                   << Option(true);
  o["MultiPV"]                  << Option(1, 1, 500);
  o["Skill Level"]              << Option(20, 0, 20);
  o["Emergency Move Horizon"]   << Option(40, 0, 50);
  o["Emergency Base Time"]      << Option(60, 0, 30000);
  o["Emergency Move Time"]      << Option(30, 0, 5000);
  o["Minimum Thinking Time"]    << Option(20, 0, 5000);
  o["Slow Mover"]               << Option(80, 10, 1000);
  o["UCI_Chess960"]             << Option(false);
}
Example #12
0
static void recomputeDependentOptions()
{
#if !defined(NDEBUG)
    Options::validateDFGExceptionHandling() = true;
#endif
#if !ENABLE(JIT)
    Options::useLLInt() = true;
    Options::useJIT() = false;
    Options::useDFGJIT() = false;
    Options::useFTLJIT() = false;
    Options::useDOMJIT() = false;
#endif
#if !ENABLE(YARR_JIT)
    Options::useRegExpJIT() = false;
#endif
#if !ENABLE(CONCURRENT_JS)
    Options::useConcurrentJIT() = false;
#endif
#if !ENABLE(DFG_JIT)
    Options::useDFGJIT() = false;
    Options::useFTLJIT() = false;
#endif
#if !ENABLE(FTL_JIT)
    Options::useFTLJIT() = false;
#endif
    
#if !CPU(X86_64) && !CPU(ARM64)
    Options::useConcurrentGC() = false;
#endif
    
#if OS(WINDOWS) && CPU(X86) 
    // Disable JIT on Windows if SSE2 is not present 
    if (!MacroAssemblerX86::supportsFloatingPoint())
        Options::useJIT() = false;
#endif
    if (Options::dumpDisassembly()
        || Options::dumpDFGDisassembly()
        || Options::dumpFTLDisassembly()
        || Options::dumpBytecodeAtDFGTime()
        || Options::dumpGraphAtEachPhase()
        || Options::dumpDFGGraphAtEachPhase()
        || Options::dumpDFGFTLGraphAtEachPhase()
        || Options::dumpB3GraphAtEachPhase()
        || Options::dumpAirGraphAtEachPhase()
        || Options::verboseCompilation()
        || Options::verboseFTLCompilation()
        || Options::logCompilationChanges()
        || Options::validateGraph()
        || Options::validateGraphAtEachPhase()
        || Options::verboseOSR()
        || Options::verboseCompilationQueue()
        || Options::reportCompileTimes()
        || Options::reportBaselineCompileTimes()
        || Options::reportDFGCompileTimes()
        || Options::reportFTLCompileTimes()
        || Options::reportDFGPhaseTimes()
        || Options::verboseCFA()
        || Options::verboseFTLFailure())
        Options::alwaysComputeHash() = true;
    
    if (!Options::useConcurrentGC())
        Options::collectContinuously() = false;

    if (Option(Options::jitPolicyScaleID).isOverridden())
        scaleJITPolicy();
    
    if (Options::forceEagerCompilation()) {
        Options::thresholdForJITAfterWarmUp() = 10;
        Options::thresholdForJITSoon() = 10;
        Options::thresholdForOptimizeAfterWarmUp() = 20;
        Options::thresholdForOptimizeAfterLongWarmUp() = 20;
        Options::thresholdForOptimizeSoon() = 20;
        Options::thresholdForFTLOptimizeAfterWarmUp() = 20;
        Options::thresholdForFTLOptimizeSoon() = 20;
        Options::maximumEvalCacheableSourceLength() = 150000;
        Options::useConcurrentJIT() = false;
    }
    if (Options::useMaximalFlushInsertionPhase()) {
        Options::useOSREntryToDFG() = false;
        Options::useOSREntryToFTL() = false;
    }
    
#if PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
    // Override globally for now. Longer term we'll just make the default
    // be to have this option enabled, and have platforms that don't support
    // it just silently use a single mapping.
    Options::useSeparatedWXHeap() = true;
#endif

    if (Options::alwaysUseShadowChicken())
        Options::maximumInliningDepth() = 1;

    // Compute the maximum value of the reoptimization retry counter. This is simply
    // the largest value at which we don't overflow the execute counter, when using it
    // to left-shift the execution counter by this amount. Currently the value ends
    // up being 18, so this loop is not so terrible; it probably takes up ~100 cycles
    // total on a 32-bit processor.
    Options::reoptimizationRetryCounterMax() = 0;
    while ((static_cast<int64_t>(Options::thresholdForOptimizeAfterLongWarmUp()) << (Options::reoptimizationRetryCounterMax() + 1)) <= static_cast<int64_t>(std::numeric_limits<int32_t>::max()))
        Options::reoptimizationRetryCounterMax()++;

    ASSERT((static_cast<int64_t>(Options::thresholdForOptimizeAfterLongWarmUp()) << Options::reoptimizationRetryCounterMax()) > 0);
    ASSERT((static_cast<int64_t>(Options::thresholdForOptimizeAfterLongWarmUp()) << Options::reoptimizationRetryCounterMax()) <= static_cast<int64_t>(std::numeric_limits<int32_t>::max()));

#if ENABLE(LLINT_STATS)
    LLInt::Data::loadStats();
#endif
#if !defined(NDEBUG)
    if (Options::maxSingleAllocationSize())
        fastSetMaxSingleAllocationSize(Options::maxSingleAllocationSize());
    else
        fastSetMaxSingleAllocationSize(std::numeric_limits<size_t>::max());
#endif
}
Example #13
0
void init(OptionsMap& o) {

  const int MaxHashMB = Is64Bit ? 1024 * 1024 : 2048;

  o["Write Debug Log"]       << Option(false, on_logger);
  o["Contempt"]              << Option(0, -100, 100);
  o["Min Split Depth"]       << Option(0, 0, 12, on_threads);
  o["Threads"]               << Option(1, 1, MAX_THREADS, on_threads);
  o["Hash"]                  << Option(16, 1, MaxHashMB, on_hash_size);
  o["Clear Hash"]            << Option(on_clear_hash);
  o["Ponder"]                << Option(true);
  o["MultiPV"]               << Option(1, 1, 500);
  o["Skill Level"]           << Option(20, 0, 20);
  o["Move Overhead"]         << Option(30, 0, 5000);
  o["Minimum Thinking Time"] << Option(20, 0, 5000);
  o["Slow Mover"]            << Option(80, 10, 1000);
  o["nodestime"]             << Option(0, 0, 10000);
  o["UCI_Chess960"]          << Option(false);
  o["SyzygyPath"]            << Option("<empty>", on_tb_path);
  o["SyzygyProbeDepth"]      << Option(1, 1, 100);
  o["Syzygy50MoveRule"]      << Option(true);
  o["SyzygyProbeLimit"]      << Option(6, 0, 6);
}
Example #14
0
void ConfigurationManager::bind(const QString &optionKey, QSpinBox *obj, int defaultValue)
{
    m_options[optionKey] = Option(defaultValue, "value", obj);
}
Example #15
0
	// optionのdefault値を設定する。
	void init(OptionsMap& o)
	{
		// Hash上限。32bitモードなら2GB、64bitモードなら1024GB
		const int MaxHashMB = Is64Bit ? 1024 * 1024 : 2048;

		// 並列探索するときのスレッド数
		// CPUの搭載コア数をデフォルトとすべきかも知れないが余計なお世話のような気もするのでしていない。

		o["Threads"] << Option(4, 1, 512, [](const Option& o) { Threads.set(o); });

		// USIプロトコルでは、"USI_Hash"なのだが、
		// 置換表サイズを変更しての自己対戦などをさせたいので、
		// 片方だけ変更できなければならない。
		// ゆえにGUIでの対局設定は無視して、思考エンジンの設定ダイアログのところで
		// 個別設定が出来るようにする。

		o["Hash"] << Option(16, 1, MaxHashMB, [](const Option&o) { TT.resize(o); });

		// その局面での上位N個の候補手を調べる機能
		o["MultiPV"] << Option(1, 1, 800);

		// cin/coutの入出力をファイルにリダイレクトする
		o["WriteDebugLog"] << Option(false, [](const Option& o) { start_logger(o); });

		// ネットワークの平均遅延時間[ms]
		// この時間だけ早めに指せばだいたい間に合う。
		// 切れ負けの瞬間は、NetworkDelayのほうなので大丈夫。
		o["NetworkDelay"] << Option(120, 0, 10000);

		// ネットワークの最大遅延時間[ms]
		// 切れ負けの瞬間だけはこの時間だけ早めに指す。
		// 1.2秒ほど早く指さないとfloodgateで切れ負けしかねない。
		o["NetworkDelay2"] << Option(1120, 0, 10000);

		// 最小思考時間[ms]
		o["MinimumThinkingTime"] << Option(2000, 1000, 100000);

		// 切れ負けのときの思考時間を調整する。序盤重視率。百分率になっている。
		// 例えば200を指定すると本来の最適時間の200%(2倍)思考するようになる。
		// 対人のときに短めに設定して強制的に早指しにすることが出来る。
		o["SlowMover"] << Option(100, 1, 1000);

		// 引き分けまでの最大手数。256手ルールのときに256を設定すると良い。
		// 0なら無制限。(桁あふれすると良くないので内部的には100000として扱う)
		o["MaxMovesToDraw"] << Option(0, 0, 100000, [](const Option& o) { max_game_ply = (o == 0) ? 100000 : (int)o; });

		// 探索深さ制限。0なら無制限。
		o["DepthLimit"] << Option(0, 0, INT_MAX);

		// 探索ノード制限。0なら無制限。
		o["NodesLimit"] << Option(0, 0, INT64_MAX);

		// 引き分けを受け入れるスコア
		// 歩を100とする。例えば、この値を100にすると引き分けの局面は評価値が -100とみなされる。

		// 千日手での引き分けを回避しやすくなるように、デフォルト値を2に変更した。[2017/06/03]
		// ちなみに、2にしてあるのは、
		//  int contempt = Options["Contempt"] * PawnValue / 100; でPawnValueが100より小さいので
		// 1だと切り捨てられてしまうからである。

		o["Contempt"] << Option(2, -30000, 30000);

		// Contemptの設定値を先手番から見た値とするオプション。Stockfishからの独自拡張。
		// 先手のときは千日手を狙いたくなくて、後手のときは千日手を狙いたいような場合、
		// このオプションをオンにすれば、Contemptをそういう解釈にしてくれる。
		// この値がtrueのときは、Contemptを常に先手から見たスコアだとみなす。

		o["ContemptFromBlack"] << Option(false);


#ifdef USE_ENTERING_KING_WIN
		// 入玉ルール
		o["EnteringKingRule"] << Option(ekr_rules, ekr_rules[EKR_27_POINT], [](const Option& o) { set_entering_king_rule(o); });
#endif
		// 評価関数フォルダ。これを変更したとき、評価関数を次のisreadyタイミングで読み直す必要がある。
		o["EvalDir"] << Option("eval", [](const USI::Option&o) { load_eval_finished = false; });

#if defined (USE_SHARED_MEMORY_IN_EVAL) && defined(_WIN32) && \
	 (defined(EVAL_KPPT) || defined(EVAL_KPP_KKPT) || defined(EVAL_KPPPT) || defined(EVAL_KPPP_KKPT) || defined(EVAL_KKPP_KKPT) || \
	defined(EVAL_KPP_KKPT_FV_VAR) || defined(EVAL_KKPPT) ||defined(EVAL_EXPERIMENTAL) || defined(EVAL_HELICES) || defined(EVAL_NABLA) )
		// 評価関数パラメーターを共有するか
		// 異種評価関数との自己対局のときにこの設定で引っかかる人が後を絶たないのでデフォルトでオフにする。
		o["EvalShare"] << Option(false);
#endif

#if defined(LOCAL_GAME_SERVER)
		// 子プロセスでEngineを実行するプロセッサグループ(Numa node)
		// -1なら、指定なし。
		o["EngineNuma"] << Option(-1, -1, 99999);
#endif

#if defined(EVAL_LEARN)
		// isreadyタイミングで評価関数を読み込まれると、新しい評価関数の変換のために
		// test evalconvertコマンドを叩きたいのに、その新しい評価関数がないがために
		// このコマンドの実行前に異常終了してしまう。
		// そこでこの隠しオプションでisready時の評価関数の読み込みを抑制して、
		// test evalconvertコマンドを叩く。
		o["SkipLoadingEval"] << Option(false);
#endif

		// 各エンジンがOptionを追加したいだろうから、コールバックする。
		USI::extra_option(o);
	}
Example #16
0
void ConfigurationManager::bind(const QString &optionKey, QLineEdit *obj, const QString &defaultValue)
{
    m_options[optionKey] = Option(defaultValue, "text", obj);
}
Example #17
0
/*
********************************************************************************
*                                                                              *
*  "annotate" command is used to search through the game in the "history" file *
*  (often set by the "read" command which reads moves in, skipping non-move    *
*  information such as move numbers, times, etc.)                              *
*                                                                              *
*  the normal output of this command is a file, in PGN format, that contains   *
*  the moves of the game, along with analysis when Crafty does not think that  *
*  move was the best choice.  the definition of "best choice" is somewhat      *
*  vague, because if the move played is "close" to the best move available,    *
*  Crafty will not comment on the move.  "close" is defined by the <margin>    *
*  option explained below.  this basic type of annotation works by first       *
*  using the normal tree search algorithm to find the best move.  if this      *
*  move was the move played, no output is produced.  if a different move is    *
*  considered best, then the actual move played is searched to the same depth  *
*  and if the best move and actual move scores are within <margin> of each     *
*  other, no comment is produced, otherwise crafty inserts the evaluation for  *
*  the move played, followed by the eval and PV for the best continuation it   *
*  found.                                                                      *
*                                                                              *
*  the format of the command is as follows:                                    *
*                                                                              *
*      annotate filename b|w|bw moves margin time [n]                          *
*                                                                              *
*  filename is the input file where Crafty will obtain the moves to annotate,  *
*  and output will be written to file "filename.ann".                          *
*                                                                              *
*  where b/w/bw indicates whether to annotate only the white side (w), the     *
*  black side (b) or both (bw).                                                *
*                                                                              *
*  moves indicates the move or moves to annotate.  it can be a single move,    *
*  which indicates the starting move number to annotate, or it can be a range, *
*  which indicates a range of move (1-999 gets the whole game.)                *
*                                                                              *
*  margin is the difference between Crafty's evaluation for the move actually  *
*  played and for the move Crafty thinks is best, before crafty will generate  *
*  a comment in the annotation file.  1.0 is a pawn, and will only generate    *
*  comments if the move played is 1.000 (1 pawn) worse than the best move      *
*  found by doing a complete search.                                           *
*                                                                              *
*  time is time per move to search, in seconds.                                *
*                                                                              *
*  [n] is optional and tells Crafty to produce the PV/score for the "n" best   *
*  moves.  Crafty stops when the best move reaches the move played in the game *
*  or after displaying n moves, whichever comes first.  if you use -n, then it *
*  will display n moves regardless of where the game move ranks.               *
*                                                                              *
********************************************************************************
*/
void Annotate() {

  FILE *annotate_in, *annotate_out;
  char command[80], text[128], colors[32], next;
  int annotate_margin, annotate_score[100], player_score, best_moves;
  int annotate_search_time_limit, search_player;
  int twtm, path_len, analysis_printed=0, *mv;
  int wtm, move_number, move_num, line1, line2, move, suggested, i;
  int temp_draw_score_is_zero, searches_done;
  CHESS_PATH temp[100], player_pv;

/*
 ----------------------------------------------------------
|                                                          |
|   first, quiz the user for the options needed to         |
|   successfully annotate a game.                          |
|                                                          |
 ----------------------------------------------------------
*/
  Print(0,"\nannotate filename: ");
  fscanf(input_stream,"%s",text);
  annotate_in = fopen(text,"r");
  if (annotate_in == NULL) {
    Print(0,"unable to open %s for input\n", text);
    return;
  }
  sprintf(command,"read=%s",text);
  Option(command);
  strcpy(text+strlen(text),".can");
  annotate_out = fopen(text,"w");
  if (annotate_out == NULL) {
    Print(0,"unable to open %s for output\n", text);
    return;
  }
  Print(0,"\ncolor(s): ");
  fscanf(input_stream,"%s",colors);
  line1=1;
  line2=999;
  Print(0,"\nstarting move number or range: ");
  fscanf(input_stream,"%s",text);
  if(strchr(text,'-')) sscanf(text,"%d-%d",&line1,&line2);
  else {
    sscanf(text,"%d",&line1);
    line2=999;
  }
  Print(0,"\nannotation margin: ");
  fscanf(input_stream,"%s",text);
  annotate_margin=atof(text)*PAWN_VALUE;
  Print(0,"\ntime per move: ");
  fscanf(input_stream,"%s",text);
  annotate_search_time_limit=atoi(text)*100;
  next=getc(input_stream);
  best_moves=1;
  if (next == ' ') {
    fscanf(input_stream,"%s",text);
    best_moves=atoi(text);
  }
/*
 ----------------------------------------------------------
|                                                          |
|   reset the game to "square 0" to start the annotation   |
|   procedure.  then we read moves from the input file,    |
|   make them on the game board, and annotate if the move  |
|   is for the correct side.  if we haven't yet reached    |
|   the starting move to annotate, we skip the Search()    |
|   stuff and read another move.                           |
|                                                          |
 ----------------------------------------------------------
*/
  annotate_mode=1;
  temp_draw_score_is_zero=draw_score_is_zero;
  draw_score_is_zero=1;
  ponder_completed=0;
  ponder_move=0;
  last_pv.path_iteration_depth=0;
  last_pv.path_length=0;
  InitializeChessBoard(&position[0]);
  wtm=1;
  move_number=1;

  fprintf(annotate_out,"[Event \"%s\"]\n",pgn_event);
  fprintf(annotate_out,"[Site \"%s\"]\n",pgn_site);
  fprintf(annotate_out,"[Date \"%s\"]\n",pgn_date);
  fprintf(annotate_out,"[Round \"%s\"]\n",pgn_round);
  fprintf(annotate_out,"[White \"%s\"]\n",pgn_white);
  fprintf(annotate_out,"[WhiteElo \"%s\"]\n",pgn_white_elo);
  fprintf(annotate_out,"[Black \"%s\"]\n",pgn_black);
  fprintf(annotate_out,"[BlackElo \"%s\"]\n",pgn_black_elo);
  fprintf(annotate_out,"[Result \"%s\"]\n",pgn_result);

  fprintf(annotate_out,"[Annotator \"Crafty v%s\"]\n",version);
  if (!strcmp(colors,"bw") || !strcmp(colors,"wb"))
    fprintf(annotate_out,"{annotating both black and white moves.}\n");
  else if (strchr(colors,'b'))
    fprintf(annotate_out,"{annotating only black moves.}\n");
  else if (strchr(colors,'w'))
    fprintf(annotate_out,"{annotating only white moves.}\n");
  fprintf(annotate_out,"{using a scoring margin of %s pawns.}\n",
          DisplayEvaluationWhisper(annotate_margin));
  fprintf(annotate_out,"{search time limit is %s}\n\n",
          DisplayTimeWhisper(annotate_search_time_limit));
  do {
    fflush(annotate_out);
    move=ReadChessMove(annotate_in,wtm,0);
    if (move <= 0) break;
    strcpy(text,OutputMove(&move,0,wtm));
    fseek(history_file,((move_number-1)*2+1-wtm)*10,SEEK_SET);
    fprintf(history_file,"%10s ",text);
    if (wtm) Print(0,"White(%d): %s\n",move_number,text);
    else Print(0,"Black(%d): %s\n",move_number,text);
    if (analysis_printed)
      fprintf(annotate_out,"%3d.%s%6s\n",move_number,(wtm?"":"   ..."),text);
    else {
      if (wtm)
        fprintf(annotate_out,"%3d.%6s",move_number,text);
      else
        fprintf(annotate_out,"%6s\n",text);
    }
    analysis_printed=0;
    if (move_number >= line1) {
      if ((!wtm && strchr(colors,'b')) | ( wtm && strchr(colors,'w'))) {
        last_pv.path_iteration_depth=0;
        last_pv.path_length=0;
        thinking=1;
        RootMoveList(wtm);
/*
 ----------------------------------------------------------
|                                                          |
|   now search the position to see if the move played is   |
|   the best move possible.  if not, then search just the  |
|   move played to get a score for it as well, so we can   |
|   determine if annotated output is appropriate.          |
|                                                          |
 ----------------------------------------------------------
*/
        search_time_limit=annotate_search_time_limit;
        search_depth=0;
        player_score=-999999;
        search_player=1;
        for (searches_done=0;searches_done<abs(best_moves);searches_done++) {
          if (searches_done > 0) {
            search_time_limit=3*annotate_search_time_limit;
            search_depth=temp[0].path_iteration_depth;
          }
          Print(0,"\n              Searching all legal moves.");
          Print(0,"----------------------------------\n");
          position[1]=position[0];
          InitializeHashTables();
          annotate_score[searches_done]=Iterate(wtm,annotate);
          if (pv[0].path[1] == move) {
            player_score=annotate_score[searches_done];
            player_pv=pv[0];
            search_player=0;
          }
          temp[searches_done]=pv[0];
          for (mv=last[0];mv<last[1];mv++) {
            if (*mv == pv[0].path[1]) {
              for (;mv<last[1]-1;mv++) *mv=*(mv+1);
              last[1]--;
              break;
            }
          }
          if (last[1] < last[0] ||
              (player_score+annotate_margin>annotate_score[searches_done] &&
               best_moves>0)) break;
        }
        if (search_player) {
          Print(0,"\n              Searching only the move played in game.");
          Print(0,"--------------------\n");
          position[1]=position[0];
          search_move=move;
          search_time_limit=3*annotate_search_time_limit;
          search_depth=temp[0].path_iteration_depth;
          if (search_depth==0) search_time_limit=annotate_search_time_limit;
          InitializeHashTables();
          player_score=Iterate(wtm,annotate);
          player_pv=pv[0];
          search_depth=0;
          search_time_limit=annotate_search_time_limit;
          search_move=0;
        }
/*
 ----------------------------------------------------------
|                                                          |
|   output the score/pv for the move played unless it      |
|   matches what Crafty would have played.  if it doesn't  |
|   then output the pv for what Crafty thinks is best.     |
|                                                          |
 ----------------------------------------------------------
*/
        thinking=0;
        if (player_pv.path_iteration_depth>1 && player_pv.path_length>=1 && 
            player_score+annotate_margin<annotate_score[0] &&
            (temp[0].path[1]!=player_pv.path[1] || annotate_margin<0.0 ||
            best_moves!=1)) {
          if (wtm) {
            analysis_printed=1;
            fprintf(annotate_out,"\n");
          }
          twtm = wtm;
          fprintf(annotate_out,"                {%d:%s",
                  player_pv.path_iteration_depth,
                  DisplayEvaluationWhisper(player_score)); 
          path_len=player_pv.path_length;
          for (i=1;i<=path_len;i++) {
            fprintf(annotate_out," %s",
                    OutputMove(&player_pv.path[i],i,twtm)); 
            MakeMove(i,player_pv.path[i],twtm);
            twtm=ChangeSide(twtm);
          }
          for (i=path_len;i>0;i--) {
            twtm=ChangeSide(twtm);
            UnMakeMove(i,player_pv.path[i],twtm);
          }
          fprintf(annotate_out,"}\n");
          for (move_num=0;move_num<searches_done;move_num++) {
            twtm = wtm;
            if (move != temp[move_num].path[1]) {
              fprintf(annotate_out,"                {%d:%s",
                      temp[move_num].path_iteration_depth,
                      DisplayEvaluationWhisper(annotate_score[move_num])); 
              path_len=temp[move_num].path_length;
              for (i=1;i<=path_len;i++) {
                fprintf(annotate_out," %s",
                        OutputMove(&temp[move_num].path[i],i,twtm)); 
                MakeMove(i,temp[move_num].path[i],twtm);
                twtm=ChangeSide(twtm);
              }
              for (i=path_len;i>0;i--) {
                twtm=ChangeSide(twtm);
                UnMakeMove(i,temp[move_num].path[i],twtm);
              }
              fprintf(annotate_out,"}\n");
            }
          }
        }
      }
    }
/*
 ----------------------------------------------------------
|                                                          |
|   before going on to the next move, see if the user has  |
|   included a set of other moves that require a search.   |
|   if so, search them one at a time and produce the ana-  |
|   lysis for each one.                                    |
|                                                          |
 ----------------------------------------------------------
*/
    do {
      next=getc(annotate_in);
    } while (next==' ' || next=='\n');
    ungetc(next,annotate_in);
    if (next == EOF) break;
    if (next == '{') do {
      do {
        next=getc(annotate_in);
      } while (next==' ');
      ungetc(next,annotate_in);
      if (next == EOF || next == '}') break;
      suggested=ReadChessMove(annotate_in,wtm,1);
      if (suggested < 0) break;
      if (suggested > 0) {
        thinking=1;
        Print(0,"\n              Searching only the move suggested.");
        Print(0,"--------------------\n");
        position[1]=position[0];
        search_move=suggested;
        search_time_limit=3*annotate_search_time_limit;
        search_depth=temp[0].path_iteration_depth;
        InitializeHashTables();
        annotate_score[0]=Iterate(wtm,annotate);
        search_depth=0;
        search_time_limit=annotate_search_time_limit;
        search_move=0;
        thinking=0;
        twtm = wtm;
        path_len = pv[0].path_length;
        if (pv[0].path_iteration_depth > 1 && path_len >= 1) {
          if (wtm && !analysis_printed) {
            analysis_printed=1;
            fprintf(annotate_out,"\n");
          }
          fprintf(annotate_out,"                {suggested %d:%s",
                  pv[0].path_iteration_depth,
                  DisplayEvaluationWhisper(annotate_score[0])); 
          for (i=1;i<=path_len;i++) {
            fprintf(annotate_out," %s",OutputMove(&pv[0].path[i],i,twtm)); 
            MakeMove(i,pv[0].path[i],twtm);
            twtm=ChangeSide(twtm);
          }
          for (i=path_len;i>0;i--) {
            twtm=ChangeSide(twtm);
            UnMakeMove(i,pv[0].path[i],twtm);
          }
          fprintf(annotate_out,"}\n");
        }
      }
    } while(1);
    MakeMoveRoot(move,wtm);
    wtm=ChangeSide(wtm);
    if (wtm) move_number++;
    if (move_number > line2) break;
  } while (1);
  fprintf(annotate_out,"\n");
  if (annotate_out) fclose(annotate_out);
  if (annotate_in) fclose(annotate_in);
  search_time_limit=0;
  draw_score_is_zero=temp_draw_score_is_zero;
  annotate_mode=0;
}
Example #18
0
void ConfigurationManager::bind(const QString &optionKey, const QVariant &defaultValue)
{
    m_options[optionKey] = Option(defaultValue);
}
Argument & ArgumentGroup::add_argument(const str_type & long_option, const str_type & short_option, const str_type & dest /*=""*/)
{
    return this->add_argument(Argument(Option(long_option, short_option, dest)));
}
Example #20
0
constexpr Option get_enum_min_value(Option) { return Option(0x0000); }
Example #21
0
const std::vector<ribi::Help::Option> ribi::Help::AddDefaultOptions(const std::vector<Option>& options)
{
  //v: unpadded Options
  std::vector<Option> v { options };
  v.push_back(Option('a',"about","display about message"));
  v.push_back(Option('h',"help","display this help message"));
  v.push_back(Option('i',"history","display version history"));
  v.push_back(Option('l',"licence","display licence"));
  v.push_back(Option('v',"version","display version"));

  //Find the longest long option, for padding
  const int max_length {
    static_cast<int>(
      std::max_element(
        v.begin(), v.end(),
        [](const Option& lhs, const Option& rhs)
        {
          return lhs.m_long.size() < rhs.m_long.size();
        }
      )->m_long.size()
    )
  };
  //w: padded options
  std::vector<Option> w;
  for (Option& p: v)
  {
    const int sz = static_cast<int>(p.m_long.size());
    assert(max_length >= sz);
    const int n_spaces = max_length - sz;
    assert(n_spaces >= 0);
    const std::string s = p.m_long
      + (n_spaces > 0 ? std::string(n_spaces,' '): std::string());
    assert(max_length == static_cast<int>(s.size()));
    const Option q(p.m_short,s,p.m_description);
    w.push_back(q);
  }

  //Sorts by short option
  //Also checks if there are no short or long option occurring twice
  std::sort(
    w.begin(),w.end(),
    [](const Option& lhs, const Option& rhs)
      {
        #ifndef NDEBUG
        if (lhs.m_short == rhs.m_short
          || lhs.m_long == rhs.m_long)
        {
          TRACE(lhs.m_short);
          TRACE(lhs.m_long);
          TRACE(lhs.m_description);
          TRACE(rhs.m_short);
          TRACE(rhs.m_long);
          TRACE(rhs.m_description);
        }
        #endif
        assert(lhs.m_short != rhs.m_short
          && "Every short option must be unique");
        assert(lhs.m_long != rhs.m_long
          && "Every long option must be unique");
        return lhs.m_short < rhs.m_short;
      }
    );

  return w;
}
Example #22
0
void ShellGenerator::writeFunctionSignature(QTextStream &s,
                                          const AbstractMetaFunction *meta_function,
                                          const AbstractMetaClass *implementor,
                                          const QString &name_prefix,
                                          Option option,
                                          const QString &classname_prefix,
                                          const QStringList &extra_arguments,
                                          int numArguments)
{
// ### remove the implementor
    AbstractMetaType *function_type = meta_function->type();


    if ((option & SkipReturnType) == 0) {
        if (function_type) {
            writeTypeInfo(s, function_type, option);
            s << " ";
        } else if (!meta_function->isConstructor()) {
            s << "void ";
        }
    }

    if (implementor) {
        if (classname_prefix.isEmpty())
            s << wrapperClassName(implementor) << "::";
        else
            s << classname_prefix << implementor->name() << "::";
    }


    QString function_name;
    if (option & OriginalName)
        function_name = meta_function->originalName();
    else
        function_name = meta_function->name();

    if (option & UnderscoreSpaces)
        function_name = function_name.replace(' ', '_');

    if (meta_function->isConstructor())
        function_name = meta_function->ownerClass()->name();

    if (meta_function->isStatic() && (option & ShowStatic)) {
      function_name = "static_" + meta_function->ownerClass()->name() + "_" + function_name;
    }
  
    if (function_name.startsWith("operator")) {
      function_name = meta_function->name();
    }

  if (meta_function->attributes() & AbstractMetaAttributes::SetterFunction)
    s << "py_set_";
  else if (meta_function->attributes() & AbstractMetaAttributes::GetterFunction)
    s << "py_get_";

  s << name_prefix << function_name;

    s << "(";

  if ((option & FirstArgIsWrappedObject) && meta_function->ownerClass() && !meta_function->isConstructor() && !meta_function->isStatic()) {
    s << meta_function->ownerClass()->qualifiedCppName() << "* theWrappedObject"; 
    if (meta_function->arguments().size() != 0) {
      s << ", ";
    }
  }
  
   writeFunctionArguments(s, meta_function->ownerClass(), meta_function->arguments(), Option(option & Option(~ConvertReferenceToPtr)), numArguments);

    // The extra arguments...
    for (int i=0; i<extra_arguments.size(); ++i) {
        if (i > 0 || meta_function->arguments().size() != 0)
            s << ", ";
        s << extra_arguments.at(i);
    }

    s << ")";
    if (meta_function->isConstant())
        s << " const";
}
Example #23
0
int
main(int argc,
     char *argv[])
{
    ulong      	done;
    ulong	fail;
    ulong	net;
    ulong	insert;
    int		netsLeft;
int TIMELOOP;
for (TIMELOOP = 0; TIMELOOP < 20; ++TIMELOOP) {

    Option(argc, argv);

    BuildChannel();
    BuildVCG();
    AcyclicVCG();
    BuildHCG();

    do {
	/*
	 * Setup.
	 */
	AllocAssign();
	NetsAssign();
	InitAllocMaps();

	/*
	 * Copy the nets assign.
	 */
	channelTracksCopy = channelTracks;
	for (net = 1; net <= channelNets; net++) {
	    netsAssignCopy[net] = netsAssign[net];
	}

	/*
	 * Route, adding a row if necessary.
	 */
	fail = 0;
	do {
	    done = TRUE;
	    if ((netsLeft = DrawNets()) != 0) {
		printf("Assignment could not route %d columns, trying maze1...\n",
		       netsLeft);
		if ((netsLeft = Maze1()) != 0) {
		    printf("Maze1 could not route %d columns, trying maze2...\n",
			   netsLeft);
		    if ((netsLeft = Maze2()) != 0) {
			printf("Maze2 could not route %d columns, trying maze3...\n",
			       netsLeft);
			if ((netsLeft = Maze3()) != 0) {
			    printf("Maze3 could not route %d columns, adding a track...\n",
				   netsLeft);
			    /* PrintChannel(); */
			    if (! fail) {
				channelTracks++;
			    }
			    fail++;

			    /*
			     * Restore the nets assign.
			     */
			    for (net = 1; net <= channelNets; net++) {
				netsAssign[net] = netsAssignCopy[net];
			    }

			    /*
			     * Damn!
			     */
			    done = FALSE;
			}
		    }
		}
	    }

	    /*
	     * Add a track at track # fail, thereby shifting
	     * all tracks at that point down one track.
	     */
	    if ((! done) && fail) {
#ifdef VERBOSE
		printf("\n*** fail (insert track at %d) ***\n", fail);
#endif
		for (insert = 1; insert <= channelNets; insert++) {
		    if (netsAssign[insert] >= fail) {
			netsAssign[insert]++;
		    }
		}
	    }
	} while ((! done) && (fail <= channelTracksCopy + 1));

	/*
	 * Did adding a row within existing assignment work?
	 * If not, just start over.
	 */
	if (! done) {
	    FreeAllocMaps();
	    FreeAssign();
	    assert(channelTracks == channelTracksCopy + 1);
	}
    } while (! done);

    printf("\n");
    PrintChannel();
#ifdef PLUS_STATS
    PrintDerefStats(stderr);
    PrintHeapSize(stderr);
#endif /* PLUS_STATS */
}
    exit(0);
}
Example #24
0
void init(OptionsMap& o) {

  const int MaxHashMB = Is64Bit ? 1024 * 1024 : 2048;
  
  unsigned int n = std::thread::hardware_concurrency();
  if (!n) n = 1;
  o["Write Debug Log"]          << Option(false, on_logger);
  o["Contempt"]                 << Option(0, -100, 100);
  o["Pawn Structure (Midgame)"] << Option(100, 0, 200, on_eval);
  o["Pawn Structure (Endgame)"] << Option(100, 0, 200, on_eval);
  o["Passed Pawns (Midgame)"]   << Option(100, 0, 200, on_eval);
  o["Passed Pawns (Endgame)"]   << Option(100, 0, 200, on_eval);
  o["Space"]                    << Option(100, 0, 200, on_eval);
  o["King Safety"]              << Option(100, 0, 200, on_eval);
  o["Book File"]                << Option("Nayeem.bin");
  o["Best Book Move"]           << Option(false);
  o["Threads"]                  << Option(n, 1, 128, on_threads);
  o["Hash"]                     << Option(16, 1, MaxHashMB, on_hash_size);
  o["Clear Hash"]               << Option(on_clear_hash);
  o["Ponder"]                   << Option(true);
  o["OwnBook"]                  << Option(false);
  o["MultiPV"]                  << Option(1, 1, 500);
  o["Skill Level"]              << Option(20, 0, 20);
  o["Move Overhead"]            << Option(30, 0, 5000);
  o["Minimum Thinking Time"]    << Option(20, 0, 5000);
  o["Slow Mover"]               << Option(89, 10, 1000);
  o["nodestime"]                << Option(0, 0, 10000);
  o["UCI_Chess960"]             << Option(false);
  o["SyzygyPath"]               << Option("<empty>", on_tb_path);
  o["SyzygyProbeDepth"]         << Option(1, 1, 100);
  o["Syzygy50MoveRule"]         << Option(true);
  o["SyzygyProbeLimit"]         << Option(6, 0, 6);
  // Hanging pieces
  o["Hanging (Midgame)"]        << Option(49, -10, 250);
  o["Hanging (Endgame)"]        << Option(27, -10, 250);
  

}
void
DependingPressingPeriodKeyToKey::add(KeyToKeyType::Value type, AddDataType datatype, AddValue newval) {
  if (type == KeyToKeyType::END_) return;

  if (datatype == BRIDGE_DATATYPE_OPTION && Option::UNINTERRUPTIBLE_BY_SCROLL_WHEEL == Option(newval)) {
    interruptibleByScrollWheel_ = false;
  } else {
    keytokey_[type].add(datatype, newval);
  }
}