Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.25 KB | None | 0 0
  1. int auto_warTotalBattles(int plan, int remaining)
  2. {
  3.     // |plan| is a 6-bit bitmask where the lowest bit is a 1
  4.     // if we finish the first quest, etc.
  5.  
  6.     int total_battles = 0;
  7.     int completed_quests = 0;
  8.  
  9.     void fightUntilRemaining(int target_remaining)
  10.     {
  11.         int to_kill = max(0, remaining-target_remaining);
  12.         int kills_per_battle = auto_warKillsPerBattle(completed_quests);
  13.         int battles = ceil(to_kill.to_float()/kills_per_battle);
  14.  
  15.         auto_log_warning("to_kill = " + to_kill, "red");
  16.         auto_log_warning("kills_per_battle = " + kills_per_battle, "red");
  17.         auto_log_warning("battles = " + battles, "red");
  18.  
  19.         total_battles += battles;
  20.         remaining -= battles * kills_per_battle;
  21.         auto_log_warning("remaining = " + remaining, "red");
  22.     }
  23.  
  24.     // 3 quests are accessible simultaneously.
  25.     completed_quests += plan&1;
  26.     completed_quests += (plan>>1)&1;
  27.     completed_quests += (plan>>2)&1;
  28.  
  29.     fightUntilRemaining(1000-64);
  30.  
  31.     completed_quests += (plan>>3)&1;
  32.  
  33.     fightUntilRemaining(1000-192);
  34.  
  35.     completed_quests += (plan>>4)&1;
  36.  
  37.     fightUntilRemaining(1000-458);
  38.  
  39.     completed_quests += (plan>>5)&1;
  40.  
  41.     fightUntilRemaining(0);
  42.  
  43.     return total_battles;
  44. }
  45.  
  46. int auto_warTotalBattles(int plan)
  47. {
  48.     return auto_warTotalBattles(plan, auto_warEnemiesRemaining());
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement