Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- using namespace std;
- const int mapSize = 15;
- bool inMap(string grid[],int x, int y)
- {
- return x >=0 && x < mapSize && y >=0 && y < mapSize && grid[x][y] == '.';
- }
- int main()
- {
- string grid[mapSize];
- int width;
- int height;
- int myId;
- cin >> width >> height >> myId; cin.ignore();
- for (int i = 0; i < height; i++) {
- string line;
- getline(cin, line);
- cerr<<line<<endl;
- grid[i] = line;
- }
- int xp, yp;
- for(int y = 0; y < mapSize; y++)
- {
- for(int x = 0; x < mapSize; x++)
- {
- if(grid [y][x] == '.')
- {
- xp = x;
- yp = y;
- }
- }
- }
- cout <<xp<< " "<<yp << endl;
- // game loop
- while (1) {
- int x;
- int y;
- int myLife;
- int oppLife;
- int torpedoCooldown;
- int sonarCooldown;
- int silenceCooldown;
- int mineCooldown;
- cin >> x >> y >> myLife >> oppLife >> torpedoCooldown >> sonarCooldown >> silenceCooldown >> mineCooldown; cin.ignore();
- string sonarResult;
- cin >> sonarResult; cin.ignore();
- string opponentOrders;
- getline(cin, opponentOrders);
- grid[y][x] = '?';
- if(inMap(grid, x, y-1))
- {
- cout << "MOVE N TORPEDO" << endl;
- }
- else if(inMap(grid, x+1, y))
- {
- cout << "MOVE E TORPEDO" << endl;
- }
- else if(inMap(grid, x, y+1))
- {
- cout << "MOVE S TORPEDO" << endl;
- }
- else if(inMap(grid, x-1, y))
- {
- cout << "MOVE w TORPEDO" << endl;
- }
- else
- {
- cout << "SURFACE" << endl;
- for(int j = 4; j < 11; j++)
- {
- for(int i = 4; i < 11; i++)
- {
- if(grid[j][i] == '?')
- {
- grid[j][i] = '.'
- }
- }
- }
- grid[j][i] = '?'
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement