当前位置: 首页>>代码示例>>C++>>正文


C++ MoveList::insert方法代码示例

本文整理汇总了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 |) */
//.........这里部分代码省略.........
开发者ID:weidendo,项目名称:qenolaba,代码行数:101,代码来源:Board.cpp


注:本文中的MoveList::insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。