int countNumber(int *mat,int begX, int begY,int x,int y)
{
	
	if(x == begX && y ==begY)
	  return 1;
	
	return  countNumber(mat, begX+1,begY,x,y) + countNumber(mat, begX,begY+1,x,y);
}
Example #2
0
GameResult Rule::checkSum(int row,int column,PieceSide side,GomokuData data,bool hasBan)
{
	int value = (int)side;

	for(int i = 0; i< 4 ; i ++)
	{
		int count = countNumber(row,column,FourDirections[i],value,data);

		if(side == PieceSide::WhiteSide)
		{
			if(count >= 5 )
			{
				// 白棋赢了
				return GameResult::WhiteWin;
			}
		}
		else
		{
			if(count > 5 && hasBan)
			{
				// 黑棋输了!
				return GameResult::BlackBan;
			}
			else if(count == 5)
			{
				// 黑棋赢了
				return GameResult::BlackWin;
			}
		}
	}

	return NoResult;
}