本文整理汇总了C++中Moves::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ Moves::push_back方法的具体用法?C++ Moves::push_back怎么用?C++ Moves::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Moves
的用法示例。
在下文中一共展示了Moves::push_back方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: valid_moves
Moves valid_moves() const {
int i = space_index();
int row = i / 4;
int col = i % 4;
Moves cand;
if (row != 0)
cand.push_back('U');
if (row != 3)
cand.push_back('D');
if (col != 0)
cand.push_back('L');
if (col != 3)
cand.push_back('R');
return cand;
}
示例2: generateOpening
Moves MoveGenerator::generateOpening(const Board& board) const
{
Moves result;
if(board.getIdleCount() == 0)
{
QMessageBox::critical(0, "error", "idle == 0");
return result;
}
for(int i=0; i<23; ++i)
{
if(board.isEmpty(i))
{
Board next = board.makeChild(); // a clone
next.setManAt(i, board.getSelfColor());
if(next.closeMill(i))
{
Moves removeMoves = generateRemove(next, board.getOpponentColor()); // remove 1 opponent chessman
copy(removeMoves.begin(), removeMoves.end(), back_inserter(result));
}
else
result.push_back(next);
}
}
return result;
}
示例3: moves
const ConnectThree::Move ConnectThree::CheckTwoOther(const std::bitset<3>& is_player_human) const
{
const Moves moves(GetAllPossibleMoves());
const int nMoves = moves.size();
if (nMoves==0) return CreateInvalidMove();
{
//Get anti-human moves
Moves v;
BOOST_FOREACH(const Move& m, moves)
{
assert(CanDoMove(m));
//Player is human
if (is_player_human[boost::tuples::get<2>(m)])
v.push_back(m);
}
//If there are anti-player moves, choose one at random
if (!v.empty())
{
const Move m = v[std::rand() % v.size()];
assert(CanDoMove(m));
return
boost::tuples::make_tuple(
boost::tuples::get<0>(m),
boost::tuples::get<1>(m),
boost::tuples::get<2>(m));
}
}
示例4:
Moves BoardC4::get_possible_moves(Token player) const {
Moves moves;
for (Size column=0; column<width; column++) {
if (tokens[column]<=token_for_columns[column]) moves.push_back(new MoveC4(player,column));
}
return moves;
}
示例5: AddBranch
/*-----------------------------------------------------------------------------*/
void MoveKif::AddBranch(Moves* parent, const MoveKif& move)
{
this->branches_.emplace_back(new Moves());
Moves* moves = this->branches_.back().get();
moves->set_parent(parent);
moves->push_back(move);
}
示例6: build_path
void build_path(ull_t v, const Searched & searched, Moves & steps) {
Searched::const_iterator it = searched.find(v);
while (it != searched.end()) {
const State & s = it->second;
steps.push_back(s.step);
it = searched.find(s.parent);
}
//pop up the first step, which must be 0, rather than one of U,D,L,R
steps.pop_back();
reverse(steps.begin(), steps.end());
}
示例7: generateRemove
Moves MoveGenerator::generateRemove(const Board& old, QChar color) const
{
Moves result;
for(int i=0; i<23; ++i)
{
if(old.getManAt(i) == color)
{
if(!old.closeMill(i))
{
// DO NOT use old.makeChild
// next is a semi-finished product of a move
Board next = old;
next.setManAt(i, 'x');
result.push_back(next);
}
}
}
if(result.empty()) // no possible remove
result.push_back(old);
return result;
}
示例8: generateHopping
Moves MoveGenerator::generateHopping(const Board& board) const
{
Moves result;
for(int from=0; from<23; ++from)
if(board.getManAt(from) == board.getSelfColor())
{
for(int to=0; to<23; ++to)
if(board.isEmpty(to))
{
Board next = board.makeChild();
next.move(from, to);
if(next.closeMill(to))
{
Moves removeMoves = generateRemove(next, board.getOpponentColor());
copy(removeMoves.begin(), removeMoves.end(), back_inserter(result));
}
else
result.push_back(next);
}
}
return result;
}
示例9: generateMove
Moves MoveGenerator::generateMove(const Board& board) const
{
Moves result;
for(int from=0; from<23; ++from)
if(board.getManAt(from) == board.getSelfColor())
{
Neighbors neighbors = Board::getNeighbors(from);
for(Neighbors::iterator it = neighbors.begin(); it != neighbors.end(); ++it)
if(board.isEmpty(*it))
{
Board next = board.makeChild();
next.move(from, *it);
if(next.closeMill(*it))
{
Moves removeMoves = generateRemove(next, board.getOpponentColor());
copy(removeMoves.begin(), removeMoves.end(), back_inserter(result));
}
else
result.push_back(next);
}
}
return result;
}