Advertisement
Guest User

civdos powergraph scoring (fix)

a guest
Apr 11th, 2020
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.77 KB | None | 0 0
  1. FUN_powergraph_score_and_civ_ranking()
  2. {
  3.     score[8] = {0,0,0,0,0,0,0,0}; //number of civs
  4.     max_score = 0;
  5.     civ = 1;
  6.     do
  7.     {
  8.         score[civ] =  (money[civ]>>5)+total_population[civ]*8+number_of_techs[civ];
  9.    
  10.         unit_type = 0;
  11.         do
  12.         {
  13.             score[civ] += unit_counter[civ][unit_type]*unit_cost[unit_type];
  14.             unit_type++;
  15.         }
  16.         while (unit_type < 28); //types of units...
  17.  
  18.         if (civ_activity_flags&(1<<civ) == 0)
  19.             score[civ] = 0; //why not check it _before_ though?
  20.         if (civ != human_player_civ && score[civ] > max_score)
  21.             max_score = score[civ]; //actually this result not used anywhere. This variable is set to -1 later anyway before it's used.
  22.         if (game_turn < 600)
  23.         {
  24.             powgr_score = (score[civ]>>3);
  25.             powgr_score = normalize_min_max(powgr_score,0,255);
  26.             power_graph[(game_turn>>2)%150][civ] = powgr_score;    
  27.    
  28.             //game actually writes graph data every turn,
  29.             //but if turn is not divisible by 4, then game just re-writes a previous record...
  30.             //that's why it looks like the game writes this data only every 4th turn
  31.             //after 600 turn, game can start to write data from 0 position again, but it never happens because of condition above...
  32.             //also power_graph data is stored in memory right after game_turn variable. You actually can
  33.             //interpet game_turn as powergraph data from barbarians from turns 0-3...
  34.         }
  35.         peace_civ_flags = 0x00;
  36.         civ2 = 0;
  37.         do
  38.         {
  39.             if (diplomacy[civ][civ2]&3 != 0) //1 - contact 2 - peace 1+2 = 3
  40.                 peace_civ_flags |= (1<<civ2);
  41.             civ2++;
  42.         }
  43.         while (civ2 < 8);
  44.         if (turn < 600)
  45.         {
  46.             peace_data[(game_turn>>2)%150][civ] = peace_civ_flags; 
  47.  
  48.             //peace data is stored in memory right after power graph data
  49.         }
  50.         civ++;
  51.     }
  52.     while (civ < 8);
  53.    
  54.     civ1 = 1;
  55.     best_civ; //undefined
  56.     //let's do some civ sorting...
  57.     do
  58.     {
  59.         max_score = -1;
  60.         civ2 = 1;
  61.         do
  62.         {
  63.             if (score[civ2] > max_score_B)
  64.             {
  65.                 best_civ = civ2;
  66.                 max_score = score[civ2];
  67.             }
  68.             civ2++;
  69.         }
  70.         while (civ2 < 8);
  71.  
  72.         civ_place[best_civ] = 8-civ1;
  73.         score[best_civ] = -1;
  74.  
  75.         civ1++;
  76.     }
  77.     whie (civ1 < 8);
  78.  
  79.     gl_var_handicap = 0;
  80.  
  81.     if (civ_place[human_player_civ] == 7 && civ_cities[human_player_civ] > 4
  82.     && unit_counter[human_player_civ][U_NUCLEAR] == 0 && game_turn > 200)
  83.     {
  84.         gl_var_handicap = 1; //it somehow changes ai behavior?.. used only in 2 places.
  85.         //in one of them, if gl_var_handicap == 1 ai always selects republic gov't if ai_tech_counter < human_tech_counter?
  86.     }
  87.  
  88.     civ = 1;
  89.     while (civ < 8)
  90.     {
  91.         if (civ != human_player_civ && civ_cities[civ] > 1)
  92.         {
  93.             if ((diplomacy[civ][human_player_civ]&2) == 0) //at war?
  94.             {
  95.                 diplomacy[civ][human_player_civ] |= 1; //has contact/at war?
  96.             }
  97.             else //at peace
  98.             {
  99.                 diplomacy[civ][human_player_civ] |= 0x10; //??
  100.             }
  101.         }
  102.         civ++;
  103.     }
  104.     return;
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement