Playouts

Playouts implementation spans across the uct module (see uct.h) and the board module (see board.h). Core functionality is provided in classes SimplePlayout and AdvisorPlayout (inherits from SimplePlayout and adds support for MoveAdvisor).

Playout is instantiated and started from uct module in Uct::doPlayout function in following way:

  //Uct::doPlayout
  ...
  AdvisorPlayout playoutManager(playBoard, MAX_PLAYOUT_LENGTH, playoutLen, advisor_);

  playoutStatus = playoutManager.doPlayout();
  float sample = decidePlayoutWinner(playBoard);
  tree_->updateHistory(sample);
  if (cfg.moveAdvisor()){
    advisor_->update(sample);
  }
  ...
  //end Uct::doPlayout

AdvisorPlayout::doPlayout basically just iteratively calls AdvisorPlayout::playOne and tests the playout end criteria. AdvisorPlayout::playOne tries to play a move according to MoveAdvisor or just fallbacks to original SimplePlayout::playOne which is not more than a wrapper around Board::findMCmoveAndMake (the real move selection happens here). This function does the real work, therefore it deserves further analysis:

if active trapping is activated and there is active trapping move, make a random trapping move

  //Board::fincMCmoveAndMake
  ...
  if (cfg.activeTrapping() && glob.grand()->get01() < cfg.activeTrapping() && findActiveTrapping(moves)){
    makeMove(moves[glob.grand()->getOne() % moves.size()]);
    return;
  }

gather positions of pieces which will be performing the move the principle is to select randomly at most three pieces

  for (int i = 0; i < BIT_LEN/2; i++){
    int pos = glob.grand()->getOne() % BIT_LEN;
    if (bits::getBit(bitboard_[toMove_][0], pos)){
      p.push_back(pos);
      if (p.size() >= 3){
        break;
      }
    }
  }

until the move is not committed, loop over pieces' positions, generate their step and select one of these (either with knowledge or randomly) as a part of the final move

  do { 
    ...
    for (intList::iterator it = p.begin(); it != p.end(); it++) { 
      //piece might have fallen into trap -> must check is there
      if (getPlayer((*it)) == toMove_){ 
        //generate steps for single piece
        genStepsOne((*it), toMove_, steps, len);
      }
    }
    
    //no steps -> play pass
    if (len == 0){
      steps[len++] = Step(STEP_PASS, toMove_);
    }

    //select step according to knowledge
    if (cfg.knowledgeInPlayout()){
      step = chooseStepWithKnowledge(steps, len);
    }
    else{
      step = steps[glob.grand()->getOne() % len];
    }
    ...
  } while (! makeStepTryCommit(step));
  ... 
  //end Board::fincMCmoveAndMake

Generated on Thu Aug 6 23:29:07 2009 for akimot by  doxygen 1.5.7.1