Advertisement
4rl3fd

One Party State Simulator

Jan 25th, 2024
534
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.22 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. #include <unistd.h>
  5.  
  6. using namespace std;
  7.  
  8. string fac_names[5] = {"Radicals", "Conservatives", "Moderates", "Reformers", "Liberals"};
  9. string fac_acro[5] = {"Rad", "Con", "Mod", "Ref", "Lib"};
  10. int fac_influence[5] = {50, 600, 200, 100,50};
  11. int fac_seats[5] = {0,0,0,0,0};
  12. int fac_commit[5]= {0,0,0,0,0};
  13. int fac_bureau[5]= {0,0,0,0,0};
  14. string fac_leaders[5][5] =
  15. {
  16.     {"","","","",""},
  17.     {"","","","",""},
  18.     {"","","","",""},
  19.     {"","","","",""},
  20.     {"","","","",""}
  21. };
  22.  
  23. int fac_leaders_age[5][5] =
  24. {
  25.     {0,0,0,0,0},
  26.     {0,0,0,0,0},
  27.     {0,0,0,0,0},
  28.     {0,0,0,0,0},
  29.     {0,0,0,0,0}
  30. };
  31.  
  32. int seats = 350;
  33. int commit = 51;
  34. int bureau = 11;
  35.  
  36. int president[2];
  37. int premier[2];
  38. int defense[2];
  39. int chairman[2];
  40. int speaker[2];
  41.  
  42. int year = 1976;
  43. int week = 1;
  44. string usr;
  45.  
  46. bool haspar = false;
  47. int paramount[2];
  48.  
  49. string indivgen()
  50. {
  51.     string consonant[20] = {"B","B","K","D","G","H","H","L","L","M","N","P","R","S","S","T","T","W","W","Y"};
  52.     string vowel[13] = {"A","A","A","A","A","E","I","I","I","O","O","O","U"};
  53.     string aftercon[11] = {"NG","NG","M","M","N","K","K","P","P","T","Y"};
  54.  
  55.     string bloc1,bloc2, bloc3;
  56.     string fname, lname;
  57.     bloc1 = consonant[rand()%20] + vowel[rand()%13];
  58.         if(rand()%10 < 3)
  59.         {
  60.             bloc1 += aftercon[rand()%11];
  61.         }
  62.         bloc2 = consonant[rand()%20] + vowel[rand()%13];
  63.         if(rand()%10 < 3)
  64.         {
  65.             bloc2 += aftercon[rand()%11];
  66.         }
  67.         bloc3 = consonant[rand()%20] + vowel[rand()%13];
  68.         if(rand()%10 < 3)
  69.         {
  70.             bloc3 += aftercon[rand()%11];
  71.         }
  72.  
  73.         fname = bloc1 + bloc2;
  74.         if(rand()%10 < 5)
  75.         {
  76.             fname += bloc3;
  77.         }
  78.  
  79.  
  80.  
  81.         bloc1 = consonant[rand()%20] + vowel[rand()%13];
  82.         if(rand()%10 < 3)
  83.         {
  84.             bloc1 += aftercon[rand()%11];
  85.         }
  86.         bloc2 = consonant[rand()%20] + vowel[rand()%13];
  87.         if(rand()%10 < 3)
  88.         {
  89.             bloc2 += aftercon[rand()%11];
  90.         }
  91.         bloc3 = consonant[rand()%20] + vowel[rand()%13];
  92.         if(rand()%10 < 3)
  93.         {
  94.             bloc3 += aftercon[rand()%11];
  95.         }
  96.  
  97.         lname = bloc1 + bloc2;
  98.         if(rand()%10 < 5)
  99.         {
  100.             lname += bloc3;
  101.         }
  102.         string final = fname + " " + lname;
  103.         return final;
  104. }
  105.  
  106. int agegen()
  107. {
  108.     int a = 40 + (rand()%20);
  109.     return a;
  110. }
  111.  
  112. void setup()
  113. {
  114.     for(int i=0; i!=5; i++)
  115.     {
  116.         for(int x=0; x!=5; x++)
  117.         {
  118.             fac_leaders[i][x] =indivgen();
  119.             fac_leaders_age[i][x] = agegen();
  120.         }
  121.     }
  122. }
  123.  
  124. void seatdistrib()
  125. {
  126.     int ogcan[5];
  127.     int winr, w_score =0;
  128.     for(int i=0; i!=5; i++)
  129.     {
  130.         ogcan[i] = fac_influence[i];
  131.     }
  132.     for(int b=0; b!=seats; b++)
  133.     {
  134.     for(int i=0; i!=5; i++)
  135.     {
  136.         if(ogcan[i] >= w_score)
  137.         {
  138.             winr = i;
  139.             w_score = ogcan[i];
  140.         }
  141.     }
  142.     fac_seats[winr]++;
  143.     ogcan[winr] = fac_influence[winr]/fac_seats[winr];
  144.     w_score=0;
  145.     }
  146. }
  147.  
  148. void comdistrib()
  149. {
  150.     int ogcan[5];
  151.     int winr, w_score =0;
  152.     for(int i=0; i!=5; i++)
  153.     {
  154.         ogcan[i] = fac_seats[i];
  155.     }
  156.     for(int b=0; b!=commit; b++)
  157.     {
  158.     for(int i=0; i!=5; i++)
  159.     {
  160.         if(ogcan[i] >= w_score)
  161.         {
  162.             winr = i;
  163.             w_score = ogcan[i];
  164.         }
  165.     }
  166.     fac_commit[winr]++;
  167.     ogcan[winr] = fac_seats[winr]/fac_commit[winr];
  168.     w_score=0;
  169.     }
  170. }
  171.  
  172. void budistrib()
  173. {
  174.     int ogcan[5];
  175.     int winr, w_score =0;
  176.     for(int i=0; i!=5; i++)
  177.     {
  178.         ogcan[i] = fac_commit[i];
  179.     }
  180.     for(int b=0; b!=bureau; b++)
  181.     {
  182.     for(int i=0; i!=5; i++)
  183.     {
  184.         if(ogcan[i] >= w_score)
  185.         {
  186.             winr = i;
  187.             w_score = ogcan[i];
  188.         }
  189.     }
  190.     fac_bureau[winr]++;
  191.     ogcan[winr] = fac_commit[winr]/fac_bureau[winr];
  192.     w_score=0;
  193.     }
  194. }
  195.  
  196. void leaderappoints()
  197. {
  198.     int ogcan[5];
  199.     int winr, w_score =0;
  200.     int points[5]= {0,0,0,0,0};
  201.    
  202.     for(int i=0; i!=5; i++)
  203.     {
  204.         ogcan[i] = fac_bureau[i];
  205.     }
  206.     for(int b=0; b!=5; b++)
  207.     {
  208.     for(int i=0; i!=5; i++)
  209.     {
  210.         if(ogcan[i] >= w_score)
  211.         {
  212.             winr = i;
  213.             w_score = ogcan[i];
  214.         }
  215.     }
  216.     switch(b)
  217.     {
  218.         case 0:
  219.         president[0] = winr;
  220.         president[1] = points[winr];
  221.         break;
  222.         case 1:
  223.         premier[0] = winr;
  224.         premier[1] = points[winr];
  225.         break;
  226.         case 2:
  227.         defense[0] = winr;
  228.         defense[1] = points[winr];
  229.         break;
  230.         case 3:
  231.         chairman[0] = winr;
  232.         chairman[1] = points[winr];
  233.         break;
  234.         case 4:
  235.         speaker[0] = winr;
  236.         speaker[1] = points[winr];
  237.         break;
  238.     }
  239.     points[winr]++;
  240.     ogcan[winr] = fac_bureau[winr]/(points[winr]+1);
  241.     w_score=0;
  242.     }
  243.     int wnr = 6;
  244.     int wps =0;
  245.     for(int i=0; i!=5; i++)
  246.     {
  247.         if(points[i]> wps)
  248.         {
  249.             wnr =i;
  250.             wps = points[i];
  251.         }
  252.     }
  253.     if(points[wnr] >=3)
  254.     {
  255.         haspar = true;
  256.         paramount[0] = wnr;
  257.         paramount[1] = 0;
  258.     } else
  259.     {
  260.         haspar = false;
  261.     }
  262. }
  263.  
  264. void update()
  265. {
  266.    
  267.     for(int i=0; i!=5; i++)
  268.     {
  269.         fac_influence[i] += ((rand()%100)-rand()%100);
  270.        
  271.         int event = rand()%100;
  272.         if(event <10)
  273.         {
  274.             fac_influence[i] -= fac_influence[i]*0.10;
  275.         }
  276.         if(event > 90)
  277.         {
  278.             fac_influence[i] += fac_influence[i]*0.10;
  279.         }
  280.        
  281.         if(fac_influence[i] <0)
  282.         {
  283.             fac_influence[i] =0;
  284.         }
  285.        
  286.        
  287.        
  288.        
  289.     }
  290.    
  291.    
  292.    
  293.     week +=1;
  294.     if(week == 52)
  295.     {
  296.         week = 1;
  297.         year++;
  298.         for(int i=0; i!=5; i++)
  299.         {
  300.             for(int x=0; x!=5; x++)
  301.         {
  302.             fac_leaders_age[i][x]+=1;
  303.            
  304.             if(fac_leaders_age[i][x] > 70)
  305.             {
  306.                 if(rand()%120 < fac_leaders_age[i][x])
  307.                 {
  308.                     fac_leaders[i][x] = indivgen();
  309.                     fac_leaders_age[i][x] = agegen();
  310.                 }
  311.             }
  312.         }
  313.         }
  314.        
  315.     }
  316.    
  317.    
  318. }
  319.  
  320. int main()
  321. {
  322.     srand(time(NULL));
  323.     setup();
  324.     seatdistrib();
  325.     comdistrib();
  326.     budistrib();
  327.     leaderappoints();
  328.    
  329.     game:
  330.     cout << year << " Government Leadership" << endl;
  331.     cout << "Week " << week << endl;
  332.     cout <<endl;
  333.     if(week == 25 || week == 50)
  334.     {
  335.         for(int i=0; i!=5;i++)
  336.         {
  337.             fac_seats[i] =0;
  338.         fac_commit[i] =0;
  339.         fac_bureau[i] =0;
  340.         }
  341.       seatdistrib();
  342.     comdistrib();
  343.     budistrib();  
  344.     }
  345.     if(week == 38)
  346.     {
  347.         leaderappoints();
  348.     }
  349.     if(haspar)
  350.     {
  351.         cout << "Paramount Leader: " << fac_leaders[paramount[0]][paramount[1]] << "(" << fac_acro[paramount[0]] << ")"  << endl;
  352.     } else
  353.     {
  354.      cout << "President: " << fac_leaders[president[0]][president[1]] << "(" << fac_acro[president[0]] << ")" << endl;  
  355.     }
  356.     cout << "Premier: " << fac_leaders[premier[0]][premier[1]] << "(" << fac_acro[premier[0]] << ")" << endl;
  357.     cout << "Defense Comissioner: " << fac_leaders[defense[0]][defense[1]] << "(" << fac_acro[defense[0]] << ")" << endl;
  358.     cout << "Committee Chairman: " << fac_leaders[chairman[0]][chairman[1]] << "(" << fac_acro[chairman[0]] << ")" << endl;
  359.     cout << "Speaker: " << fac_leaders[speaker[0]][speaker[1]] << "(" << fac_acro[speaker[0]] << ")" << endl;
  360.     cout << endl;
  361.     for(int i=0; i!=5; i++)
  362.     {
  363.         cout << fac_names[i] << ":" << endl;
  364.         cout << "Congress Seats: " << fac_seats[i] << endl;
  365.         cout << "Committee Seats: " << fac_commit[i] << endl;
  366.         cout << "Bureau Seats: " << fac_bureau[i] << endl;
  367.         cout<< "Leaders:" << endl;
  368.         for(int x=0; x!=5; x++)
  369.         {
  370.             cout << fac_leaders[i][x] << " | ";
  371.         }
  372.         cout<< "\n==================" << endl;
  373.     }
  374.     cin>> usr;
  375.     update();
  376.     system("clear");
  377.     goto game;
  378. }
  379.  
  380.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement