本文整理汇总了C++中MoveList::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ MoveList::insert方法的具体用法?C++ MoveList::insert怎么用?C++ MoveList::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoveList
的用法示例。
在下文中一共展示了MoveList::insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateFieldMoves
/* generate moves starting at field <startField> */
void Board::generateFieldMoves(int startField, MoveList& list)
{
int d, dir, c, actField;
bool left, right;
int opponent = (color == color1) ? color2 : color1;
Q_ASSERT( field[startField] == color );
/* 6 directions */
for(d=1;d<7;d++) {
dir = direction[d];
/* 2nd field */
c = field[actField = startField+dir];
if (c == free) {
/* (c .) */
list.insert(startField, d, Move::move1);
continue;
}
if (c != color)
continue;
/* 2nd == color */
left = (field[startField+direction[d-1]] == free);
if (left) {
left = (field[actField+direction[d-1]] == free);
if (left)
/* 2 left */
list.insert(startField, d, Move::left2);
}
right = (field[startField+direction[d+1]] == free);
if (right) {
right = (field[actField+direction[d+1]] == free);
if (right)
/* 2 right */
list.insert(startField, d, Move::right2);
}
/* 3rd field */
c = field[actField += dir];
if (c == free) {
/* (c c .) */
list.insert(startField, d, Move::move2);
continue;
}
else if (c == opponent) {
/* 4th field */
c = field[actField += dir];
if (c == free) {
/* (c c o .) */
list.insert(startField, d, Move::push1with2);
}
else if (c == out) {
/* (c c o |) */
list.insert(startField, d, Move::out1with2);
}
continue;
}
if (c != color)
continue;
/* 3nd == color */
if (left) {
if (field[actField+direction[d-1]] == free)
/* 3 left */
list.insert(startField, d, Move::left3);
}
if (right) {
if (field[actField+direction[d+1]] == free)
/* 3 right */
list.insert(startField, d, Move::right3);
}
/* 4th field */
c = field[actField += dir];
if (c == free) {
/* (c c c .) */
list.insert(startField, d, Move::move3);
continue;
}
if (c != opponent)
continue;
/* 4nd == opponent */
/* 5. field */
c = field[actField += dir];
if (c == free) {
/* (c c c o .) */
list.insert(startField, d, Move::push1with3);
continue;
}
else if (c == out) {
/* (c c c o |) */
//.........这里部分代码省略.........