Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.51 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <cmath>
  6.  
  7. using namespace std;
  8.  
  9. /**
  10.  * Made with love by AntiSquid, Illedan and Wildum.
  11.  * You can help children learn to code while you participate by donating to CoderDojo.
  12.  **/
  13.  
  14. struct Entity{
  15.     int unitId;
  16.     int team;
  17.     string unitType; // UNIT, HERO, TOWER, can also be GROOT from wood1
  18.     int x;
  19.     int y;
  20.     int attackRange;
  21.     int health;
  22.     int maxHealth;
  23.     int shield; // useful in bronze
  24.     int attackDamage;
  25.     int movementSpeed;
  26.     int stunDuration; // useful in bronze
  27.     int goldValue;
  28.     int countDown1; // all countDown and mana variables are useful starting in bronze
  29.     int countDown2;
  30.     int countDown3;
  31.     int mana;
  32.     int maxMana;
  33.     int manaRegeneration;
  34.     string heroType; // DEADPOOL, VALKYRIE, DOCTOR_STRANGE, HULK, IRONMAN
  35.     int isVisible; // 0 if it isn't
  36.     int itemsOwned; // useful from wood1
  37. };
  38.  
  39. struct Item{
  40.     string itemName; // contains keywords such as BRONZE, SILVER and BLADE, BOOTS connected by "_" to help you sort easier
  41.     int itemCost; // BRONZE items have lowest cost, the most expensive items are LEGENDARY
  42.     int damage; // keyword BLADE is present if the most important item stat is damage
  43.     int health;
  44.     int maxHealth;
  45.     int mana;
  46.     int maxMana;
  47.     int moveSpeed; // keyword BOOTS is present if the most important item stat is moveSpeed
  48.     int manaRegeneration;
  49.     int isPotion; // 0 if it's not instantly consumed
  50. };
  51.  
  52. void wait() {
  53.     cout << "WAIT" << endl;}
  54. void move(int x, int y){
  55.     cout << "MOVE " << x << ' ' << y << endl;}
  56. void attack(int id){
  57.     cout << "ATTACK " << id << endl;}
  58. void attack_nearest(string type){
  59.     cout << "ATTACK_NEAREST " << type << endl;}
  60. void move_attack(int x, int y, string id){
  61.     cout << "MOVE ATTACK " << x << ' ' << y << ' ' << id << endl;}
  62. void buyItem(string itemName){
  63.     cout << "BUY " << itemName << endl;}
  64. void sellItem(string itemName){
  65.     cout << "SELL " << itemName << endl;}
  66. int main()
  67. {
  68.    
  69.    
  70.     int myTeam;
  71.     cin >> myTeam; cin.ignore();
  72.     int bushAndSpawnPointCount; // useful from wood1, represents the number of bushes and the number of places where neutral units can spawn
  73.     cin >> bushAndSpawnPointCount; cin.ignore();
  74.     for (int i = 0; i < bushAndSpawnPointCount; i++) {
  75.         string entityType; // BUSH, from wood1 it can also be SPAWN
  76.         int x;
  77.         int y;
  78.         int radius;
  79.         cin >> entityType >> x >> y >> radius; cin.ignore();
  80.     }
  81.    
  82.     int itemCount; // useful from wood2
  83.     cin >> itemCount; cin.ignore();
  84.     vector<Item> item;
  85.     for (int i = 0; i < itemCount; i++) {
  86.         cin >> item[i].itemName >> item[i].itemCost >> item[i].damage >> item[i].health >> item[i].maxHealth >> item[i].mana >> item[i].maxMana >> item[i].moveSpeed >> item[i].manaRegeneration >> item[i].isPotion; cin.ignore();
  87.         }
  88.     // game loop
  89.     while (1) {
  90.         int gold;
  91.         cin >> gold; cin.ignore();
  92.         int enemyGold;
  93.         cin >> enemyGold; cin.ignore();
  94.         int roundType; // a positive value will show the number of heroes that await a command
  95.         cin >> roundType; cin.ignore();
  96.         int entityCount;
  97.         cin >> entityCount; cin.ignore();
  98.        
  99.         Entity entity[entityCount];
  100.         for (int i = 0; i < entityCount; i++) {        
  101.             cin >> entity[i].unitId >> entity[i].team >> entity[i].unitType >> entity[i].x >> entity[i].y >> entity[i].attackRange >> entity[i].health >> entity[i].maxHealth >> entity[i].shield >> entity[i].attackDamage >> entity[i].movementSpeed >> entity[i].stunDuration >> entity[i].goldValue >> entity[i].countDown1 >> entity[i].countDown2 >> entity[i].countDown3 >> entity[i].mana >> entity[i].maxMana >> entity[i].manaRegeneration >> entity[i].heroType >> entity[i].isVisible >> entity[i].itemsOwned; cin.ignore();
  102.            
  103.        
  104.         if(roundType < 0)
  105.             wait();
  106.         else
  107.             attack_nearest("HERO");
  108.         }
  109.     }
  110. }
  111.  
  112. /* NOTES
  113.     TODO:
  114. Add remember current heroes-able-to-be-controlled id;
  115.     DONE:
  116. Added simple functions for cout (makes life easier)
  117. Added structs
  118.  
  119.  
  120.     // Write an action using cout. DON'T FORGET THE "<< endl"  
  121.     // To debug: cerr << "Debug messages..." << endl;
  122.  
  123.  
  124.     // If roundType has a negative value then you need to output a Hero name, such as "DEADPOOL" or "VALKYRIE".
  125.     // Else you need to output roundType number of any valid action, such as "WAIT" or "ATTACK unitId"
  126. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement