#include #include #include #include #include #include #include #include #include #define DN 15 #define LB 10 #define SM "MISSED" #define HT 0 #define BT 1 using namespace std; int dx[]={0,1}; int dy[]={1,0}; map shipLenght; vector shipTypes; class Board { private: map shots; bool isShot[DN][DN]; string type[DN][DN]; public: bool validate(int x,int y) { if(x<1 || y<1 || x>LB || y>LB) return 0; return 1; } Board() { for(int i=1; i<=LB; ++i) for(int j=1; j<=LB; ++j) { isShot[i][j]=0; type[i][j]=SM; } for(int i=0; i1) return 0; for(int i=0; i > moves; void initMoves() { for(int i=1; i<=LB; ++i) for(int j=1; j<=LB; ++j) { moves.push_back(make_pair(i,j)); } random_shuffle(moves.begin(),moves.end()); } int main(){ srand(time(NULL)); shipLenght["destroyer"]=2; shipLenght["cruiser"]=3; shipLenght["submarine"]=3; shipLenght["battleship"]=4; shipLenght["aircraft carrier"]=5; shipTypes.push_back("destroyer"); shipTypes.push_back("cruiser"); shipTypes.push_back("submarine"); shipTypes.push_back("battleship"); shipTypes.push_back("aircraft carrier"); Board *b=new Board(); for(int i=0; isetShip(x,y,o,shipTypes[i])) { x=rand()%LB+1; y=rand()%LB+1; o=rand()%2; } cout<