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


C++ Hand::isDead方法代码示例

本文整理汇总了C++中Hand::isDead方法的典型用法代码示例。如果您正苦于以下问题:C++ Hand::isDead方法的具体用法?C++ Hand::isDead怎么用?C++ Hand::isDead使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Hand的用法示例。


在下文中一共展示了Hand::isDead方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AI

void Game::AI()
{
	//AI works by:
	//1. using a killing move (if any)
	//2. giving the largest number of digits/points to opponent
	Hand *usePtr = m_gameWorld->tLeft();
	Hand *tarPtr = m_gameWorld->bLeft();
	int largestSum = 0;
	if (m_gameWorld->OFOn())
	{
		int sum = 0;
		if (!usePtr->isDead())
		{
			if (!tarPtr->isDead())
			{
				largestSum = m_gameWorld->tLeft()->numDigits() + m_gameWorld->bLeft()->numDigits() % 5;
				if (largestSum == 0) 
				{
					m_gameWorld->attack(usePtr,tarPtr); return;
				}
			}
			if (!m_gameWorld->bRight()->isDead())
			{
				sum = m_gameWorld->tLeft()->numDigits() + m_gameWorld->bRight()->numDigits() % 5;
				if (sum == 0) 
				{
					m_gameWorld->attack(usePtr,m_gameWorld->bRight()); return;
				}
				if (sum > largestSum)
				{
					largestSum = sum;
					tarPtr = m_gameWorld->bRight();
				}
			}
		}
		if (!m_gameWorld->tRight()->isDead())
		{
			if (!m_gameWorld->bLeft()->isDead())
			{
				sum = m_gameWorld->tRight()->numDigits() + m_gameWorld->bLeft()->numDigits() % 5;
				if (sum == 0) 
				{
					m_gameWorld->attack(m_gameWorld->tRight(),m_gameWorld->bLeft()); return;
				}
				if (sum > largestSum)
				{
					largestSum = sum; 
					usePtr = m_gameWorld->tRight();
					tarPtr = m_gameWorld->bLeft();
				}
			}
			if (!m_gameWorld->bRight()->isDead())
			{
				sum = m_gameWorld->tRight()->numDigits() + m_gameWorld->bRight()->numDigits() % 5;
				if (sum == 0) 
				{
					m_gameWorld->attack(m_gameWorld->tRight(),m_gameWorld->bRight()); return;
				}
				if (sum > largestSum)
				{
					largestSum = sum;
					usePtr = m_gameWorld->tRight();
					tarPtr = m_gameWorld->bRight();
				}
			}
		}
	}
	else
	{
		int sum = 0;
		if (!usePtr->isDead())
		{
			if (!tarPtr->isDead())
				largestSum = m_gameWorld->tLeft()->numDigits() + m_gameWorld->bLeft()->numDigits();
			if (!m_gameWorld->bRight()->isDead())
			{
				sum = m_gameWorld->tLeft()->numDigits() + m_gameWorld->bRight()->numDigits();
				if (sum > largestSum)
				{
					largestSum = sum;
					tarPtr = m_gameWorld->bRight();
				}
			}
		}
		if (!m_gameWorld->tRight()->isDead())
		{
			if (!m_gameWorld->bLeft()->isDead())
			{
				sum = m_gameWorld->tRight()->numDigits() + m_gameWorld->bLeft()->numDigits();
				if (sum > largestSum)
				{
					largestSum = sum; 
					usePtr = m_gameWorld->tRight();
					tarPtr = m_gameWorld->bLeft();
				}
			}
			if (!m_gameWorld->bRight()->isDead())
			{
				sum = m_gameWorld->tRight()->numDigits() + m_gameWorld->bRight()->numDigits();
				if (sum > largestSum)
//.........这里部分代码省略.........
开发者ID:ayrc,项目名称:chopsticks_game,代码行数:101,代码来源:Game.cpp


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