shoot 12/14 bool Player:shoot(int dir) { m_age++; if (rand() % 3 == 0) // miss with 1/3 probability { return false; } else if (dir == UP) { for (int i = 0; i nRobotsAt(m_row - i, m_col) > 0 && m_row -...


write the following for loop as a while loop


shoot<br>12/14<br>bool Player:shoot(int dir)<br>{<br>m_age++;<br>if (rand() % 3 == 0) // miss with 1/3 probability<br>{<br>return false;<br>}<br>else if (dir == UP)<br>{<br>for (int i = 0; i < MAXSHOTLEN + 1; i++)<br>{<br>if (m_arena->nRobotsAt(m_row - i, m_col) > 0 && m_row - i > 0)<br>{<br>m_arena->damageRobotAt(m_row - i, m_col);<br>return true;<br>}<br>}<br>}<br>><br>

Extracted text: shoot 12/14 bool Player:shoot(int dir) { m_age++; if (rand() % 3 == 0) // miss with 1/3 probability { return false; } else if (dir == UP) { for (int i = 0; i < maxshotlen="" +="" 1;="" i++)="" {="" if="" (m_arena-="">nRobotsAt(m_row - i, m_col) > 0 && m_row - i > 0) { m_arena->damageRobotAt(m_row - i, m_col); return true; } } } >

Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here