Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <list>
  6.  
  7. using namespace std;
  8.  
  9. const int WIDTH = 12;
  10. const int HEIGHT = 12;
  11. char gameArea[WIDTH][HEIGHT];
  12. int i, j;
  13. int camp = -1;
  14.  
  15. int numberMineSpots;
  16. int gold;
  17. int income;
  18. int opponentGold;
  19. int opponentIncome;
  20. int buildingCount;
  21. int unitCount;
  22.  
  23. void build(string type, int x, int y)
  24. {
  25.     cout << "BUILD " << type << " " << x << " " << y << ";";
  26. }
  27.  
  28. void train(int lvl, int x, int y)
  29. {
  30.     cout << "TRAIN " << lvl << " " << x << " " << y << ";";
  31. }
  32.  
  33. void move(int id, int x, int y)
  34. {
  35.     cout << "MOVE " << id << " " << x << " " << y << ";";
  36. }
  37.  
  38. int checkCamp(int x) //0 == UPLEFT //1 == DOWNRIGHT
  39. {
  40.     if(x == 0)
  41.     {
  42.         return 0;
  43.     }
  44.     else
  45.     {
  46.         return 1;
  47.     }
  48. }
  49.  
  50. void defaultCreateUnit()
  51. {
  52.     if(camp == 0) //QG UPLEFT
  53.     {
  54.         train(1, 1, 0);
  55.         train(1, 0, 1);
  56.     }
  57.     else //QG DOWNRIGHT
  58.     {
  59.         train(1, 10, 11);
  60.         train(1, 11, 10);
  61.     }
  62. }
  63.  
  64. class Building
  65. {
  66.     public:
  67.         int owner;
  68.         int buildingType;
  69.         int x;
  70.         int y;
  71. };
  72.  
  73. class Units
  74. {
  75.     public:
  76.         int owner;
  77.         int unitId;
  78.         int level;
  79.         int x;
  80.         int y;
  81. };
  82.  
  83. int main()
  84. {
  85.     cin >> numberMineSpots; cin.ignore(); //MINE PAS UTILE POUR L'INSTANT
  86.     for (i = 0; i < numberMineSpots; i++) {
  87.         int x;
  88.         int y;
  89.         cin >> x >> y; cin.ignore();
  90.     }
  91.  
  92.     // game loop
  93.     while (1) {
  94.  
  95.         cin >> gold; cin.ignore();
  96.         cin >> income; cin.ignore();
  97.         cin >> opponentGold; cin.ignore();
  98.         cin >> opponentIncome; cin.ignore();
  99.  
  100.         for (i = 0; i < HEIGHT; i++) {
  101.             char line[WIDTH];
  102.             cin >> line; cin.ignore();
  103.             for (j = 0; j < WIDTH; j++)
  104.             {
  105.                 gameArea[j][i] = line[j];
  106.             }
  107.         }
  108.        
  109.         cin >> buildingCount; cin.ignore();
  110.         list<Building> buildList;
  111.  
  112.         for (i = 0; i < buildingCount; i++) {
  113.             Building building;
  114.             cin >> building.owner >> building.buildingType >> building.x >> building.y; cin.ignore();
  115.  
  116.             buildList.emplace_front(new Building{building.owner, building.buildingType, building.x, building.y});
  117.  
  118.             if(building.buildingType == 0 && building.owner == 0) //si mon QG check sa pos
  119.             {
  120.                 camp = checkCamp(building.x);
  121.             }
  122.         }
  123.        
  124.         cin >> unitCount; cin.ignore();
  125.  
  126.         for (i = 0; i < unitCount; i++) {
  127.             int owner;
  128.             int unitId;
  129.             int level;
  130.             int x;
  131.             int y;
  132.             cin >> owner >> unitId >> level >> x >> y; cin.ignore();
  133.         }
  134.  
  135.         defaultCreateUnit();
  136.         cout << "WAIT" << endl;
  137.     }
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement