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;
- struct Unit
- {
- int id;
- int level;
- int x,y;
- };
- //struktura
- struct Grid
- {
- char state;
- int level = 0;
- };
- struct Pos
- {
- int x, y;
- };
- int level;
- int main()
- {
- int numberMineSpots;
- cin >> numberMineSpots; cin.ignore();
- for (int i = 0; i < numberMineSpots; i++) {
- int x;
- int y;
- cin >> x >> y; cin.ignore();
- }
- // game loop
- while (1) {
- int gold;
- cin >> gold; cin.ignore();
- int income;
- cin >> income; cin.ignore();
- int opponentGold;
- cin >> opponentGold; cin.ignore();
- int opponentIncome;
- cin >> opponentIncome; cin.ignore();
- vector<vector<Grid>> grid; //pakeiciau
- for (int i = 0; i < 12; i++) {
- string line;
- cin >> line; cin.ignore();
- grid.push_back({}); //pakeiciau
- for(int j = 0; j < 12; j++)//pakeiciau
- {
- grid[i].push_back({line[j], 0});//pakeiciau
- }
- }
- Pos enemyHQ;
- int buildingCount;
- cin >> buildingCount; cin.ignore();
- for (int i = 0; i < buildingCount; i++) {
- int owner;
- int buildingType;
- int x;
- int y;
- cin >> owner >> buildingType >> x >> y; cin.ignore();
- if(owner == 1 && buildingType == 0)
- {
- enemyHQ.x = x;
- enemyHQ.y = y;
- }
- }
- vector<Unit> units;
- vector<Unit> enUnits; //pakeiciau
- int unitCount;
- cin >> unitCount; cin.ignore();
- for (int i = 0; i < unitCount; i++) {
- int owner;
- int unitId;
- int level;
- int x;
- int y;
- cin >> owner >> unitId >> level >> x >> y; cin.ignore();
- if(owner == 0)
- {
- units.push_back({unitId, level, x, y});
- }
- else
- {
- enUnits.push_back({unitId, level, x, y}); //pakeiciau
- grid[y][x].level = level; //pakeiciau
- }
- }
- cout << "WAIT";
- for(int i = 0; i < units.size(); i++)
- {
- cout << ";MOVE " << units[i].id << " " << enemyHQ.x << " " << enemyHQ.y;
- }
- for(int i = 0; i < 12; i++)
- {
- for(int j = 0; j < 12; j++)
- {
- if(grid[i][j] == 'O')
- {
- int tempX = j + 1;
- int tempY = i;
- if(tempX < 12 && (grid[tempY][tempX].state == '.' || grid[tempY][tempX] == 'x' || grid[tempY][tempX] == 'X' ) && gold >= 10 && level <= 1 )
- {
- cout << ";TRAIN 1 " << tempX << " " << tempY;
- grid[tempY][tempX] == 'O';
- gold -= 10 ;
- }
- else if(tempX < 12 && (grid[tempY][tempX] == '.' || grid[tempY][tempX] == 'x' || grid[tempY][tempX] == 'X' ) && gold >= 20 && level == 1 ) {
- cout << ";TRAIN 2 " << tempX << " " << tempY;
- grid[tempY][tempX] == 'O';
- gold -= 20 ;
- }
- else if(tempX < 12 && (grid[tempY][tempX] == '.' || grid[tempY][tempX] == 'x' || grid[tempY][tempX] == 'X' ) && gold >= 30 && level >= 2 ) {
- cout << ";TRAIN 3 " << tempX << " " << tempY;
- grid[tempY][tempX] == 'O';
- gold -= 30 ;
- }
- tempX = j - 1;
- tempY = i;
- if(tempX >= 0 && (grid[tempY][tempX] == '.' || grid[tempY][tempX] == 'x' || grid[tempY][tempX] == 'X' ) && gold >= 10 && level <= 1)
- {
- cout << ";TRAIN 1 " << tempX << " " << tempY;
- grid[tempY][tempX] == 'O';
- gold -= 10 ;
- }
- else if(tempX >= 0 && (grid[tempY][tempX] == '.' || grid[tempY][tempX] == 'x' || grid[tempY][tempX] == 'X' ) && gold >= 20 && level == 1 ) {
- cout << ";TRAIN 2 " << tempX << " " << tempY;
- grid[tempY][tempX] == 'O';
- gold -= 20 ;
- }
- else if(tempX >= 0 && (grid[tempY][tempX] == '.' || grid[tempY][tempX] == 'x' || grid[tempY][tempX] == 'X' ) && gold >= 30 && level >= 2 ) {
- cout << ";TRAIN 3 " << tempX << " " << tempY;
- grid[tempY][tempX] == 'O';
- gold -= 30 ;
- }
- tempX = j;
- tempY = i - 1;
- if(tempY >= 0 && (grid[tempY][tempX] == '.' || grid[tempY][tempX] == 'x' || grid[tempY][tempX] == 'X' ) && gold >= 10 && level <= 1)
- {
- cout << ";TRAIN 1 " << tempX << " " << tempY;
- grid[tempY][tempX] == 'O';
- gold -= 10 ;
- }
- else if(tempY >= 0 && (grid[tempY][tempX] == '.' || grid[tempY][tempX] == 'x' || grid[tempY][tempX] == 'X' ) && gold >= 20 && level == 1 ) {
- cout << ";TRAIN 2 " << tempX << " " << tempY;
- grid[tempY][tempX] == 'O';
- gold -= 20 ;
- }
- else if(tempY >= 0 && (grid[tempY][tempX] == '.' || grid[tempY][tempX] == 'x' || grid[tempY][tempX] == 'X' ) && gold >= 30 && level >= 2 ) {
- cout << ";TRAIN 3 " << tempX << " " << tempY;
- grid[tempY][tempX] == 'O';
- gold -= 30 ;
- }
- tempX = j;
- tempY = i + 1;
- if(tempY < 12 && (grid[tempY][tempX] == '.' || grid[tempY][tempX] == 'x' || grid[tempY][tempX] == 'X' ) && gold >= 10 && level <= 1)
- {
- cout << ";TRAIN 1 " << tempX << " " << tempY;
- grid[tempY][tempX] == 'O';
- gold -= 10 ;
- }
- else if(tempY < 12 && (grid[tempY][tempX] == '.' || grid[tempY][tempX] == 'x' || grid[tempY][tempX] == 'X' ) && gold >= 20 && level == 1 ) {
- cout << ";TRAIN 2 " << tempX << " " << tempY;
- grid[tempY][tempX] == 'O';
- gold -= 20 ;
- }
- else if(tempY < 12 && (grid[tempY][tempX] == '.' || grid[tempY][tempX] == 'x' || grid[tempY][tempX] == 'X' ) && gold >= 30 && level >= 2) {
- cout << ";TRAIN 3 " << tempX << " " << tempY;
- grid[tempY][tempX] == 'O';
- gold -= 30 ;
- }
- }
- }
- }
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement