当前位置: 首页>>代码示例>>C++>>正文


C++ NodeStack::size方法代码示例

本文整理汇总了C++中NodeStack::size方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeStack::size方法的具体用法?C++ NodeStack::size怎么用?C++ NodeStack::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NodeStack的用法示例。


在下文中一共展示了NodeStack::size方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: exploreNode

void OracleBuilder::exploreNode(ConcurrentMap<string, HashTable *> &tables,
                                NodeStack &nodes, Color playFor, int commId)
{
    Position pos;
    Comm::UCICommunicatorPool &pool = Comm::UCICommunicatorPool::getInstance();
    Options &opt = Options::getInstance();
    HashTable *oracle = tables[""];
    pool.sendOption(commId, "MultiPV", to_string(opt.getMaxMoves()));
    //Main loop
    Node *current = nullptr;
    while ((current = nodes.poptop())) {
        string iterationOutput;
        const string currentPos = current->getPos();

        Line bestLine;
        /*Set the chessboard to current pos*/
        pos.set(currentPos);
        Color active = pos.side_to_move();
        string signature = pos.signature();
        uint64_t curHash = pos.hash();
        bool insertCopyInSignTable = false;

        /*Lookup in signature tables*/
        if (signature.length() <= opt.getMaxPiecesEnding()) {
            HashTable *table = nullptr;
            if (tables.count(signature) == 0) {
                string filename = opt.getTableFolder() + "/" + signature
                                  + ".autosave."
                                  + opt.getVariantAsString()
                                  + to_string(opt.getCutoffThreshold())
                                  + ".bin";
                table = new HashTable(filename);
                if (tables.findOrInsert(signature, table) != table) {
                    delete table;
                    table = tables[signature];
                }
            } else {
                table = tables[signature];
            }
            Node *s = nullptr;
            if ((s = table->findVal(curHash))) {
                current->updateStatus((Node::StatusFlag)
                                      (s->getStatus() | Node::SIGNATURE_TABLE));
                if (current->getStatus() & Node::THEM) {
                    OracleBuilder::displayNodeHistory(current);
                    Out::output("Iteration output for error :\n" + iterationOutput);
                    Err::handle("A node has gone from draw to mate, this is an error"
                                " until we decide on what to do, and if it's a bug"
                                " in the engine.");
                }
                if (oracle->findOrInsert(curHash, current) != current)
                    delete current;
                continue;
            } else {
                insertCopyInSignTable = true;
            }
        }

        /*Try to find the position and insert it if not found*/
        if (oracle->findOrInsert(curHash, current) != current) {
            Out::output(iterationOutput, "Position already in table.\n", 1);
            delete current;
            continue;
        }

        /* TODO rethink this, as we should probably remove the position if cut
         *if (OracleBuilder::cutNode(pos, current)) {
         *    Out::output("Node cut by user-defined function", 1);
         *    continue;
         *}
         */
        Out::output(iterationOutput, "[" + color_to_string(active)
                    + "] Proceed size : " + to_string(nodes.size())
                    + "\n");

        /*Clear cut*/
        if (!pos.hasSufficientMaterial()) {
            current->updateStatus(Node::DRAW);
            Out::output(iterationOutput, "[" + color_to_string(active)
                        + "] Insuficient material.\n", 2);
            //Proceed to next node...
            continue;
        }


        Out::output(iterationOutput, pos.pretty(), 2);

        /*Hit statistic*/
        __atomic_fetch_add(&OracleFinder::signStat_[signature], 1, __ATOMIC_SEQ_CST);

        string position = "position fen ";
        position += pos.fen();
        pool.send(commId, position);

        if (playFor != active) {
            /*We are on a node where the opponent has to play*/
            current->updateStatus(Node::AGAINST);
            /*proceedAgainstNode(pos, current);*/
            vector<Move> all = gen_all(pos);
            /*
//.........这里部分代码省略.........
开发者ID:viroulep,项目名称:chessfinder,代码行数:101,代码来源:OracleFinder.cpp


注:本文中的NodeStack::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。