本文整理汇总了C++中BinaryHeap::interact_with_Soldier方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryHeap::interact_with_Soldier方法的具体用法?C++ BinaryHeap::interact_with_Soldier怎么用?C++ BinaryHeap::interact_with_Soldier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryHeap
的用法示例。
在下文中一共展示了BinaryHeap::interact_with_Soldier方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processTurn
//Will pick a soldier from our remaining soldiers alive.
//
void processTurn(BinaryHeap<soldier>& heap, vector<int>& soldiers, int& remaining_Soldiers)
{
int position_of_Soldier;
if(remaining_Soldiers == 1) position_of_Soldier = 0;//A condition to ensure kill a soldier is not called when only one soldier is left
else position_of_Soldier = rand() % remaining_Soldiers;
bool target_Condition;
soldier nextUp = heap.findMin(); //Return the smallest value; our next up.
target_Condition = heap.interact_with_Soldier(nextUp.return_Faction(), soldiers[position_of_Soldier]);//False if alive, true if killed
if(target_Condition && nextUp.return_Faction() ) kill_a_Soldier(soldiers, remaining_Soldiers, position_of_Soldier);//Will removed the soldier if dead.
else if(target_Condition && !(nextUp.return_Faction()) ) {//Will invigorate if a soldier is killed, AND the soldier target was a Persian
kill_a_Soldier(soldiers, remaining_Soldiers, position_of_Soldier);//Remove the soldier as per usual
invigorate(heap, soldiers, remaining_Soldiers);//function invigorate will go through the entire array to invigorate soldiers.
}
}