Guest User

civdos AI continent policy logic v1.0

a guest
Aug 5th, 2020
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.07 KB | None | 0 0
  1. //CIVDOS: AI CONTINENT POLICY (v 1.0)
  2. //from FUN_basic_actions_for_current_civ(civ)
  3. //...omitted...
  4.     //STRATEGY FOR CONTINENTS...
  5.     //25fb:053b
  6.     max_cities_on_cont = -1;
  7.     for (i = 1; i < 15; i++) //continents
  8.     {
  9.         att_desire_points = 0; //how much we want to attack...
  10.         def_desire_points = 0; //how much we want to defend...
  11.         policy_flags = 0;
  12.         total_cit_per_cont = 0;
  13.         total_def_per_cont = 0;
  14.         for (j = 1; j < 8; j++) //civs
  15.         {
  16.             //25fb:05ee
  17.             if (defence_per_cont[j][i] != 0
  18.             && (attack_per_cont[civ][i] < attack_per_cont[j][i] || city_counter_per_cont[j][i] != 0)
  19.             && ((diplomacy_status[civ][j]&3) == 1 || (diplomacy_status[civ][j]&x0100) != 0)) //contact and war OR unknown dipl. status...
  20.             {
  21.                 //25fb:064f
  22.                 if (defence_per_cont[j][i] < attack_per_cont[civ][i]
  23.                 || attack_per_cont[j][i] < defence_per_cont[civ][i]
  24.                 || city_counter_per_cont[civ][i] == 0)
  25.                 {
  26.                     att_desire_points++;
  27.                 }
  28.                 else
  29.                     def_desire_points++;
  30.             }
  31.             if (defence_per_cont[j][i] != 0 && j == player_civ //PLAYER forces here!
  32.             && (diplomacy_status[civ][j]&2) != 0 //peace with player
  33.             && attack_per_cont[civ][i]/2+defence_per_cont[civ][i] < attack_per_cont[j][i])
  34.             {
  35.                 def_desire_points++;
  36.             }
  37.             total_def_per_cont += defence_per_cont[j][i];
  38.             total_cit_per_cont += city_counter_per_cont[j][i];
  39.             if (defence_per_cont[j][i] != 0) //other civ has some units on this continent...
  40.             {
  41.                 if ((diplomacy_status[civ][j]&2)==0) //war
  42.                 {
  43.                     policy_flags |= 2;
  44.                 }
  45.                 else
  46.                 {
  47.                     policy_flags |= 1;
  48.                 }
  49.             }
  50.         } //civs loop
  51.         //25fb:068d
  52.         if (city_counter_per_cont[0][i] != 0) //if there are some barbarian cities on this continent...
  53.         {
  54.             att_desire_points++;
  55.         }
  56.         my_cont_strat = strat_per_cont[civ][i];
  57.        
  58.         if (((defence_per_cont[civ][i]+total_def_per_cont)*2-continent_sizes[i] <= 0
  59.         && (city_counter_per_cont[civ][i]+total_cit_per_cont)*6+2 <= good_squares_on_cont[i])
  60.         //25fb:06ef
  61.         || (check_tech(civ,7) == 0) //civ doesn't know mapmaking
  62.             pol = 0;
  63.         else
  64.             pol = 5; //transport
  65.         //25fb:0709
  66.         strat_per_cont[civ][i] = pol; //SI
  67.        
  68.         if (att_desire_points != 0)
  69.             strat_per_cont[civ][i] = 1; //attack
  70.         if (def_desire_points != 0)
  71.             strat_per_cont[civ][i] = 2; //defence (even if att_desire_points > 0, game still will use DEFENCE policy)
  72.         //25fb:072d
  73.         if (defence_per_cont[civ][i] == 0 && city_counter_per_cont[civ][i] == 0 ///we have no units and no cities on this continent...
  74.         && policy_flags != 1)  //other civ has some units here + we at WAR with this civ...
  75.             strat_per_cont[civ][i] = 1; //->attack
  76.            
  77.         if (max_cities_on_cont < city_counter_per_cont[civ][i])
  78.             max_cities_on_cont = city_counter_per_cont[civ][i];
  79.        
  80.         if (strat_per_cont[civ][i] != my_cont_strat
  81.         && human_civ_bits&(1<<civ) == 0)
  82.         {
  83.             FUN_change_production_on_continent(civ,i); //everytime when policy for continent is changed, AI changed production in all cities on this continent...
  84.         }
  85.        
  86.         if (defence_per_cont[civ][i] != 0
  87.         && city_counter_per_cont[civ][i] > 1)
  88.         {
  89.             curr_civ_bit |= (1<<civ);
  90.         }
  91.     }
  92. //...omitted...
Advertisement
Add Comment
Please, Sign In to add comment