本文整理汇总了C++中MoveList::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ MoveList::push_back方法的具体用法?C++ MoveList::push_back怎么用?C++ MoveList::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoveList
的用法示例。
在下文中一共展示了MoveList::push_back方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: moves
MoveList EndgamePlayer::moves(int nmoves)
{
if (currentPosition().bag().size() > 0)
{
#ifdef DEBUG_ENDGAME
UVcout << "EndgamePlayer returning statically evaluated play." << endl;
#endif
m_simulator.currentPosition().kibitz(nmoves);
#ifdef DEBUG_ENDGAME
UVcout << "EndgamePlayer returns " << m_simulator.currentPosition().moves() << endl;
#endif
return m_simulator.currentPosition().moves();
}
m_endgame.setPosition(currentPosition());
if (nmoves > 1) return m_endgame.moves(nmoves);
#ifdef DEBUG_ENDGAME
UVcout << "EndgamePlayer solving endgame from position:" << endl;
UVcout << currentPosition() << endl;
#endif
MoveList ret;
Move solution = m_endgame.solve(currentPosition().nestedness());
ret.push_back(solution);
#ifdef DEBUG_ENDGAME
UVcout << "EndgamePlayer returns solved endgame:" << ret << endl;
#endif
return ret;
}
示例2: getBlockMove
MoveList ChessPiece::getBlockMove(Move blockMove, MoveList curMoveList) {
MoveList res;
for (auto move : curMoveList)
if (move == blockMove)
res.push_back(move);
return res;
}
示例3: getAttackMove
MoveList ChessPiece::getAttackMove(MoveList curMoveList) {
MoveList moveList = permissibleMove();
MoveList attackList;
for (auto move : moveList)
if (std::find(curMoveList.begin(), curMoveList.end(), move) == curMoveList.end())
attackList.push_back(move);
return attackList;
}
示例4: getValidMove
void Board::getValidMove(Color my,MoveList& validMove) const{
static Position offsets[8]={
Position(-1,-1),Position(-1,0),Position(-1,1),
Position(0,-1),Position(0,1),
Position(1,-1),Position(1,0),Position(1,1)
};
for(int row=0;row<sideLength;++row){
for(int col=0;col<sideLength;++col){
Move m(row,col);
Position current(row,col);
if(piece(current)!=EMPTY)
continue;
for(int i=0;i<8;++i){
if(hasClosure(my,current,offsets[i]))
m.addOffset(offsets[i]);
}
if(m.getOffsets().size()!=0)
validMove.push_back(m);
}
}
}
示例5: allWordsFormedBy
MoveList Board::allWordsFormedBy(const Move &move) const
{
MoveList ret;
if (move.tiles().length() > 1)
ret.push_back(move);
if (move.action == Move::Place)
{
if (m_empty)
{
ret.push_back(move);
}
else
{
LetterString word;
if (move.horizontal)
{
int i = 0;
for (const auto& it : move.tiles())
{
if (m_letters[move.startrow][i + move.startcol] == QUACKLE_NULL_MARK)
{
word.clear();
word += it;
int startRow = 0;
for (int j = move.startrow - 1; j >= 0; --j)
{
if (m_letters[j][i + move.startcol] == QUACKLE_NULL_MARK)
{
startRow = j + 1;
break;
}
else
{
word = m_letters[j][i + move.startcol] + word;
}
}
for (int j = move.startrow + 1; j < m_height; ++j)
{
if (m_letters[j][i + move.startcol] == QUACKLE_NULL_MARK)
j = m_height;
else
word += m_letters[j][i + move.startcol];
}
if (word.length() > 1)
{
ret.push_back(Move::createPlaceMove(startRow, (i + move.startcol), /* vertical */ false, word));
}
}
i++;
}
}
else
{
int i = 0;
for (const auto& it : move.tiles())
{
if (m_letters[i + move.startrow][move.startcol] == QUACKLE_NULL_MARK)
{
word.clear();
word += it;
int startColumn = 0;
for (int j = move.startcol - 1; j >= 0; --j)
{
if (m_letters[i + move.startrow][j] == QUACKLE_NULL_MARK)
{
startColumn = j + 1;
break;
}
else
{
word = m_letters[i + move.startrow][j] + word;
}
}
for (int j = move.startcol + 1; j < m_width; ++j)
{
if (m_letters[i + move.startrow][j] == QUACKLE_NULL_MARK)
j = m_width;
else
word += m_letters[i + move.startrow][j];
}
if (word.length() > 1)
{
ret.push_back(Move::createPlaceMove((i + move.startrow), startColumn, /* horizontal */ true, word));
}
i++;
}
}
}
}
}
//.........这里部分代码省略.........
示例6: reportPosition
void Reporter::reportPosition(const GamePosition &position, ComputerPlayer *computerPlayer, UVString *report)
{
UVOStringStream s;
UVOStringStream titleStream;
if (!position.gameOver())
titleStream << position.currentPlayer().name() << MARK_UV(": Turn ") << position.turnNumber() << MARK_UV('\n');
const Quackle::PlayerList players(position.endgameAdjustedScores());
for (PlayerList::const_iterator it = players.begin(); it != players.end(); ++it)
{
s.width(3);
s << right << ((*it) == position.currentPlayer()? MARK_UV("->") : MARK_UV(" "));
s << MARK_UV(' ');
s.width(24);
s << left << (*it).name() << MARK_UV(' ');
s.width(9);
s << (*it).rack().toString() << MARK_UV(' ');
s.width(4);
s << (*it).score();
s << MARK_UV('\n');
}
if (computerPlayer && !position.gameOver())
{
computerPlayer->setPosition(position);
if (position.committedMove().isAMove())
computerPlayer->considerMove(position.committedMove());
const unsigned int movesToShow = 10;
MoveList moves = computerPlayer->moves(movesToShow);
int ourMoveIndex = 0;
int i = 1;
for (Quackle::MoveList::const_iterator it = moves.begin(); it != moves.end(); ++it, ++i)
{
if ((*it) == position.committedMove())
{
ourMoveIndex = i;
break;
}
}
bool isUrp = false;
if (position.committedMove().isAMove())
{
// our move not in list
if (ourMoveIndex == 0)
{
if (moves.size() == movesToShow)
moves.pop_back();
isUrp = true;
ourMoveIndex = movesToShow;
moves.push_back(position.committedMove());
}
}
int highestScore = 0;
double highestEquity = 0;
unsigned int widestPositionString = 0;
unsigned int widestMove = 0;
bool hasWinPercentages = false;
const Quackle::MoveList::const_iterator end(moves.end());
for (Quackle::MoveList::const_iterator it = moves.begin(); it != end; ++it)
{
if ((*it).prettyTiles().length() > widestMove)
widestMove = (*it).prettyTiles().length();
if ((*it).positionString().length() > widestPositionString)
widestPositionString = (*it).positionString().length();
if ((*it).win > 0)
hasWinPercentages = true;
if ((*it).equity > highestEquity)
highestEquity = (*it).equity;
if ((*it).score > highestScore)
highestScore = (*it).score;
}
s << MARK_UV("--");
UVOStringStream headerStream;
headerStream << computerPlayer->name();
headerStream << "'s choices (your play: ";
if (isUrp)
headerStream << "urp";
else
headerStream << ourMoveIndex;
headerStream << ")";
s.width(43);
s << setfill(MARK_UV('-'));
s << left << headerStream.str() << MARK_UV('\n');
s << setfill(MARK_UV(' '));
i = 1;
//.........这里部分代码省略.........
示例7: moves
MoveList SmartBogowin::moves(int nmoves)
{
Stopwatch stopwatch;
if (currentPosition().bag().empty())
{
signalFractionDone(0);
EndgamePlayer endgame;
endgame.setPosition(currentPosition());
return endgame.moves(nmoves);
}
// TODO
// Move this all to an Inferrer class
//
// Generate all moves for all racks opp could have had.
// This can be done efficiently by making a big "rack" out of the bag (with the computer
// player's own rack removed) and generating moves from that big "rack" with some smarts
// added to the move generator to not create moves that have so many tiles not in the
// opp's play that they wouldn't have been possible from any of the racks we're looking
// for. Make a ProbableRackList of racks from which the opp's play is best or nearly
// (really what we're looking for is least bad). Most heavily weight the leaves for which
// the play is as close to optimal as possible (an x-point static mistake), and let the
// weights taper off to zero as the mistakes approach say x+7.
//
// Make the Simulator able to select racks randomly from the ProbableRackList
if (m_parameters.inferring) {
int numPlayers = currentPosition().players().size();
UVcout << "numPlayers: " << numPlayers << endl;
if (numPlayers == 2) {
bool hasPreviousPosition;
GamePosition previous = m_simulator.history().previousPosition(&hasPreviousPosition);
if (hasPreviousPosition) {
UVcout << "previous position:" << endl;
UVcout << previous << endl;
} else {
UVcout << "no previous position" << endl;
}
}
}
UVcout << "SmartBogowin generating move from position:" << endl;
UVcout << currentPosition() << endl;
const int zerothPrune = 33;
int plies = 2;
if (currentPosition().bag().size() <= QUACKLE_PARAMETERS->rackSize() * 2)
plies = -1;
const int initialCandidates = m_additionalInitialCandidates + nmoves;
currentPosition().kibitz(initialCandidates);
m_simulator.setIncludedMoves(m_simulator.currentPosition().moves());
m_simulator.pruneTo(zerothPrune, initialCandidates);
m_simulator.makeSureConsideredMovesAreIncluded();
m_simulator.setIgnoreOppos(false);
MoveList staticMoves = m_simulator.moves(/* prune */ true, /* sort by equity */ false);
m_simulator.moveConsideredMovesToBeginning(staticMoves);
//UVcout << "Bogo static moves: " << staticMoves << endl;
//UVcout << "Bogo considered moves: " << m_simulator.consideredMoves() << endl;
MoveList firstMove;
MoveList simmedMoves;
MoveList::const_iterator it = staticMoves.begin();
firstMove.push_back(*it);
signalFractionDone(0);
m_simulator.setIncludedMoves(firstMove);
m_simulator.simulate(plies, minIterations());
Move best = *m_simulator.moves(/* prune */ true, /* sort by win */ true).begin();
simmedMoves.push_back(best);
double bestbp = bogopoints(best);
//UVcout << "firstMove: " << best << endl;
for (++it; it != staticMoves.end(); ++it)
{
signalFractionDone(max(static_cast<float>(simmedMoves.size()) / static_cast<float>(staticMoves.size()), static_cast<float>(stopwatch.elapsed()) / static_cast<float>(m_parameters.secondsPerTurn)));
if (shouldAbort())
goto sort_and_return;
//UVcout << "best move: " << best << " with " << bestbp << " bogopoints." << endl;
MoveList lookFurther;
lookFurther.push_back(*it);
m_simulator.setIncludedMoves(lookFurther);
m_simulator.simulate(plies, minIterations());
Move move = *m_simulator.moves(/* prune */ true, /* sort by win */ true).begin();
double movebp = bogopoints(move);
//UVcout << "we just simmed " << move << "; bogopoints: " << movebp << endl;
//.........这里部分代码省略.........
示例8: SearchForNewMods
//.........这里部分代码省略.........
{
if (fs::is_directory(*i)) continue;
fs::path pk4path = *i;
// Check extension
idStr extLower = pk4path.extension().string().c_str();
extLower.ToLower();
if (extLower != extension)
{
continue;
}
DM_LOG(LC_MAINMENU, LT_INFO)LOGSTRING("Found %s in FM root folder: %s\r", extension.c_str(), pk4path.string().c_str());
// Does the PK4 file contain a proper description file?
CZipFilePtr pk4file = CZipLoader::Instance().OpenFile(pk4path.string().c_str());
if (pk4file == NULL)
{
DM_LOG(LC_MAINMENU, LT_DEBUG)LOGSTRING("Could not open PK4 in root folder: %s\r", pk4path.string().c_str());
continue; // failed to open zip file
}
// Check if this is a l10n pack, if yes we need to move it to the same mod folder
bool isL10nPack = boost::algorithm::iends_with(pk4path.stem().string(), "_l10n");
DM_LOG(LC_MAINMENU, LT_DEBUG)LOGSTRING("This is a localisation pack: %s\r", isL10nPack ? "yes" : "no");
// Ordinary missions PK4s require a proper description file in it
if (!isL10nPack && !pk4file->ContainsFile(cv_tdm_fm_desc_file.GetString()))
{
DM_LOG(LC_MAINMENU, LT_DEBUG)LOGSTRING("Ignoring PK4 file, no 'darkmod.txt' found inside archive: %s\r", pk4path.string().c_str());
continue; // no darkmod.txt
}
// Deduce the mod folder name based on the PK4 name
idStr modName = pk4path.leaf().string().c_str();
modName.StripPath();
modName.StripFileExtension();
modName.ToLower();
if (modName.IsEmpty()) continue; // error?
// l10n packs get moved in the same mod folder as the mission itself
if (isL10nPack)
{
modName.StripTrailingOnce("_l10n");
}
// Clean modName string from any weird characters
for (int i = 0; i < modName.Length(); ++i)
{
if (idStr::CharIsAlpha(modName[i]) || idStr::CharIsNumeric(modName[i])) continue;
modName[i] = '_'; // replace non-ASCII keys with underscores
}
// Remember this for the user to display
if (!isL10nPack)
{
_newFoundMods.Append(modName);
}
// Assemble the mod folder, e.g. c:/games/doom3/darkmod/fms/outpost
fs::path modFolder = darkmodPath / cv_tdm_fm_path.GetString() / modName.c_str();
// Create the fm folder, if necessary
if (!fs::exists(modFolder))
{
DM_LOG(LC_MAINMENU, LT_DEBUG)LOGSTRING("Mod folder doesn't exist for PK4, creating: %s\r", modFolder.string().c_str());
try
{
fs::create_directory(modFolder);
}
catch (fs::filesystem_error& e)
{
DM_LOG(LC_MAINMENU, LT_DEBUG)LOGSTRING("Exception while creating folder for PK4: %s\r", e.what());
}
}
// Move the PK4 to that folder
fs::path targetPath = modFolder;
if (isL10nPack)
{
targetPath /= (modName + "_l10n.pk4").c_str();
}
else
{
targetPath /= (modName + ".pk4").c_str();
}
// Remember to move this file as soon as we're done here
moveList.push_back(MoveList::value_type(pk4path, targetPath));
}
return moveList;
}