本文整理汇总了C++中Stone::setPlayer方法的典型用法代码示例。如果您正苦于以下问题:C++ Stone::setPlayer方法的具体用法?C++ Stone::setPlayer怎么用?C++ Stone::setPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stone
的用法示例。
在下文中一共展示了Stone::setPlayer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: step
/*
core function, drives all action on the board each turn
param player: the player whose turn needs to be executed
param x,y: coordinates of the stone to be placed
(note, should be validated with isValidMove() before
step is called.
return int: a signal to show the turn has completed succesfully
*/
int GoBoard::step( Player player, int x, int y )
{
Player currPlayer = player;
Player Enemy;
Stone *currStone;
bool KOflag1 = false;
Group playerGroup;
std::string playerName;
//establish the opposing player for reference
if( currPlayer == BLACK )
{
Enemy = WHITE;
}
else
{
Enemy = BLACK;
}
//get the stone at x, y
currStone = grid[x][y];
//set the piece to its new player
currStone->setPlayer( currPlayer );
//test and possibly kill enemies
KOflag1 = effectEnemies( Enemy, x, y ); //set the Ko flag to the output
//initialize the attributes of the group for the current player
playerGroup.size = 0;
playerGroup.liberties = 0;
playerGroup.player = currPlayer;
playerGroup.owner = (Player)EMPTY;
//call to determine the attributes
playerGroup = getGroup( x, y, playerGroup );
//Debug message to see if the liberties, size, and owner are counted correctly
//std::cout<<"Size: "<<playerGroup.size<<" Liberties: "<<playerGroup.liberties<<" Player: "<<playerGroup.player<<" Owner: "<<playerGroup.owner<<std::endl;
//test if player killed themselves
if( playerGroup.liberties == 0 )
{
clearGroup( currPlayer, x, y );
}
//Determine if there is not a KO
if( playerGroup.liberties != 1 || playerGroup.size != 1 || !KOflag1 )
{
//The KO positions are set when an enemy is killed,
//if a KO is not possible then the positions need to be reset
//to an unreachable position -1,-1 before the step finishes
koPosX = -1;
koPosY = -1;
}
//clear all our Counted marks
clearMarks();
//return to signal that the player made a move
return 1;
}