Code:aiMove::aiBomb() { // 13 == Miss; // 11 == Already fire apon; m_oldRandY = m_randY; m_oldRandX = m_randX; whichBoard->bombCoords(randX, randY); do { short int bombCoord = whichBoard->bombCoords(m_randX, m_randY); if (!lastMoveHit) { m_randY = 1 + rand() % (m_xCoord - 1); m_randX = 1 + rand() % (m_yCoord - 1); short int bombCoord = whichBoard->bombCoords(randX, randY); if (bombCoord != 13 && bombCoord != 11 && bombCoord => 10) { m_lastMoveHit = 1; } else { m_lastMoveHit = 0; } } else { // If we hit something last time, but didn't sink it // we need to check around that position.. // Gawd this hurts my head.. } } while (bombCoord == 11);
Where you see the comments, I need to implement some system of checking around the location of the ship.. I don't really require code.. as that would require me to post most of my OO Battleship game (~900 lines)
I can almost get it.. but I've put this project aside for a week because of this difficulty; so I guess it's time to ask for help.