本文整理汇总了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)
//.........这里部分代码省略.........