本文整理汇总了C++中board::checkers0Raw方法的典型用法代码示例。如果您正苦于以下问题:C++ board::checkers0Raw方法的具体用法?C++ board::checkers0Raw怎么用?C++ board::checkers0Raw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类board
的用法示例。
在下文中一共展示了board::checkers0Raw方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checks
double strategytdexp4::getOutputBackgammonLossValue( const vector<double>& middles, const board& brd ) const
{
// special case - if the player 0 has taken any pieces in, the gammon loss prob is zero
if( brd.bornIn0Raw() > 0 ) return 0;
// also if there are no player 0 pieces in player 1's box, the backgammon win prob is zero
vector<int> checks( brd.checkers0Raw() );
bool foundOne = brd.hit0Raw() > 0;
if( !foundOne )
for( int i=18; i<24; i++ )
if( checks.at(i) > 0 )
{
foundOne = true;
break;
}
if( !foundOne ) return 0;
// otherwise calculate the network value
double val=0;
for( int i=0; i<nMiddle; i++ )
val += outputBackgammonLossWeights.at(i) * middles.at(i);
val += outputBackgammonLossWeights.at(nMiddle); // bias node
return 1. / ( 1 + exp( -val ) );
}
示例2:
vector<double> strategytdexp4::getInputValues( const board& brd, int turn ) const
{
vector<double> inputs;
inputs.resize(198,0);
vector<int> checks = brd.checkers0Raw();
vector<int> otherChecks = brd.checkers1Raw();
int hit = brd.hit0Raw();
int otherHit = brd.hit1Raw();
int borneIn = brd.bornIn0Raw();
int otherBorneIn = brd.bornIn1Raw();
int i, j;
// we put values for the first player in the first half of the inputs and for the second player
// in the second half.
for( i=0; i<24; i++ )
{
// each spot gets four units. The first is 1 if there is at least one checker on the point,
// else 0; the 2nd is 1 if there are at least two checkers; the 3rd if there are at least
// three; and the fourth = max(0,(n-3)/2), where n=# of checkers. That's done for both players.
for( j=0; j<3; j++ )
{
if( checks.at(i) > j ) inputs.at(4*i+j) = 1;
if( otherChecks.at(i) > j ) inputs.at(4*i+j+99) = 1;
}
if( checks.at(i) > 3 ) inputs.at(4*i+3) = ( checks[i]-3 ) / 2.;
if( otherChecks.at(i) > 3 ) inputs.at(4*i+3+99) = ( otherChecks[i]-3 ) / 2.;
}
// one spot for each player records the number on the bar
inputs.at(96) = hit / 2.;
inputs.at(195) = otherHit / 2.;
// one spot for each player records the number born in
inputs.at(97) = borneIn / 15.;
inputs.at(196) = otherBorneIn / 15.;
// one spot for each player notes whose turn it is
inputs.at(98) = turn == 0 ? 1 : 0;
inputs.at(197) = turn == 0 ? 0 : 1;
return inputs;
}
示例3: if
//.........这里部分代码省略.........
newProbOutput = 1.;
if( newBoard.bornIn1Raw() == 0 ) // gammon or backgammon
{
newGammonWinOutput = 1.;
vector<int> checks( newBoard.checkers1Raw() );
bool foundOne = newBoard.hit1Raw() > 0;
if( !foundOne )
{
for( int i=0; i<6; i++ )
if( checks.at(i) > 0 )
{
foundOne = true;
break;
}
}
newBgWinOutput = foundOne ? 1 : 0;
}
else
{
newGammonWinOutput = 0.;
trainBgWin = false; // no gammon win so can't train conditional bg win prob
}
}
else if( newBoard.bornIn1Raw() == 15 )
{
trainGammonWin = false;
trainBgWin = false;
newProbOutput = 0.;
if( newBoard.bornIn0Raw() == 0 ) // gammon loss or backgammon loss
{
newGammonLossOutput = 1;
vector<int> checks( newBoard.checkers0Raw() );
bool foundOne = newBoard.hit0Raw() > 0;
if( !foundOne )
{
for( int i=18; i<24; i++ )
if( checks.at(i) > 0 )
{
foundOne = true;
break;
}
}
newBgLossOutput = foundOne ? 1 : 0;
}
else
{
newGammonLossOutput = 0;
trainBgLoss = false;
}
}
else
{
// estimate from the new board's outputs, remembering that after the move is done,
// the other player gets the dice.
vector<double> midVals( getMiddleValues( getInputValues( newBoard, !newBoard.perspective() ) ) );
newProbOutput = getOutputProbValue( midVals );
newGammonWinOutput = getOutputGammonWinValue( midVals, newBoard );
newGammonLossOutput = getOutputGammonLossValue( midVals, newBoard );
newBgWinOutput = getOutputBackgammonWinValue( midVals, newBoard );
newBgLossOutput = getOutputBackgammonLossValue( midVals, newBoard );
}
// train the nodes as appropriate