Skip to content

Commit

Permalink
random first move when selfplay
Browse files Browse the repository at this point in the history
  • Loading branch information
hzyhhzy committed Oct 9, 2024
1 parent d482977 commit 39a4abf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cpp/neuralnet/nninputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,15 +566,17 @@ void NNInputs::fillRowV7(
//The first 5 of them were set already above to flag which of the past 5 moves were passes.

//Scoring
if(hist.rules.scoringRule == Rules::SCORING_AREA) {}
if(hist.rules.scoringRule == Rules::SCORING_AREA) {}
else if(hist.rules.scoringRule == Rules::SCORING_CON) {
rowGlobal[6] = 1.0;
}
else
ASSERT_UNREACHABLE;


// Parameter 0 noResultUtilityForWhite, when draw, white's win rate = 0.5*(noResultUtilityForWhite+1)
rowGlobal[0] = pla == C_WHITE ? nnInputParams.noResultUtilityForWhite : -nnInputParams.noResultUtilityForWhite;

rowGlobal[6] = hist.rules.scoringRule == Rules::SCORING_CON;

// Parameter 15 is used because there's actually a discontinuity in how training behavior works when this is
// nonzero, no matter how slightly.
Expand Down
13 changes: 13 additions & 0 deletions cpp/program/play.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,19 @@ FinishedGameData* Play::runGame(
}
};

if (gameRand.nextBool(0.95))
{
if (board.stonenum == 0)
{
//random play first move
int x = gameRand.nextUInt(board.x_size);
int y = gameRand.nextUInt(board.y_size);
Loc loc = Location::getLoc(x, y, board.x_size);
assert(pla == C_BLACK);
assert(board.isLegal(loc, pla));
hist.makeBoardMoveAssumeLegal(board, loc, pla);
}
}

if(playSettings.initGamesWithPolicy && otherGameProps.allowPolicyInit) {
double avgPolicyInitMoveNum =
Expand Down

0 comments on commit 39a4abf

Please sign in to comment.