Domain knowledge

All code containing domain knowledge for both static evaluation and step evaluation is defined in eval module (see eval.h). Core class of this module is class Eval, taking responsibility for both mentioned tasks. Evaluation constants are parsed and incorporated in Eval via helper classes EvaluationValues, resp. StepKnowledgeValues - constructors of these are called from config module (see config.h) during the configuration file parsing. Evaluation functions basically just check binary features (is a step's piece elephant, etc. ) and according to these assign weights (bonus for step's piece being elephant, etc.)
Step evaluation is represented by function Eval::evaluateStep and contains for instance following elements (for full list of features, please see the code):

rabbits evaluation

  //Eval::evaluateStep
  ...
  
  gameStage_e gs = determineGameStage(b->getBitboard());
  if (step.piece_ == RABBIT){
    switch (gs) { 
      case GS_BEGIN: eval += skvals_->rabbitStepBeginVal; 
                break;
      case GS_MIDDLE: eval += skvals_->rabbitStepMiddleVal; 
                break;
      case GS_LATE: eval += skvals_->rabbitStepLateVal;
                break;
    }
  }
  ...

locality handling

  ...
  if (cfg.localPlayout() && 
      b->lastStep().stepType_ != STEP_NULL){
    int d = SQUARE_DISTANCE(b->lastStep().to_, step.from_);
    eval += d <= skvals_->localityReach ?  
                 (skvals_->localityReach - d) * skvals_->localityVal : 0;
  }
  ...

step kills an opponent's piece

  ...
  if (step.isPushPull() && b->checkKillForward(step.oppFrom_, step.oppTo_)){
    eval += skvals_->killVal;
  }
  ...
  //end Eval::evaluateStep

Static evaluation is represented by function Eval::evaluate and contains for instance following elements (for full list of features, please see the code):

Bonus for pieces (value, position) and penalties for frozen pieces

  //Eval::evaluate
  ...
  while ((pos = bits::lix(pieces)) != BIT_EMPTY){
    piece_t piece = b->getPiece(pos, player);
    tot[player] += vals_->pieceValue[piece];
    
    logDDebug("material bonus %4d for %s", vals_->pieceValue[piece], Soldier(player, piece, pos).toString().c_str());

    tot[player] += vals_->piecePos[gs][player][piece][pos];
    logDDebug("positional bonus %4d for %s", vals_->piecePos[gs][player][piece][pos], Soldier(player, piece, pos).toString().c_str());

  //frozen
    if (! bits::getBit(movable, pos)){
      tot[player] += vals_->pieceValue[piece] * vals_->frozenPenaltyRatio;
      logDDebug("material penalty %4.2f for %s being frozen", vals_->pieceValue[piece] * vals_->frozenPenaltyRatio, Soldier(player, piece, pos).toString().c_str());
    } 
  ...

evaluation of sole traps and their bonuses

  while ((trap = bits::lix(traps)) != BIT_EMPTY){
    ...
    //sole traps
    if (guardsNum[player] > 0 && guardsNum[OPP(player)] == 0){
      tot[player] += vals_->trapSoleVal;
      logDDebug("trap sole %d to %d player for %s trap " , 
        vals_->trapSoleVal, player, coordToStr(trap).c_str()); 
      //bonus for opponent pieces in victims Area
      if (influenceDom == player && 
          victimsArea & b->bitboard_[OPP(player)][0] & ~movable){
        tot[player] += vals_->trapPotVal;
        logDDebug("trap pot bonus %d to %d player for %s trap " , 
          vals_->trapPotVal, player, coordToStr(trap).c_str()); 
      }
    }
    ...
  //end Eval::evaluate

Evaluation is transformed to win ratio by Eval::evaluateInPercent (this function is actually called from uct module from Uct::decidePlayoutWinner ).


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