Advertisement
4rl3fd

NewPar(C++ Election Simulation)

Nov 23rd, 2023 (edited)
780
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 76.10 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. #include <unistd.h>
  5. #include <chrono>
  6. #include <thread>
  7. #include <fstream>
  8. #include <algorithm>
  9. #include <utility>
  10. #include <cmath>
  11.  
  12. using namespace std;
  13.  
  14. //string allparties[6][5] = {{"National Revival Rally - L", "Collectivist Union","Labor Party", "New Cultural Movement - L", "Patriotic Socialists United - L"}, {"National Reform Council", "New Cultural Movement - P", "Yellow & Blue Alliance - P", "People's Nationalist League - P", "National Revival Rally - P"}, {"Liberal Democratic Congress", "Unity and Nation - M", "Yellow & Blue Alliance - M", "Centrist Democrats", "National Revival Rally - M"}, {"The Traditional Way", "Unity and Nation - R", "Yellow & Blue Alliance - R", "Conservative Labor", "National Revival Rally - R"},{"Order and Culture Front", "Unity and Nation - N", "Patriotic Socialists United - N", "National Revival Rally - N", "People's Nationalist League - N"}, {"National Development Corp", "United Officer's League", "People's Revolutionary Vanguard"}};
  15.  
  16. string allparties[6][10]= {
  17.     {"Labor Action Front","Democratic Liberation Party","Socialist United Front","National Democratic Party","Worker's Party","National Congress of Unions","Labor, Liberty, Action","People's Liberation Party","People's Struggle Party","Worker's Unity Front"},
  18.     {"Progressive Unity Party","Forward Party","Social Prosperity Coalition","Social Democrats","Left Bloc","Democratic Renewal Front","National Labor Coalition","Progressive Democracy","Labor Interests List","Social Bloc"},
  19.     {"Unity and Independence Movement","Progressive Moderates Alliance","Common Ground","Centrist Democrats","Unity Party","Liberal Party","Center Alliance","A Better Future","National Stability Coalition","National Unity List"},
  20.     {"Reform Party","Tradition and Democracy","National Sovereignty Party","Democratic Interests Alliance","Righteous Future Movement","Restoration Party","True Democracy","Federalist-Nationalist Party","Nationalist Revival Coalition","United Right Party"},
  21.     {"Homeland First Party","Social Purity Movement","Sovereign Nation Party","Patriotic Renewal Front","One Nation, One Culture","Heritage Party","Our Land","Nationalist Democratic Movement","Patriotic Movement","New Nationalism"},
  22.     {"National Stability Directorate","National Security Council","Order Maintenance Committee","Defense Authority Council","Sovereignty Guardianship Council","Military Oversight Committee","National Harmony Command","Authority Preservation Council","Unity and Defense Directorate","Strategic Leadership Council"}
  23.     };
  24.  
  25. string par_name[7] = {"Labor Action List", "Nationalist People's Party", "Unity and Independence Movement", "National Sovereignty Party", "Nationalist Democratic Movement", "National Development Corp", "Vacant"};
  26. string par_acro[7] ={"Far-Left", "Center-Left", "Center", "Center-Right", "Far-Right", "Military", "Vacant"};
  27.  
  28. string ideologies[5][5] = {
  29.     {"Communism","Reformist Syndicalism","Socialism", "Market Socialism", "National Communism"},
  30.     {"Social Democracy","Social Liberalism","Progressive Liberalism", "Left-wing Populism", "Religious Socialism"},
  31.     {"Market Liberalism","Third Way","Fiscal Conservatism", "Religious Liberalism", "Big Tent"},
  32.     {"Dynastic Democracy","Populist Conservatism","Libertarianism", "Religious Conservatism", "Neoconservatism"},
  33.     {"Nationalism","Right Corporatism","Traditionalism", "National Socialism", "National Conservatism"},
  34. };
  35. string pcro[5];
  36. int acronum[7] = {0,1,2,3,4,0,0};
  37. int par_coal[5];
  38. float par_seats[5];
  39. int par_seats_int[5];
  40.  
  41. int regions = 150;
  42. bool ismajor[5] = {false,false,false,false,false};
  43.  
  44. int wbmid =0; // 0 = midterm before snap: make next elect general, 1 = general before snap, make next elect midterm
  45. bool snap = false;
  46. int friendly[6];
  47.  
  48. int ctfnum =0;
  49. bool ctfyes = false;
  50.  
  51. int mode =0; // 0 = Sainte-league , 1 = D'Hondt
  52.  
  53. string flags[13] = {"Economic Redistribution", "Labor Rights Empowerment", "Social Welfare Expansion", "Education Reform", "Market Regulation", "Immigration Management", "Foreign Relations Diplomacy", "Cultural Heritage Preservation", "Strong National Defense", "Identity-Based Citizenship", "Environmental Protection", "National Security Enhancement", "Ethnic and National Exclusivity"};
  54.  
  55. int minumpol = 7;
  56.  
  57. int pflags[5];
  58.  
  59.  
  60. int prevseats[5] = {0,0,0,0,0};
  61.  
  62. string prevideo;
  63. int splural = 0;
  64. int startyear = 1948;
  65. bool isnew[5] = {true,true,true,true,true};
  66.  
  67. int ppyear= 1948;
  68.  
  69. int psyear = startyear;
  70. string ppar = "vacant";
  71.  
  72. bool prevmid = false;
  73.  
  74. int fpol =0;
  75.  
  76. int military = 80;
  77. int milfav = 4, milenem =0;
  78. int milyear = startyear;
  79.  
  80. int intervals = 2;
  81. int inyear = startyear;
  82.  
  83. string userinput ="";
  84.  
  85. bool wassnap = false;
  86.  
  87. int prevtot =0;
  88. int policy;
  89. float pfloat = 0.50;
  90. int year = startyear;
  91. int trendyear = startyear;
  92. int lhgains[5] = {0,0,0,0,0};
  93.  
  94. int population = 1526789;
  95. float turnout = 0.5;
  96. int votingpops =0;
  97.  
  98. int militancy = 50;
  99.  
  100. int prevpercent[5] = {0,0,0,0,0};
  101.  
  102. bool fair = true;
  103.  
  104. int presyear =startyear, premyear = startyear;
  105.  
  106. string cannames[8];
  107. string pcannames[7] = {"","","","","","",""};
  108. int pcanyear[5] = {startyear,startyear,startyear,startyear,startyear};
  109. int canyear[5] = {startyear,startyear,startyear,startyear,startyear};
  110.  
  111. string prevpres = "", prevprem = "";
  112.  
  113. string presprename, premprename;
  114.  
  115. string pname, pmname;
  116.  
  117. string president, primeminister, opposition;
  118.  
  119. int trending =2;
  120.  
  121. float par_votes[5] = {25,25,25,25,25};
  122. int par_votes_int[5];
  123.  
  124. float par_percent[5];
  125. int par_percent_int[5];
  126.  
  127. float popularity[5] = {20,20,20,20,20};
  128.  
  129. int totalvotes =0;
  130.  
  131. int tvts =0;
  132. int prevpop =100000;
  133. int people =100;
  134. int pefav = trending, penem = 4;
  135. int peyear = startyear; // note: create a people's revolution mechanic
  136.  
  137. int seats = 250;
  138. int seatcheck;
  139.  
  140. int presidentnum =6;
  141. int pres_votes =0;
  142.  
  143. int juntayear = startyear-8;
  144.  
  145. int primeministernum =6;
  146.  
  147. int oppositionnum =6;
  148.  
  149. int govmembers=0;
  150. int gmem[5];
  151. int govseats;
  152. int govper;
  153.  
  154. int plurality;
  155. int pluralvotes;
  156.  
  157. int oppomembers =0;
  158. int omem[5];
  159. int opposeats;
  160. int oppoper;
  161.  
  162. int indepmembers =0;
  163. int imem[5];
  164. int indepseats =0;
  165. int indeper;
  166.  
  167. int prevpar =6;
  168.  
  169. int prvtot =0;
  170.  
  171. int p_auth[7] = {0,0,0,0,0};
  172. // -5 to 5
  173.  
  174. int totauth = 20; // higher, less authoritarian, lower more authoritarian
  175. // -100 to 100
  176.  
  177. int av_correspond =0; // this integer will correspond to the "i" integer use din the for loop for adding votes
  178.  
  179. bool midterm = false;
  180.  
  181. bool junta = false;
  182.  
  183. bool ot =false;
  184. int countdown = startyear;
  185.  
  186. int economy = 40; // only goes 1 to 100
  187. int competence[5] = {2,3,4,3,2};
  188. int BBC = 5;
  189. bool boom = true;
  190. int shiffty;
  191.  
  192. void mupdate()
  193. {
  194.     /*militancy += (p_auth[presidentnum]*10)*0.10;
  195.     militancy += totauth*0.5;
  196.     militancy += people*0.20;
  197.     militancy -= ((year - presyear)/100)*0.20;*/
  198.  
  199.     militancy = (totauth*0.25) + (people*0.25) + (((year - presyear)/100)*0.25) + ((p_auth[presidentnum]*10)*0.10);
  200.  
  201.     if(militancy > 100)
  202.     {
  203.         militancy =100;
  204.     }
  205.     if(militancy < -100)
  206.     {
  207.         militancy = -100;
  208.     }
  209. }
  210.  
  211. void upturnout()
  212. {
  213.     turnout = turnout*100;
  214.     float tchange, pfol = (float) people*0.50, efol = (float)economy*0.25, tfol = (float)totauth*0.25;
  215.     /*if(pfol <5)
  216.     {
  217.         pfol = 5;
  218.     }
  219.     if(efol < 5)
  220.     {
  221.         efol =5;
  222.     }
  223.     if(tfol < 5)
  224.     {
  225.         tfol = 5;
  226.     }*/
  227.     tchange = (pfol+efol+tfol)/100;
  228.     /*string ipt;
  229.     cout << "total change: " << tchange << endl;
  230.     cout << "people: " << pfol << endl;
  231.     cout << "Economy: " << efol << endl;
  232.     cout << "totauth: " << tfol << endl;
  233.     cin >> ipt;*/
  234.     //float tchange = (float) (people*0.50) + (economy*0.25) + (totauth*0.25);
  235.  
  236.     turnout += (float) turnout*tchange;
  237.     while(turnout >= 100)
  238.     {
  239.         if(turnout >= 100)
  240.         {
  241.             turnout -= rand()%30;
  242.         }
  243.     }
  244.     if(turnout <1)
  245.     {
  246.         turnout += (rand()%30)+1;
  247.     }
  248.     if(turnout < 70)
  249.     {
  250.         turnout += (70 - turnout) + rand()%20;
  251.     }
  252.     turnout /=100;
  253. }
  254.  
  255. void uppop()
  256. {
  257.     float tchange = (float)people*0.05;
  258.     tchange += (float)economy*0.025;
  259.     tchange += (float)totauth*0.025;
  260.     if(tchange <=-2)
  261.     {
  262.         tchange =-2;
  263.     }
  264.     tchange = tchange/100;
  265.     population += population*tchange;
  266.  
  267. }
  268.  
  269. void calcto()
  270. {
  271.     votingpops = population*turnout;
  272. }
  273.  
  274. void updateauth()
  275. {
  276.     float auadd = (float) p_auth[presidentnum]*(popularity[presidentnum] + (par_seats[presidentnum]/seats));
  277.     //cout << "Before: " << totauth << endl;
  278.     totauth += p_auth[presidentnum];
  279.     //cout << "Party Auth: " << p_auth[presidentnum] << endl;
  280.     totauth += militancy*0.025;
  281.     //cout << "Militancy: " << militancy*0.025 << endl;
  282.     float pear = (float) year, spear = (float) psyear;
  283.  
  284.     auadd = (float)(pear - spear);
  285.     auadd /= 100;
  286.     totauth -= totauth* auadd;
  287.     //cout << "totauth decrease: " << auadd << endl;
  288.  
  289.     totauth += 10 - rand()%5;
  290.     if(par_seats_int[presidentnum] >= seats*0.75)
  291.     {
  292.         totauth -= 10;
  293.     }
  294.     //cout << "Before: " << totauth << endl;
  295.     //totauth += auadd;
  296.     if(totauth > 100)
  297.     {
  298.         totauth = 100;
  299.     } else if(totauth < -100)
  300.     {
  301.         totauth = -100;
  302.     }
  303. }
  304.  
  305. void bbcupdate()
  306. {
  307.     if(boom)
  308.     {
  309.         BBC++;
  310.     } else
  311.     {
  312.         BBC--;
  313.     }
  314.     if(BBC >= 10)
  315.     {
  316.         BBC--;
  317.         boom = false;
  318.     }
  319.     if(BBC <= -10)
  320.     {
  321.         shiffty = (rand()%3)*5;
  322.         BBC++;
  323.         boom = true;
  324.     }
  325.  
  326.     if(boom == false)
  327.     {
  328.         if(rand()%10 < competence[presidentnum]/2)
  329.         {
  330.             boom = true;
  331.             shiffty = (rand()%3)*5;
  332.         }
  333.     } else if(boom == true)
  334.     {
  335.         if( rand()%10 > competence[presidentnum]*2)
  336.         {
  337.             boom = false;
  338.         }
  339.     }
  340. }
  341.  
  342. void shiftcomp(int k)
  343. {
  344.     if(rand()%10 <5)
  345.     {
  346.         competence[k]++;
  347.     } else
  348.     {
  349.         competence[k]--;
  350.     }
  351.     if(competence[k] > 10)
  352.     {
  353.         competence[k] = 10;
  354.     }
  355.     if(competence[k] < 1)
  356.     {
  357.         competence[k] = 1;
  358.     }
  359. }
  360.  
  361. void ecupdate()
  362. {
  363.     float bonus =0;
  364.     //cout << "competence: " << competence[presidentnum] << endl;
  365.     switch(competence[presidentnum])
  366.     {
  367.     case 1:bonus = -0.25;
  368.         break;
  369.     case 2:bonus = -0.2;
  370.         break;
  371.     case 3:bonus = -0.15;
  372.         break;
  373.     case 4:bonus = -0.1;
  374.         break;
  375.     case 5:bonus = -0.05;
  376.         break;
  377.     case 6:bonus = 0;
  378.         break;
  379.     case 7:bonus = 0.1;
  380.         break;
  381.     case 8: bonus = 0.15;
  382.         break;
  383.     case 9: bonus = 0.2;
  384.         break;
  385.     case 10: bonus = 0.25;
  386.         break;
  387.     default:
  388.         bonus = 0;
  389.         break;
  390.     }
  391.  
  392.     switch(people/10)
  393.     {
  394.     case 1:bonus += -0.25;
  395.         break;
  396.     case 2:bonus += -0.2;
  397.         break;
  398.     case 3:bonus +=  -0.15;
  399.         break;
  400.     case 4:bonus += -0.1;
  401.         break;
  402.     case 5:bonus += -0.05;
  403.         break;
  404.     case 6:bonus += 0.05;
  405.         break;
  406.     case 7:bonus += 0.1;
  407.         break;
  408.     case 8: bonus += 0.15;
  409.         break;
  410.     case 9: bonus += 0.2;
  411.         break;
  412.     case 10: bonus += 0.25;
  413.         break;
  414.     default:
  415.         if(people < 0)
  416.         {
  417.             bonus += -0.3;
  418.         }else
  419.         {
  420.             bonus += 0.3;
  421.         }
  422.     }
  423.     float BBChange = (float) BBC/100;
  424.     //cout << "Before " << economy << endl;
  425.     economy += economy*BBChange;
  426.     //cout << "Boom Bust Effect: " << BBChange << endl;
  427.     //cout << "Ecobonus: " << bonus << endl;
  428.     economy += economy*bonus;
  429.     int downturn = rand()%10;
  430.     //cout << "downturn: " << downturn << endl;
  431.     economy -= downturn;
  432.     economy += militancy*0.025;
  433.     //cout << "Militancy Bonus: " <<militancy*0.025 << endl;
  434.  
  435.     //cout << "After " << economy << endl;
  436.  
  437.     if(economy > 100)
  438.     {
  439.         economy = 100;
  440.     }
  441.     if(economy < -100)
  442.     {
  443.         economy = -100;
  444.     }
  445. }
  446.  
  447. void indivgen(int k)
  448. {
  449.     string consonant[20] = {"B","B","K","D","G","H","H","L","L","M","N","P","R","S","S","T","T","W","W","Y"};
  450.     string vowel[13] = {"A","A","A","A","A","E","I","I","I","O","O","O","U"};
  451.     string aftercon[11] = {"NG","NG","M","M","N","K","K","P","P","T","Y"};
  452.  
  453.     string bloc1,bloc2, bloc3;
  454.     string fname, lname;
  455.     bloc1 = consonant[rand()%20] + vowel[rand()%13];
  456.         if(rand()%10 < 3)
  457.         {
  458.             bloc1 += aftercon[rand()%11];
  459.         }
  460.         bloc2 = consonant[rand()%20] + vowel[rand()%13];
  461.         if(rand()%10 < 3)
  462.         {
  463.             bloc2 += aftercon[rand()%11];
  464.         }
  465.         bloc3 = consonant[rand()%20] + vowel[rand()%13];
  466.         if(rand()%10 < 3)
  467.         {
  468.             bloc3 += aftercon[rand()%11];
  469.         }
  470.  
  471.         fname = bloc1 + bloc2;
  472.         if(rand()%10 < 5)
  473.         {
  474.             fname += bloc3;
  475.         }
  476.  
  477.  
  478.  
  479.         bloc1 = consonant[rand()%20] + vowel[rand()%13];
  480.         if(rand()%10 < 3)
  481.         {
  482.             bloc1 += aftercon[rand()%11];
  483.         }
  484.         bloc2 = consonant[rand()%20] + vowel[rand()%13];
  485.         if(rand()%10 < 3)
  486.         {
  487.             bloc2 += aftercon[rand()%11];
  488.         }
  489.         bloc3 = consonant[rand()%20] + vowel[rand()%13];
  490.         if(rand()%10 < 3)
  491.         {
  492.             bloc3 += aftercon[rand()%11];
  493.         }
  494.  
  495.         lname = bloc1 + bloc2;
  496.         if(rand()%10 < 5)
  497.         {
  498.             lname += bloc3;
  499.         }
  500.         cannames[k] = fname + " " + lname;
  501.  
  502.  
  503. }
  504.  
  505. void pmindivgen(int k)
  506. {
  507.     string consonant[20] = {"B","B","K","D","G","H","H","L","L","M","N","P","R","S","S","T","T","W","W","Y"};
  508.     string vowel[13] = {"A","A","A","A","A","E","I","I","I","O","O","O","U"};
  509.     string aftercon[11] = {"NG","NG","M","M","N","K","K","P","P","T","Y"};
  510.  
  511.     string bloc1,bloc2, bloc3;
  512.     string fname, lname;
  513.     bloc1 = consonant[rand()%20] + vowel[rand()%13];
  514.         if(rand()%10 < 3)
  515.         {
  516.             bloc1 += aftercon[rand()%11];
  517.         }
  518.         bloc2 = consonant[rand()%20] + vowel[rand()%13];
  519.         if(rand()%10 < 3)
  520.         {
  521.             bloc2 += aftercon[rand()%11];
  522.         }
  523.         bloc3 = consonant[rand()%20] + vowel[rand()%13];
  524.         if(rand()%10 < 3)
  525.         {
  526.             bloc3 += aftercon[rand()%11];
  527.         }
  528.  
  529.         fname = bloc1 + bloc2;
  530.         if(rand()%10 < 5)
  531.         {
  532.             fname += bloc3;
  533.         }
  534.  
  535.  
  536.  
  537.         bloc1 = consonant[rand()%20] + vowel[rand()%13];
  538.         if(rand()%10 < 3)
  539.         {
  540.             bloc1 += aftercon[rand()%11];
  541.         }
  542.         bloc2 = consonant[rand()%20] + vowel[rand()%13];
  543.         if(rand()%10 < 3)
  544.         {
  545.             bloc2 += aftercon[rand()%11];
  546.         }
  547.         bloc3 = consonant[rand()%20] + vowel[rand()%13];
  548.         if(rand()%10 < 3)
  549.         {
  550.             bloc3 += aftercon[rand()%11];
  551.         }
  552.  
  553.         lname = bloc1 + bloc2;
  554.         if(rand()%10 < 5)
  555.         {
  556.             lname += bloc3;
  557.         }
  558.         pcannames[k] = fname + " " + lname;
  559.  
  560.  
  561. }
  562.  
  563. void pecheck()
  564. {
  565.     int dbgto=0;
  566.     if(acronum[presidentnum] == pefav)
  567.     {
  568.         people += 10;
  569.         dbgto += 10;
  570.     } else if(acronum[presidentnum] == penem)
  571.     {
  572.         people -= 10;
  573.         dbgto -= 10;
  574.     } else
  575.     {
  576.         if(acronum[presidentnum] > pefav)
  577.         {
  578.             people -= acronum[presidentnum] - pefav;
  579.             dbgto -= acronum[presidentnum] - pefav;
  580.         } else
  581.         {
  582.             people -=  pefav -acronum[presidentnum];
  583.             dbgto -=  pefav -acronum[presidentnum];
  584.         }
  585.  
  586.         if(acronum[presidentnum] > penem)
  587.         {
  588.             people += acronum[presidentnum] - penem;
  589.             dbgto += acronum[presidentnum] - penem;
  590.         } else
  591.         {
  592.             people +=  penem -acronum[presidentnum];
  593.             dbgto +=  penem -acronum[presidentnum];
  594.         }
  595.     }
  596.  
  597.  
  598.     if(pefav == acronum[oppositionnum])
  599.     {
  600.         people -= 5;
  601.         dbgto -= 5;
  602.     }
  603.     if(penem == acronum[primeministernum])
  604.     {
  605.         people -= 5;
  606.         dbgto -= 5;
  607.     }
  608.     if(pefav == acronum[primeministernum])
  609.     {
  610.         people += 5;
  611.         dbgto += 5;
  612.     }
  613.     //cout << "Total pos bonus: " << dbgto << endl;
  614.     people -= par_percent_int[penem]/2;
  615.     //cout << "penem bonus: " << par_percent_int[penem]/2 << endl;
  616.     people += par_percent_int[pefav]/2;
  617.     //cout << "pefav bonus: " << par_percent_int[pefav]/2 << endl;
  618.     people += economy*0.15;
  619.     //cout << "Eco bonus: " << economy*0.15 << endl;
  620.     people += totauth*0.10;
  621.     //cout << "Auth bonus: " << totauth*0.10 << endl;
  622.     people += militancy*0.10;
  623.     //cout << "Mil bonus: " << militancy*0.10 << endl;
  624.  
  625.     if(fair == false)
  626.     {
  627.         people -= year - presyear;
  628.     }
  629.     //string upt;
  630.     //cin >> upt;
  631.  
  632.     if(people > 100 && acronum[presidentnum] == pefav)
  633.     {
  634.         people = 100;
  635.     } else if (people > 40 && acronum[presidentnum] == acronum[penem])
  636.     {
  637.         people = 40;
  638.     } else if (people > 70 && acronum[presidentnum] != acronum[pefav] && presidentnum != acronum[penem])
  639.     {
  640.         people = 70;
  641.     }
  642.  
  643.     if(people < -200)
  644.     {
  645.         people = -200;
  646.     }
  647. }
  648.  
  649. void pshift()
  650. {
  651.  
  652.         /*switch(rand()%10)
  653.         {
  654.         case 1:
  655.         case 2:
  656.             penem++;
  657.             break;
  658.         case 9:
  659.         case 8:
  660.             penem --;
  661.             break;
  662.         default:
  663.             break;
  664.         }*/
  665.         int cchange =0;
  666.         cchange = (rand()%2) -1;
  667.         penem += cchange;
  668.         cchange = (rand()%2) -1;
  669.         pefav += cchange;
  670.     if(penem > 4)
  671.     {
  672.         penem = 4;
  673.     }
  674.     if(penem < 0)
  675.     {
  676.         penem  =0;
  677.     }
  678.     if(pefav > 4)
  679.     {
  680.         pefav = 4;
  681.     }
  682.     if(pefav < 0)
  683.     {
  684.         pefav  =0;
  685.     }
  686.  
  687.     if(penem == pefav)
  688.     {
  689.         penem = rand()%4;
  690.     }
  691. }
  692.  
  693. void revcheck()
  694. {
  695.     if(rand()%20 < year - peyear)
  696.     {
  697.         if(people < -25 && rand()%20 > (people + par_percent_int[presidentnum])-intervals && militancy < -10)
  698.         {
  699.             intervals =0;
  700.             peyear = year;
  701.             ofstream presfile;
  702.         presfile.open("Presidents.txt", fstream::app);
  703.         presfile << presprename << " (" << prevpres <<  " | " << prevideo <<  ") " << presyear << " - " << year << " (REVOLT)" << endl;
  704.         presfile.close();
  705.         presyear = year;
  706.         prevpres = par_name[presidentnum];
  707.         presprename = cannames[presidentnum];
  708.  
  709.  
  710.         ofstream pmfile;
  711.         pmfile.open("Premieres.txt", fstream::app);
  712.         pmfile << premprename << " (" << prevprem << ") " << premyear << " - " << year  << " (REVOLT)"<< endl;
  713.         pmfile.close();
  714.         premyear = year;
  715.         prevprem = par_name[primeministernum];
  716.         premprename = cannames[primeministernum];
  717.         economy -= (rand()%5)*5;
  718.         if(presidentnum == milfav)
  719.         {
  720.             military -=50;
  721.         } else if(presidentnum == milenem)
  722.         {
  723.             military += 25;
  724.         } else
  725.         {
  726.             military -=30;
  727.         }
  728.         totauth += (rand()%100)-50;
  729.         popularity[presidentnum] = 0;
  730.  
  731.         intervals = 0;
  732.         ot = true;
  733.         militancy += (rand()%100)-50;
  734.  
  735.         acronum[pefav] = pefav;
  736.             par_name[pefav] = allparties[acronum[pefav]][rand()%9];
  737.  
  738.             presidentnum = pefav;
  739.             popularity[presidentnum] = 100;
  740.             oppositionnum = penem;
  741.             president = par_name[pefav];
  742.             opposition = par_name[oppositionnum];
  743.             presyear = year;
  744.             pname = cannames[pefav];
  745.  
  746.             primeministernum = 6;
  747.             primeminister = "VACANT";
  748.             premyear = year;
  749.             pmname = "VACANT";
  750.             fair = true;
  751.             junta = false;
  752.             midterm = false;
  753.             people =99;
  754.             cout << "REVOLUTION!" << endl;
  755.             sleep(1);
  756.         }else if(people < -10 && rand()%100 < military)
  757.         {
  758.             people += rand()%200;
  759.             militancy += rand()%200;
  760.             totauth -= rand()%200;
  761.             int plr = popularity[presidentnum]/2;
  762.             popularity[presidentnum] = (float )plr;
  763.             cout << "REVOLUTION FAILED" << endl;
  764.             sleep(1);
  765.         }
  766.     }
  767. }
  768.  
  769. void mchange()
  770. {
  771.     if((rand()%year-startyear)+1 < year - milyear)
  772.     {
  773.         milyear = year;
  774.         int k = rand()%10;
  775.  
  776.         int cchange = 0;
  777.         cchange = (rand()%3) -1;
  778.         milfav += cchange;
  779.         if(milfav > 4)
  780.         {
  781.             milfav =4;
  782.         } else if( milfav < 0)
  783.         {
  784.             milfav = 0;
  785.         }
  786.  
  787.         cchange = (rand()%3) -1;
  788.         milenem += cchange;
  789.  
  790.  
  791.  
  792.         for(int i=0; i!= oppomembers; i++)
  793.         {
  794.             if(milfav == omem[i])
  795.             {
  796.                 military -=5;
  797.             }
  798.             if(milenem == omem[i])
  799.             {
  800.                 military +=5;
  801.             }
  802.         }
  803.  
  804.         for(int i=0; i!= govmembers; i++)
  805.         {
  806.             if(milfav == gmem[i])
  807.             {
  808.                 military +=5;
  809.             }
  810.             if(milenem == gmem[i])
  811.             {
  812.                 military -=5;
  813.             }
  814.         }
  815.  
  816.         if(milenem > 4)
  817.         {
  818.             milenem =4;
  819.         } else if( milenem < 0)
  820.         {
  821.             milenem = 0;
  822.         }
  823.         if(milfav > 4)
  824.         {
  825.             milfav =4;
  826.         } else if( milfav < 0)
  827.         {
  828.             milfav = 0;
  829.         }
  830.  
  831.  
  832.         while(milenem == milfav)
  833.         {
  834.             milenem = rand()%4;
  835.         }
  836.     }
  837.     par_name[5] = allparties[5][rand()%3];
  838. }
  839.  
  840. void covalues()
  841. {
  842.     if(acronum[presidentnum] == milfav)
  843.     {
  844.         military += 10;
  845.     }else if(acronum[presidentnum] == milenem)
  846.     {
  847.         military -= 10;
  848.     }else
  849.     {
  850.         if(acronum[presidentnum] < milenem)
  851.         {
  852.             military += milenem - acronum[presidentnum];
  853.         } else
  854.         {
  855.             military += acronum[presidentnum] - milenem;
  856.         }
  857.  
  858.         if(presidentnum < milfav)
  859.         {
  860.             military -= milfav - acronum[presidentnum];
  861.         }else
  862.         {
  863.             military -= acronum[presidentnum] - milfav;
  864.         }
  865.     }
  866.  
  867.     if(acronum[primeministernum] == milfav)
  868.     {
  869.         military += 5;
  870.     } else if(acronum[primeministernum] == milenem)
  871.     {
  872.         military -= 5;
  873.     }
  874.  
  875.     if(oppositionnum == milfav)
  876.     {
  877.         military -= 20;
  878.     }
  879.     if(fair == false)
  880.     {
  881.         military -= year- presyear;
  882.     }
  883.     if(military > 100 && acronum[presidentnum] == milfav)
  884.     {
  885.         military = 100;
  886.     } else if (military > 40 && acronum[presidentnum] == milenem)
  887.     {
  888.         military = 40;
  889.     } else if (military > 70 && acronum[presidentnum] != milfav && acronum[presidentnum] != milenem)
  890.     {
  891.         military = 70;
  892.     }
  893.     if(military < -100)
  894.     {
  895.         military =-100;
  896.     }
  897.     military += economy/10;
  898.     military-= totauth/10;
  899.     military += (int) (par_seats[milfav] / seats)*100;
  900.     military -= (int) (par_seats[milenem] / seats)*100;
  901. }
  902.  
  903. void coupcheck()
  904. {
  905.     // coup factor = term length(year - presyear)
  906.  
  907.     if(rand()%8 < year - juntayear && junta == false)
  908.     {
  909.  
  910.         int supportfactor = (int)(par_percent_int[presidentnum]/10 + ((par_seats[presidentnum] / seats)*100) + military) - (year-presyear);
  911.         int sfcheck = rand()%50;
  912.         sfcheck = sfcheck - (sfcheck*2);
  913.         if(sfcheck > supportfactor-intervals)
  914.         {
  915.             intervals = 0;
  916.             junta = true;
  917.         ot = true;
  918.         juntayear = year;
  919.             ofstream presfile;
  920.         presfile.open("Presidents.txt", fstream::app);
  921.         presfile << presprename << " (" << prevpres <<  " | " << prevideo <<  ") " << presyear << " - " << year << " (COUP)" << endl;
  922.         presfile.close();
  923.         presyear = year;
  924.         prevpres = par_name[presidentnum];
  925.         presprename = cannames[presidentnum];
  926.  
  927.  
  928.         ofstream pmfile;
  929.         pmfile.open("Premieres.txt", fstream::app);
  930.         pmfile << premprename << " (" << prevprem << ") " << premyear << " - " << year  << " (COUP)"<< endl;
  931.         pmfile.close();
  932.         premyear = year;
  933.         prevprem = par_name[primeministernum];
  934.         premprename = cannames[primeministernum];
  935.  
  936.  
  937.         economy -= (rand()%5)*5;
  938.         if(presidentnum == pefav)
  939.         {
  940.             people -=50;
  941.         } else if(presidentnum == penem)
  942.         {
  943.             people += 25;
  944.         } else
  945.         {
  946.             people -=30;
  947.         }
  948.         fair = false;
  949.         totauth += (rand()%50)-100;
  950.         militancy += (rand()%50)-100;
  951.         intervals = 0;
  952.             presidentnum = milfav;
  953.  
  954.             pcro[milfav] = "Junta";
  955.             par_name[milfav] = "Military Government";
  956.             isnew[milfav] = true;
  957.             prevseats[milfav] = 0;
  958.             prevpercent[milfav] = 0;
  959.             canyear[milfav] = year;
  960.             indivgen(milfav);
  961.             shiftcomp(milfav);
  962.             p_auth[milfav] = (rand()%10) -(5+(abs(acronum[milfav]-3)*2));
  963.             pflags[milfav] = (rand()%minumpol)+acronum[milfav];
  964.             friendly[milfav] = (rand()%20)-10;
  965.  
  966.  
  967.             oppositionnum = milenem;
  968.             president = par_name[presidentnum];
  969.             opposition = par_name[oppositionnum];
  970.             presyear = year;
  971.             pname = cannames[milfav];
  972.  
  973.             primeministernum = 6;
  974.             primeminister = "VACANT";
  975.             premyear = year;
  976.             pmname = "VACANT";
  977.             midterm = false;
  978.             military =99;
  979.             cout << "MILITARY COUP!" << endl;
  980.             sleep(1);
  981.         } else if(military < -10 && rand()%100 < people)
  982.         {
  983.             military += rand()%200;
  984.             militancy += rand()%200;
  985.             totauth -= rand()%200;
  986.             int plr = popularity[presidentnum]/2;
  987.             popularity[presidentnum] = (float )plr;
  988.             cout << "COUP ATTEMPT FAILED" << endl;
  989.             sleep(1);
  990.         }
  991.     }
  992. }
  993.  
  994. void countplural()
  995. {
  996.     pluralvotes = 0;
  997.     for(int i=0; i!=5; i++)
  998.     {
  999.         if(par_votes_int[i] > pluralvotes)
  1000.         {
  1001.             plurality =i;
  1002.             pluralvotes = par_votes_int[i];
  1003.         }
  1004.     }
  1005. }
  1006.  
  1007. void dsdhondt()
  1008. {
  1009.     int winr = 6;
  1010.     int winnum =0;
  1011.     int vcomp[6];
  1012.     int counts[6]= {0,0,0,0,0};
  1013.     int leading =6;
  1014.     int lnum =0;
  1015.     vcomp[5] =0;
  1016.  
  1017.     for(int i=0; i!=5; i++)
  1018.     {
  1019.         if(par_votes_int[i] > lnum)
  1020.         {
  1021.             leading =i;
  1022.             lnum = par_votes_int[i];
  1023.         }
  1024.     }
  1025.  
  1026.     for(int i=0; i!=5; i++)
  1027.     {
  1028.         vcomp[i] = par_votes_int[i];
  1029.     }
  1030.  
  1031.     int prv =seats*pfloat;  //abs
  1032.     int cng =0;
  1033.     while(0< seats*pfloat)
  1034.     {
  1035.         //cout << "A";
  1036.         for(int j=0; j!=5; j++)
  1037.         {
  1038.             //cout << "B";
  1039.             if(vcomp[j] > winnum)
  1040.             {
  1041.  
  1042.                 if(par_votes_int[j] > ctfnum)
  1043.                 {
  1044.                     winr = j;
  1045.                     winnum = vcomp[j];
  1046.                 }
  1047.                 //winr = j;
  1048.                     //winnum = vcomp[j];
  1049.  
  1050.             }
  1051.  
  1052.         }
  1053.         /*for(int f=0; f!=5; f++)
  1054.         {
  1055.  
  1056.             cout << par_name[f] << " " << counts[f]+1 << " " << vcomp[f] << " ";
  1057.             if(f == winr)
  1058.             {
  1059.                 cout << "+";
  1060.                 if(f == leading)
  1061.                 {
  1062.                     cout << "5";
  1063.                 }
  1064.             }
  1065.             cout <<  endl;
  1066.  
  1067.         }*/
  1068.  
  1069.         prv = counts[winr];
  1070.         counts[winr]++;
  1071.         if(winr == leading)
  1072.         {
  1073.             par_seats[winr]+= par_percent_int[winr]/10;
  1074.         par_seats_int[winr]+= par_percent_int[winr]/10;
  1075.         }
  1076.         vcomp[winr] = par_votes_int[winr]/(counts[winr]+1);
  1077.         par_seats[winr]++;
  1078.         par_seats_int[winr]++;
  1079.  
  1080.         if(vcomp[winr] == 0 && rand()% 100 < par_percent_int[winr])
  1081.         {
  1082.             for(int c=0; c!=5; c++)
  1083.             {
  1084.                 vcomp[c] = par_votes_int[c];
  1085.             }
  1086.         }
  1087.         cng += counts[winr];
  1088.         if(cng >= seats*pfloat)
  1089.         {
  1090.             break;
  1091.         }
  1092.  
  1093.         winnum =0;
  1094.         winr =6;
  1095.         //sleep(1);
  1096.         //system("CLS");
  1097.  
  1098.  
  1099.     }
  1100.  
  1101.     for(int i=0; i!=5; i++)
  1102.     {
  1103.         lhgains[i] = par_seats_int[i];
  1104.     }
  1105. }
  1106.  
  1107.  
  1108.  
  1109. void cutoff()
  1110. {
  1111.     int totv =0;
  1112.     for(int i=0; i!=5; i++)
  1113.     {
  1114.         totv+= par_votes_int[i];
  1115.     }
  1116.     ctfnum = totv/((seats/regions)+5);
  1117. }
  1118.  
  1119. void checkcutoff()
  1120. {
  1121.     int ctotau = totauth+100;
  1122.     if(par_votes_int[presidentnum] < totalvotes /2)
  1123.     {
  1124.         ctfyes = true;
  1125.         cutoff();
  1126.     } else
  1127.     {
  1128.         ctfyes = false;
  1129.     }
  1130. }
  1131.  
  1132. void domode()
  1133. {
  1134.     int ctotau = totauth+100;
  1135.     int kai = rand()%200;
  1136.     if(kai < ctotau)
  1137.     {
  1138.         mode = 0;
  1139.     } else if (kai > ctotau && govseats > seats*0.75)
  1140.     {
  1141.         mode =1;
  1142.     }
  1143. }
  1144.  
  1145. void discont()
  1146. {
  1147.     srand(time(NULL));
  1148.     int order[5] = {0,0,0,0,0};
  1149.     int oper[5] = {0,0,0,0,0};
  1150.  
  1151.     for(int i=0; i!=5; i++)
  1152.     {
  1153.         oper[i] = par_percent_int[i];
  1154.         order[i] = i;
  1155.     }
  1156.  
  1157.     for(int i=0; i!=5; i++)
  1158.     {
  1159.         if(i == presidentnum && midterm == true)
  1160.         {
  1161.             oper[i] += 5;
  1162.         } else if(i == plurality && midterm == false)
  1163.         {
  1164.             oper[i] += 15;
  1165.         } else if(i == presidentnum && midterm == false)
  1166.         {
  1167.             oper[i] += 5;
  1168.         } else if(i == plurality && midterm == true)
  1169.         {
  1170.             oper[i] += 10;
  1171.         }
  1172.  
  1173.         if(i == presidentnum)
  1174.         {
  1175.             oper[i] +=10;
  1176.         }
  1177.         if(i == primeministernum)
  1178.         {
  1179.             oper[i] += 5;
  1180.         }
  1181.         if( i == oppositionnum)
  1182.         {
  1183.             oper[i] += 5;
  1184.         }
  1185.         if(acronum[i] == trending)
  1186.         {
  1187.             oper[i] += 7;
  1188.         }
  1189.         if(i == presidentnum)
  1190.         {
  1191.             oper[i] -= year-presyear;
  1192.         }
  1193.         if(plurality != presidentnum && i == plurality)
  1194.     {
  1195.         oper[i] += par_percent_int[plurality] - par_percent_int[presidentnum];
  1196.     }
  1197.     }
  1198.  
  1199.     int k =0;
  1200.  
  1201.     /*if(year == startyear)
  1202.     {
  1203.         policy = ((rand()%13) *5)+35;
  1204.         pfloat = (float) policy/100;
  1205.     }*/
  1206.  
  1207.     for(int c=0; c< round(seats*pfloat); c++)
  1208.     {
  1209.         for(int f=0; f!=5; f++)
  1210.         {
  1211.             k = rand()%100;
  1212.                 if(k < oper[f])
  1213.                 {
  1214.                     par_seats[order[f]]++;
  1215.                     par_seats_int[order[f]]++;
  1216.                     break;
  1217.                 }
  1218.         }
  1219.  
  1220.     }
  1221.  
  1222.     for(int i=0; i!=5; i++)
  1223.     {
  1224.         lhgains[i] = par_seats_int[i];
  1225.     }
  1226.  
  1227. }
  1228.  
  1229. void calsplu()
  1230. {
  1231.     int winer = 1;
  1232.     for(int i=0; i!=5; i++)
  1233.     {
  1234.         if(par_seats_int[i] > winer)
  1235.         {
  1236.             splural = i;
  1237.             winer = par_seats_int[i];
  1238.         }
  1239.     }
  1240. }
  1241.  
  1242. int add_votes(int rmn)
  1243. {
  1244.     srand(time(NULL));
  1245.     std::this_thread::sleep_for(std::chrono::milliseconds(100));
  1246.     float advote =0;
  1247.     int event = rand()%5;
  1248.     if(av_correspond == presidentnum){
  1249.         switch(event)
  1250.         {
  1251.         case 3:
  1252.             advote += (rand()%rmn) *1.10;
  1253.         case 4:
  1254.             case 5:
  1255.             advote += (rand()%rmn) *1.05;
  1256.             break;
  1257.         default:
  1258.             advote += (rand()%rmn) * 0.50;
  1259.         }
  1260.     }
  1261.     if(av_correspond == primeministernum) {
  1262.         switch(event)
  1263.         {
  1264.         case 1:
  1265.             if(primeministernum == oppositionnum)
  1266.             {
  1267.                 advote += (rand()%rmn) * 0.75;
  1268.             }else
  1269.             {
  1270.                 advote += (rand()%rmn)*0.95;
  1271.             }
  1272.             break;
  1273.         case 2:
  1274.             if(primeministernum == oppositionnum)
  1275.             {
  1276.                 advote += (rand()%rmn) * 0.45;
  1277.             }else
  1278.             {
  1279.                 advote += (rand()%rmn)*1;
  1280.             }
  1281.         case 3:
  1282.             case 4:
  1283.                 if(primeministernum == oppositionnum)
  1284.             {
  1285.                 advote += (rand()%rmn) * 0.20;
  1286.             }else
  1287.             {
  1288.                 advote += (rand()%rmn)*0.45;
  1289.             }
  1290.             break;
  1291.         default:
  1292.             if(primeministernum == oppositionnum)
  1293.             {
  1294.                 advote += (rand()%rmn) * 0.05;
  1295.             }else
  1296.             {
  1297.                 advote += (rand()%rmn) * 0.10;
  1298.             }
  1299.         }
  1300.     }
  1301.     if(av_correspond == oppositionnum){
  1302.         switch(event)
  1303.         {
  1304.         case 1:
  1305.             if(primeministernum == oppositionnum)
  1306.             {
  1307.                 advote += (rand()%rmn) * 1.05;
  1308.             }else
  1309.             {
  1310.                 advote += (rand()%rmn) *1.10;
  1311.             }
  1312.         case 2:
  1313.         case 3:
  1314.             if(primeministernum == oppositionnum)
  1315.             {
  1316.                 advote += (rand()%rmn) * 0.45;
  1317.             } else
  1318.             {
  1319.                 advote += (rand()%rmn) *1;
  1320.             }
  1321.             break;
  1322.         default:
  1323.             if(primeministernum == oppositionnum)
  1324.             {
  1325.                 advote += (rand()%rmn) * 0.10;
  1326.             }else
  1327.             {
  1328.                 advote += (rand()%rmn) * 0.5;
  1329.             }
  1330.         }
  1331.     }
  1332.  
  1333.  
  1334.  
  1335.     int kal = rand()%100;
  1336.     if(kal >50)
  1337.     {
  1338.         advote += (rand()%rmn)/100;
  1339.     } else if(kal <50 && kal >30)
  1340.     {
  1341.         advote += (rand()%rmn)/50;
  1342.     } else if( kal < 30 && kal > 10)
  1343.     {
  1344.         advote += (rand()%rmn)/20;
  1345.     } else if(kal <10 && kal >3)
  1346.     {
  1347.         advote += rand()%rmn;
  1348.     } else
  1349.     {
  1350.         advote += (rand()%rmn)*2;
  1351.     }
  1352.  
  1353.     if(pcro[presidentnum] == pcro[oppositionnum])
  1354.     {
  1355.         if(av_correspond == presidentnum || av_correspond == oppositionnum)
  1356.         {
  1357.             advote -= advote * 0.50;
  1358.         }
  1359.     }
  1360.     if(pflags[av_correspond] == fpol)
  1361.     {
  1362.         advote += advote * 0.25;
  1363.     }
  1364.  
  1365.     if(ismajor[av_correspond] == true)
  1366.     {
  1367.         advote += advote*0.25;
  1368.         if(av_correspond != presidentnum && av_correspond != oppositionnum)
  1369.         {
  1370.             advote += advote*2;
  1371.         }
  1372.     }
  1373.  
  1374.  
  1375.     float pla = popularity[av_correspond]/100;
  1376.     advote += advote * pla;
  1377.  
  1378.     if(av_correspond == presidentnum)
  1379.     {
  1380.         float tsl = (year - ppyear)/ 200;
  1381.         advote -= advote * tsl;
  1382.  
  1383.  
  1384.     }
  1385.  
  1386.  
  1387.  
  1388.     for(int i=0; i!=5; i++)
  1389.     {
  1390.         if(acronum[i] == acronum[av_correspond] && i != av_correspond)
  1391.         {
  1392.             advote -= advote*0.1;
  1393.         }
  1394.     }
  1395.  
  1396.  
  1397.     if(fair == false)
  1398.     {
  1399.         if(av_correspond != presidentnum)
  1400.         {
  1401.             advote = advote /100;
  1402.         }
  1403.  
  1404.     }
  1405.  
  1406.     float qwer = (5 - abs(trending - pflags[acronum[av_correspond]]))/100;
  1407.     advote += advote * qwer;
  1408.  
  1409.     //float paut = (p_auth[av_correspond]+10)/100;
  1410.  
  1411.     //advote += advote*paut;
  1412.  
  1413.     if(junta == true && av_correspond == milenem)
  1414.     {
  1415.         advote = advote /10;
  1416.     }
  1417.  
  1418.  
  1419.     if(trending == acronum[av_correspond] && junta == false)
  1420.     {
  1421.         advote += advote *0.75;
  1422.     }
  1423.     if(acronum[presidentnum] > 3 && acronum[oppositionnum] > 3)
  1424.     {
  1425.         if(acronum[av_correspond] <=3)
  1426.         {
  1427.             advote += advote*0.75;
  1428.         } else if(av_correspond == presidentnum || av_correspond == oppositionnum)
  1429.         {
  1430.             advote -= advote * 0.75;
  1431.         }
  1432.     }
  1433.  
  1434.     if(acronum[presidentnum] < 3 && acronum[oppositionnum] < 3)
  1435.     {
  1436.         if(acronum[av_correspond] >=3)
  1437.         {
  1438.             advote += advote*0.75;
  1439.         } else if(av_correspond == presidentnum || av_correspond == oppositionnum)
  1440.         {
  1441.             advote -= advote * 0.75;
  1442.         }
  1443.     }
  1444.  
  1445.     float fly = (friendly[av_correspond]+10)/100;
  1446.     advote += advote*fly;
  1447.     if(av_correspond == presidentnum)
  1448.     {
  1449.         float age = (year-presyear) /100;
  1450.         advote -= advote*age;
  1451.     }
  1452.  
  1453.     int aconvert = (int) advote;
  1454.  
  1455.  
  1456.     return aconvert;
  1457. }
  1458.  
  1459. void count_total()
  1460. {
  1461.     prvtot = totalvotes;
  1462.     totalvotes =0;
  1463.     for(int i=0; i!=5; i++)
  1464.     {
  1465.         par_votes_int[i] = (int) par_votes[i];
  1466.         totalvotes += par_votes_int[i];
  1467.     }
  1468. }
  1469.  
  1470. void oppoprimaries()
  1471. {
  1472.     int wvotes =0;
  1473.     int opint[5];
  1474.     for(int i=0; i!=5; i++)
  1475.     {
  1476.         opint[i] = par_seats_int[i];
  1477.     }
  1478.     if((acronum[presidentnum] > 3 && acronum[oppositionnum] > 3) || (acronum[presidentnum] < 3 && acronum[oppositionnum] < 3))
  1479.     {
  1480.         opint[oppositionnum] = opint[oppositionnum]*0.9;
  1481.     }
  1482.  
  1483.     for(int i=0; i!=oppomembers; i++)
  1484.     {
  1485.         opint[omem[i]] += abs(acronum[omem[i]] - acronum[presidentnum]) * (opint[omem[i]]*0.10);
  1486.     }
  1487.  
  1488.     for(int i=0; i!= oppomembers; i++)
  1489.     {
  1490.         if(opint[omem[i]] > wvotes)
  1491.         {
  1492.             oppositionnum = omem[i];
  1493.             wvotes = opint[omem[i]];
  1494.         }
  1495.     }
  1496. }
  1497.  
  1498. void vcalc()
  1499. {
  1500.     for(int i=0; i!=5; i++)
  1501.     {
  1502.         par_percent[i] = (par_votes[i] / totalvotes);
  1503.         par_percent_int[i] = (int)(par_percent[i]*100);
  1504.     }
  1505. }
  1506.  
  1507. float tseats =0;
  1508. float remaining =0;
  1509.  
  1510. void seatcalc()
  1511. {
  1512.     tseats =0;
  1513.     seatcheck =0;
  1514.     for(int i=0; i!=5; i++)
  1515.     {
  1516.         tseats += par_seats[i];
  1517.     }
  1518.     remaining =0;
  1519.     remaining = seats-tseats;
  1520.     for(int i=0; i!=5; i++)
  1521.     {
  1522.         par_seats[i] += round(remaining * par_percent[i]);
  1523.         par_seats_int[i] = (int) par_seats[i];
  1524.     }
  1525. }
  1526.  
  1527. void prescalc()
  1528. {
  1529.     int loservotes =1;
  1530.     pres_votes =1;
  1531.  
  1532.     for(int i=0; i!=5; i++)
  1533.     {
  1534.         if(par_votes_int[i] > pres_votes)
  1535.         {
  1536.             presidentnum = i;
  1537.             pres_votes = par_votes_int[i];
  1538.         }
  1539.     }
  1540.     for(int i=0; i!=5; i++)
  1541.     {
  1542.         if(par_votes_int[i] < pres_votes && par_votes_int[i] > loservotes)
  1543.         {
  1544.             oppositionnum =i;
  1545.             loservotes = par_votes_int[i];
  1546.         }
  1547.     }
  1548.  
  1549.  
  1550.     gmem[govmembers] = presidentnum;
  1551.     govseats += par_seats_int[presidentnum];
  1552.     govper += par_percent_int[presidentnum];
  1553.     govmembers++;
  1554.     if(pres_votes >= (totalvotes/2))
  1555.     {
  1556.         cout << cannames[presidentnum] << " (" << par_name[presidentnum] << ") has won the Presidency by a Majority!" << endl;
  1557.     } else
  1558.     {
  1559.         cout << cannames[presidentnum] << " (" << par_name[presidentnum] << ") has won the Presidency by a Plurality!" << endl;
  1560.     }
  1561.  
  1562.     if(par_name[presidentnum] != ppar)
  1563.     {
  1564.         ppar = par_name[presidentnum];
  1565.         psyear = year;
  1566.     }
  1567.  
  1568.     if(presidentnum != prevpar)
  1569.     {
  1570.         prevpar = presidentnum;
  1571.         prevideo = pcro[prevpar];
  1572.         ppyear = year;
  1573.     }
  1574.  
  1575.  
  1576.     if(cannames[presidentnum] != presprename && junta == false)
  1577.     {
  1578.         ofstream presfile;
  1579.         presfile.open("Presidents.txt", fstream::app);
  1580.         presfile << presprename << " (" << prevpres << " | " << prevideo << ") " << presyear << " - " << year << endl;
  1581.         presfile.close();
  1582.         presyear = year;
  1583.         prevpres = par_name[presidentnum];
  1584.         presprename = cannames[presidentnum];
  1585.     }
  1586.     if( cannames[presidentnum] != presprename && junta == true && ot == true)
  1587.     {
  1588.         ot = false;
  1589.         ofstream presfile;
  1590.         presfile.open("Presidents.txt", fstream::app);
  1591.         presfile << par_name[5] << " " << presyear << " - " << year << endl;
  1592.         presfile.close();
  1593.         presyear = year;
  1594.         prevpres = par_name[presidentnum];
  1595.         presprename = cannames[presidentnum];
  1596.     } else if( cannames[presidentnum] != presprename && junta == true && ot == false)
  1597.     {
  1598.         ofstream presfile;
  1599.         presfile.open("Presidents.txt", fstream::app);
  1600.         presfile << presprename << " (" << prevpres <<   " | " << prevideo <<  ") " << presyear << " - " << year << endl;
  1601.         presfile.close();
  1602.         presyear = year;
  1603.         prevpres = par_name[presidentnum];
  1604.         presprename = cannames[presidentnum];
  1605.     }
  1606.     pname = cannames[presidentnum];
  1607. }
  1608.  
  1609. void coalitionform()
  1610. {
  1611.  
  1612.  
  1613.     oppomembers =0;
  1614.     omem[oppomembers] = 0;
  1615.     opposition = "";
  1616.     opposeats += 0;
  1617.     oppoper += 0;
  1618.  
  1619.     opposition = par_name[oppositionnum];
  1620.     omem[oppomembers] = oppositionnum;
  1621.     opposeats += par_seats_int[oppositionnum];
  1622.     oppoper += par_percent_int[oppositionnum];
  1623.     oppomembers++;
  1624.  
  1625.     int gchance =0;
  1626.     int ochance =0;
  1627.  
  1628.     gchance = par_percent_int[presidentnum]/2;
  1629.     ochance = par_percent_int[oppositionnum]/2;
  1630.     int ichance = 10;
  1631.  
  1632.     //cout << "Prepared Variables" << endl;
  1633.  
  1634.     for(int i=0; i!=5; i++)
  1635.     {
  1636.         gchance = par_percent_int[presidentnum]/2;
  1637.     ochance = par_percent_int[oppositionnum]/2;
  1638.     ichance = ((gchance+ochance)*0.05)+1;
  1639.         if(i != presidentnum && i!= oppositionnum)
  1640.         {
  1641.             if(acronum[presidentnum] > acronum[i])
  1642.             {
  1643.                 ochance += (acronum[presidentnum] - acronum[i])*5;
  1644.             } else if (acronum[presidentnum] < acronum[i])
  1645.             {
  1646.                 ochance += (acronum[i]-acronum[presidentnum])*5;
  1647.             } else if(acronum[presidentnum] == acronum[i])
  1648.             {
  1649.                 gchance == 10;
  1650.             }
  1651.  
  1652.             if(acronum[oppositionnum] > acronum[i])
  1653.             {
  1654.                 gchance += (acronum[oppositionnum] - acronum[i])*5;
  1655.             } else if (acronum[oppositionnum] < acronum[i])
  1656.             {
  1657.                 gchance += (acronum[i]-acronum[oppositionnum])*5;
  1658.             }else if(acronum[oppositionnum] == acronum[i])
  1659.             {
  1660.                 ochance == 10;
  1661.             }
  1662.  
  1663.  
  1664.             if(pflags[i] == pflags[presidentnum])
  1665.             {
  1666.                 if(presidentnum > i)
  1667.                 {
  1668.                     gchance += (presidentnum - i)*5;
  1669.                 } else
  1670.                 {
  1671.                     gchance += (i-presidentnum)*5;
  1672.                 }
  1673.             } else if(pflags[i] == pflags[oppositionnum])
  1674.             {
  1675.                 if(oppositionnum > i)
  1676.                 {
  1677.                     gchance += (oppositionnum - i)*5;
  1678.                 } else
  1679.                 {
  1680.                     gchance += (i-oppositionnum)*5;
  1681.                 }
  1682.             } else
  1683.             {
  1684.                 if(pflags[i] > pflags[presidentnum])
  1685.                 {
  1686.                     ochance += (pflags[i] - pflags[presidentnum])*2;
  1687.                 } else
  1688.                 {
  1689.                     ochance += (pflags[presidentnum] - pflags[i])*2;
  1690.                 }
  1691.  
  1692.                 if(pflags[i] > pflags[oppositionnum])
  1693.                 {
  1694.                     gchance += (pflags[i] - pflags[oppositionnum])*2;
  1695.                 } else
  1696.                 {
  1697.                     gchance += (pflags[oppositionnum] - pflags[i])*2;
  1698.                 }
  1699.             }
  1700.             gchance += friendly[presidentnum]*2;
  1701.             ochance += friendly[oppositionnum]*2;
  1702.             if(par_seats_int[presidentnum] >= seats/2)
  1703.             {
  1704.                 ochance+=10;
  1705.                 gchance-=10;
  1706.             }
  1707.             if(snap == true)
  1708.             {
  1709.                 gchance *=10;
  1710.             }
  1711.             //cout << "Finished Manipulating Chances" << endl;
  1712.             // coalition chance
  1713.             /*long long ccer =0;
  1714.             long long totalChance = ochance + gchance + ichance;
  1715.  
  1716.             if (totalChance <= RAND_MAX) {
  1717.                 ccer = (rand() % totalChance) + 1;
  1718.             } else
  1719.             {
  1720.                 totalChance/=10;
  1721.                 ccer = (rand() % totalChance) + 1;
  1722.             }
  1723.  
  1724.             ccer = (rand()%(ochance + gchance + ichance))+1;*/
  1725.  
  1726.             int tchan = (ochance + gchance + ichance)+1;
  1727.             float ocp = (ochance / static_cast<float>(tchan)) * 100;
  1728.             float gcp = (gchance / static_cast<float>(tchan)) * 100;
  1729.             float icp = (ichance / static_cast<float>(tchan)) * 100;
  1730.  
  1731.             int evt = rand()%100;
  1732.             //cout << "Generated Random Number" << endl;
  1733.             if(evt >= ocp+icp)
  1734.             {
  1735.                 gmem[govmembers] = i;
  1736.                 govseats += par_seats_int[i];
  1737.                 govper += par_percent_int[i];
  1738.                 govmembers++;
  1739.             } else if(evt < ocp && evt > icp)
  1740.             {
  1741.                 omem[oppomembers] =i;
  1742.                 opposeats += par_seats_int[i];
  1743.                 oppoper += par_percent_int[i];
  1744.                 oppomembers++;
  1745.             } else
  1746.             {
  1747.                 imem[indepmembers] =i;
  1748.                 indepseats += par_seats_int[i];
  1749.                 indeper += par_percent_int[i];
  1750.                 indepmembers++;
  1751.             }
  1752.  
  1753.             //cout << "Finished Deciding Coalitions" << endl;
  1754.         }
  1755.     }
  1756.     if(oppositionnum == presidentnum)
  1757.     {
  1758.         oppositionnum = omem[rand()%oppomembers];
  1759.     }
  1760. }
  1761.  
  1762.  
  1763. void pmcalc()
  1764. {
  1765.     float goseats = (float) govseats, opseats = (float) opposeats, inseats = (float) indepseats;
  1766.     goseats = (goseats/seats)*100;
  1767.     opseats = (opseats/seats)*100;
  1768.     inseats = (inseats/seats)*100;
  1769.     govper = (int) goseats;
  1770.     oppoper = (int) opseats;
  1771.     indeper = (int) inseats;
  1772.     bool hasfoundpm = false;
  1773.     int gplu =0;
  1774.  
  1775.  
  1776.     if(govseats+1 > opposeats && indepseats < (govseats+1) + opposeats)
  1777.     {
  1778.         int tgovseats = 0;
  1779.         for(int i=0; i!= govmembers; i++)
  1780.         {
  1781.             tgovseats += par_seats_int[gmem[i]];
  1782.         }
  1783.         cout << "The Ruling Party has secured a majority in parliament" << endl;
  1784.         if(par_seats_int[presidentnum] > tgovseats/2)
  1785.         {
  1786.             primeministernum = presidentnum;
  1787.         }else
  1788.         {
  1789.             int wnp =0;
  1790.             int wnr = 6;
  1791.             for(int i=0; i!= govmembers; i++)
  1792.             {
  1793.                 //cout << "A" << endl;
  1794.                 if(par_seats_int[gmem[i]] > wnp)
  1795.                 {
  1796.                     wnp = par_seats_int[gmem[i]];
  1797.                     wnr = gmem[i];
  1798.                     //cout << "B" << endl;
  1799.                 }
  1800.             }
  1801.             primeministernum = wnr;
  1802.         }
  1803.         //cout << "Finished picking a PM" << endl;
  1804.  
  1805.         cout << pcannames[primeministernum] << "(" << par_name[primeministernum] << ") has been appointed Prime Minister" << endl;
  1806.  
  1807.     } else
  1808.     {
  1809.         if(indepseats >= (govseats+1) + opposeats)
  1810.         {
  1811.             cout << "A majority in parliament has declared a boycott. \nSnap elections have been scheduled later this year" << endl;
  1812.         intervals = 0;
  1813.         primeministernum = 6;
  1814.         } else if(opposeats >= govseats+1)
  1815.         {
  1816.  
  1817.         int tgovseats = 0;
  1818.         for(int i=0; i!= oppomembers; i++)
  1819.         {
  1820.             tgovseats += par_seats_int[omem[i]];
  1821.         }
  1822.         cout << "The Opposition has secured a majority in parliament" << endl;
  1823.         if(par_seats_int[oppositionnum] > tgovseats/2)
  1824.         {
  1825.             primeministernum = oppositionnum;
  1826.         }else
  1827.         {
  1828.             int wnp =0;
  1829.             int wnr = 6;
  1830.             for(int i=0; i!= oppomembers; i++)
  1831.             {
  1832.                 //cout << "A" << endl;
  1833.                 if(par_seats_int[omem[i]] > wnp)
  1834.                 {
  1835.                     wnp = par_seats_int[omem[i]];
  1836.                     wnr = omem[i];
  1837.                     //cout << "B" << endl;
  1838.                 }
  1839.             }
  1840.             primeministernum = wnr;
  1841.         }
  1842.         //cout << "Finished picking a PM" << endl;
  1843.  
  1844.         cout << pcannames[primeministernum] << "(" << par_name[primeministernum] << ") has been appointed Prime Minister" << endl;
  1845.  
  1846.  
  1847.         }
  1848.  
  1849.     }
  1850.  
  1851.  
  1852.     if(oppomembers == 0)
  1853.     {
  1854.         oppositionnum = 7;
  1855.         opposition = "";
  1856.     }
  1857.  
  1858.     pmname = pcannames[primeministernum];
  1859.  
  1860.     if(pcannames[primeministernum] != premprename && junta == false)
  1861.     {
  1862.         ofstream pmfile;
  1863.         pmfile.open("Premieres.txt", fstream::app);
  1864.         pmfile << premprename << " (" << prevprem << ") " << premyear << " - " << year << endl;
  1865.         pmfile.close();
  1866.         premyear = year;
  1867.         prevprem =par_name[primeministernum];
  1868.         premprename = pcannames[primeministernum];
  1869.     }
  1870.     if( pcannames[primeministernum] != premprename && junta == true && ot == true)
  1871.     {
  1872.         ot = false;
  1873.         ofstream pmfile;
  1874.         pmfile.open("Premieres.txt", fstream::app);
  1875.         pmfile << premprename << " (" << par_name[5] << ") " << premyear << " - " << year << endl;
  1876.         pmfile.close();
  1877.         premyear = year;
  1878.         prevprem =par_name[primeministernum];
  1879.         premprename = pcannames[primeministernum];
  1880.     } else if( pcannames[primeministernum] != premprename && junta == true && ot == false)
  1881.     {
  1882.         ofstream pmfile;
  1883.         pmfile.open("Premieres.txt", fstream::app);
  1884.         pmfile << premprename << " (" << prevprem << ") " << premyear << " - " << year << endl;
  1885.         pmfile.close();
  1886.         premyear = year;
  1887.         prevprem =par_name[primeministernum];
  1888.         premprename = pcannames[primeministernum];
  1889.     }
  1890.     if(cannames[primeministernum] == pcannames[primeministernum])
  1891.     {
  1892.         premprename = cannames[primeministernum];
  1893.     } else
  1894.     {
  1895.         premprename = pcannames[primeministernum];
  1896.     }
  1897.  
  1898. }
  1899.  
  1900. void converttoint()
  1901. {
  1902.     for(int i=0; i!=5; i++)
  1903.     {
  1904.         par_percent_int[i] = (int)(par_percent[i]*100);
  1905.         par_votes_int[i] = (int)par_votes[i];
  1906.     }
  1907. }
  1908.  
  1909. void restart()
  1910. {
  1911.     president = par_name[presidentnum];
  1912.     primeminister = par_name[primeministernum];
  1913.     opposition = par_name[oppositionnum];
  1914.     plurality =0;
  1915.     pluralvotes =0;
  1916.  
  1917.  
  1918.  
  1919.     if(people < 30 && people > 10 && primeministernum != 6)
  1920.     {
  1921.         intervals -= 3/(people/10);
  1922.     } else if(people <=10 && primeministernum != 6)
  1923.     {
  1924.         intervals += people/10;
  1925.     }
  1926.  
  1927.  
  1928.     pefav = trending;
  1929.     if(fair == true)
  1930.     {
  1931.         for(int i=0; i!=5; i++)
  1932.     {
  1933.         popularity[i] = par_percent[i];
  1934.         if(popularity[i] < 0.01)
  1935.         {
  1936.             popularity[i] =0.01;
  1937.         }
  1938.     }
  1939.     }
  1940.  
  1941.     /*for(int i=0; i!=5; i++)
  1942.     {
  1943.         cout << popularity[i];
  1944.     }
  1945.     string inp;
  1946.     cin >> inp;*/
  1947.  
  1948.  
  1949.     for(int i=0; i!=5; i++)
  1950.     {
  1951.         isnew[i] = false;
  1952.         if(rand()%100 > par_percent_int[i] && par_seats_int[i] <= seats*0.10 && intervals >1 && i != presidentnum && i!= primeministernum)
  1953.         {
  1954.             if(i == oppositionnum)
  1955.             {
  1956.                 oppositionnum = 6;
  1957.             }
  1958.             acronum[i] = rand()%5;
  1959.             par_name[i] = allparties[acronum[i]][rand()%9];
  1960.             pcro[i] = ideologies[acronum[i]][rand()%4];
  1961.             isnew[i] = true;
  1962.             prevseats[i] = 0;
  1963.             prevpercent[i] = 0;
  1964.             canyear[i] = year;
  1965.             indivgen(i);
  1966.             shiftcomp(i);
  1967.             p_auth[i] = (rand()%10) -(5+(abs(acronum[i]-3)*2));
  1968.             pflags[i] = (rand()%minumpol)+acronum[i];
  1969.             friendly[i] = (rand()%20)-10;
  1970.         }
  1971.     }
  1972.  
  1973.  
  1974.     par_name[presidentnum] = president;
  1975.     par_name[primeministernum] = primeminister;
  1976.     par_name[oppositionnum] = opposition;
  1977.  
  1978.     int mf = rand()%10;
  1979.     int polyear = startyear;
  1980.  
  1981.  
  1982.     for(int i=0; i!=5; i++)
  1983.     {
  1984.         prevseats[i] = par_seats_int[i];
  1985.         prevpercent[i] = par_percent_int[i];
  1986.     }
  1987.  
  1988.     for(int i=0; i!=5; i++)
  1989.     {
  1990.  
  1991.          par_coal[i]=0;
  1992.  par_seats[i]=0;
  1993.  par_seats_int[i]=0;
  1994.  
  1995.  par_votes[i] =10;
  1996.  par_votes_int[i] =0;
  1997.  
  1998.  par_percent[i] =0;
  1999.  par_percent_int[i] =0;
  2000.  
  2001.  
  2002.  totalvotes =0;
  2003.  
  2004.  pres_votes =0;
  2005.  
  2006.  
  2007. govper=0;
  2008. oppoper =0;
  2009. indeper=0;
  2010. govmembers=0;
  2011.  gmem[i] =0;
  2012.  govseats =0;
  2013.  
  2014.  oppomembers =0;
  2015.  omem[i] =0;
  2016.  opposeats =0;
  2017.  
  2018.  indepmembers =0;
  2019.  imem[i] =0;
  2020.  indepseats =0;
  2021.  
  2022.  av_correspond =0;
  2023.  
  2024.     }
  2025.  
  2026.  
  2027.     if(primeministernum != 6 && intervals < 1)
  2028.     {
  2029.         intervals = 1;
  2030.     }
  2031. }
  2032.  
  2033.  
  2034. void updates()
  2035. {
  2036.     int mf = rand()%10;
  2037.     int polyear = startyear;
  2038.     if(junta == true && rand()%100 < year - juntayear)
  2039.     {
  2040.         junta = false;
  2041.     }
  2042.  
  2043.     if(junta == true)
  2044.     {
  2045.         people += (year - presyear)/10;
  2046.     }
  2047.  
  2048.     if(rand()%15 < (year-trendyear))
  2049.     {
  2050.         trending = rand()%4;
  2051.         trendyear = year;
  2052.     }
  2053.     for(int i=0; i!= intervals; i++)
  2054.     {
  2055.         updateauth();
  2056.         bbcupdate();
  2057.         ecupdate();
  2058.         mupdate();
  2059.         uppop();
  2060.         //string upt;
  2061.         //cin>> upt;
  2062.     }
  2063.  
  2064.     for(int i=0; i!=5; i++)
  2065.     {
  2066.         int s = rand()%75;
  2067.         if(fair == true)
  2068.         {
  2069.             s = rand()%50;
  2070.         } else
  2071.         {
  2072.             s = rand()%80;
  2073.         }
  2074.         s += year-canyear[i];
  2075.         if(s > par_percent_int[i] - (((year-canyear[i])+ friendly[i])- p_auth[i]) && intervals >1 && wassnap == false)
  2076.     {
  2077.         if(rand()%100 > par_percent_int[i])
  2078.         {
  2079.             if(i == presidentnum)
  2080.             {
  2081.                 cannames[i] = pname;
  2082.                 pflags[i] = (rand()%minumpol)+acronum[i];
  2083.                 pcro[i] = ideologies[acronum[i]][rand()%4];
  2084.             shiftcomp(i);
  2085.             p_auth[i] = (rand()%10) -(5+(abs(acronum[i]-3)*2));
  2086.             friendly[i] = (rand()%20)-10;
  2087.             } else
  2088.             {
  2089.              cannames[i] = pcannames[i];
  2090.             pflags[i] = (rand()%minumpol)+acronum[i];
  2091.             shiftcomp(i);
  2092.             p_auth[i] = (rand()%10) -(5+(abs(acronum[i]-3)*2));
  2093.             friendly[i] = (rand()%20)-10;
  2094.             pcro[i] = ideologies[acronum[i]][rand()%2];
  2095.             }
  2096.         } else
  2097.         {
  2098.             canyear[i] = year;
  2099.         indivgen(i);
  2100.         pcro[i] = ideologies[acronum[i]][rand()%2];
  2101.         pflags[i] = (rand()%minumpol)+acronum[i];
  2102.         shiftcomp(i);
  2103.         p_auth[i] = (rand()%10) -(5+(abs(acronum[i]-3)*2));
  2104.         friendly[i] = (rand()%20)-10;
  2105.         popularity[i] -= 10;
  2106.         }
  2107.     }
  2108.     }
  2109.     for(int i=0; i!=5; i++)
  2110.     {
  2111.         int v = rand()%100;
  2112.         if(v > par_percent_int[i] - (year-pcanyear[i]))
  2113.     {
  2114.         pcanyear[i] = year;
  2115.         pmindivgen(i);
  2116.     }
  2117.     }
  2118.  
  2119.  
  2120.     if(rand()%50 < year - polyear)
  2121.     {
  2122.         polyear = year;
  2123.         switch(mf)
  2124.         {
  2125.         case 1:
  2126.             pfloat = 0.20;
  2127.         case 2:
  2128.             pfloat = 0.25;
  2129.         case 3:
  2130.             pfloat = 0.30;
  2131.         case 4:
  2132.             pfloat = 0.35;
  2133.         case 5:
  2134.             pfloat = 0.40;
  2135.         case 6:
  2136.             pfloat = 0.45;
  2137.         case 7:
  2138.             pfloat = 0.50;
  2139.         case 8:
  2140.             pfloat = 0.55;
  2141.         case 9:
  2142.             pfloat = 0.60;
  2143.         case 10:
  2144.             pfloat = 0.65;
  2145.         default:
  2146.             break;
  2147.         }
  2148.     }
  2149.  
  2150.     /*if(primeministernum == presidentnum)
  2151.     {
  2152.         if(rand()%100 < par_percent_int[primeministernum]*0.75 && intervals >1)
  2153.         {
  2154.             cannames[presidentnum] = pcannames[primeministernum];
  2155.         }
  2156.     }*/
  2157.  
  2158.     domode();
  2159.     if(wassnap == true)
  2160.     {
  2161.         wassnap = false;
  2162.     }
  2163.     fpol = rand()%13;
  2164.  
  2165. }
  2166.  
  2167.  
  2168. void calcdif()
  2169. {
  2170.  
  2171.      /*int difference = ((year - startyear)/10) +2;
  2172.  seats = rand()%difference;
  2173.      regions += rand()%difference;
  2174.  float tdif = (float)totalvotes, ttot = (float) prevtot;
  2175.  if(totalvotes > prevtot)
  2176.  {
  2177.      tdif = (tdif-ttot) /totalvotes;
  2178.  } else
  2179.  {
  2180.      tdif = (ttot-tdif) /prevtot;
  2181.  }
  2182.  
  2183.  seats += regions*2;
  2184.  seats += round(seats*tdif);
  2185.  if(seats <=3)
  2186.  {
  2187.      seats =3;
  2188.  }*/
  2189.  regions += rand()%5;
  2190.  float difference = (float)(population - prevpop)/population;
  2191.  float cnge = (float) ((rand()%10)-5)/100;
  2192.  difference += cnge;
  2193.  seats = regions;
  2194. seats += seats*difference;
  2195. if(seats <regions)
  2196. {
  2197.     seats = regions;
  2198. }
  2199.  
  2200.  
  2201.  
  2202. }
  2203.  
  2204.  
  2205. void dispall()
  2206. {
  2207.     int lowerhouse =0;
  2208.     for(int i=0; i!=5; i++)
  2209.     {
  2210.         lowerhouse += lhgains[i];
  2211.     }
  2212.     int upperhouse = 0;
  2213.     for(int i=0; i!=5; i++)
  2214.     {
  2215.         upperhouse += par_seats_int[i] - lhgains[i];
  2216.     }
  2217.     for(int i =0; i!=5; i++)
  2218.     {
  2219.         cout << "======================================" << endl;
  2220.         if(cannames[i] == pcannames[i])
  2221.         {
  2222.             cout << cannames[i] << " - " << par_name[i] << " (" << pcro[i] << ")\n" << par_votes_int[i] << " (" << par_percent_int[i] << "% | ";
  2223.         } else
  2224.         {
  2225.             cout << cannames[i] << " / " << pcannames[i] << " - " << par_name[i] << " (" << pcro[i] << ")\n" << par_votes_int[i] << " (" << par_percent_int[i] << "% | ";
  2226.         }
  2227.         if(isnew[i] != true)
  2228.         {
  2229.             if(par_percent_int[i] >= prevpercent[i])
  2230.         {
  2231.             cout << "+" << par_percent_int[i] - prevpercent[i] << "%)" << endl;
  2232.         }else
  2233.         {
  2234.             cout << par_percent_int[i] - prevpercent[i] << "%)" << endl;
  2235.         }
  2236.         } else
  2237.         {
  2238.             if(par_percent_int[i] >= prevpercent[i])
  2239.             {
  2240.             cout << "+" << par_percent_int[i] - prevpercent[i] << "%) - NEW" << endl;
  2241.             }else
  2242.             {
  2243.                 cout << par_percent_int[i] - prevpercent[i] << "%) - NEW" << endl;
  2244.             }
  2245.         }
  2246.  
  2247.  
  2248.         for(int b=0; b< par_percent_int[i]; b++)
  2249.         {
  2250.             cout << "|";
  2251.         }
  2252.         cout << "\nTotal Seats Won: " << par_seats_int[i] << " (US: " << par_seats_int[i] - lhgains[i] << " | LS: " << lhgains[i] << " | ";
  2253.  
  2254.         if(isnew[i] != true)
  2255.         {
  2256.             if(par_seats_int[i] >= prevseats[i])
  2257.         {
  2258.             cout << "+" << par_seats_int[i] - prevseats[i] << ")" << endl;
  2259.         }else
  2260.         {
  2261.             cout << par_seats_int[i] - prevseats[i] << ")" << endl;
  2262.         }
  2263.         } else
  2264.         {
  2265.             if(par_seats_int[i] >= prevseats[i])
  2266.             {
  2267.             cout << "+" << par_seats_int[i] - prevseats[i] << ") - NEW" << endl;
  2268.             }else
  2269.             {
  2270.                 cout << par_seats_int[i] - prevseats[i] << ") - NEW" << endl;
  2271.             }
  2272.         }
  2273.         cout << "FLAGSHIP POLICY: " << flags[pflags[i]] << endl;
  2274.  
  2275.  
  2276.     }
  2277. }
  2278.  
  2279. void checkmajors()
  2280. {
  2281.  
  2282.     for(int i=0; i!=5; i++)
  2283.     {
  2284.         ismajor[i] = false;
  2285.     }
  2286.     for(int i=0; i!=5; i++)
  2287.     {
  2288.         if(par_percent_int[i] >= 10)
  2289.         {
  2290.             ismajor[i] = true;
  2291.         }
  2292.     }
  2293. }
  2294.  
  2295. int main()
  2296. {
  2297.     srand(time(NULL));
  2298.     //cngen();
  2299.     population += rand()%population;
  2300.     shiffty = (rand()%3)*5;
  2301.     trending = rand()%5;
  2302.     fpol = rand()%13;
  2303.     for(int i=0; i!=5; i++)
  2304.     {
  2305.         acronum[i] = rand()%5;
  2306.         par_name[i] = allparties[acronum[i]][rand()%9];
  2307.         pcro[i] = ideologies[acronum[i]][rand()%4];
  2308.         isnew[i] = true;
  2309.         prevseats[i] = 0;
  2310.         prevpercent[i] = 0;
  2311.         canyear[i] = year;
  2312.         indivgen(i);
  2313.         pmindivgen(i);
  2314.         shiftcomp(i);
  2315.         p_auth[i] = (rand()%10) -(5+(abs(acronum[i]-3)*2));
  2316.         pflags[i] = (rand()%minumpol)+acronum[i];
  2317.         friendly[i] = (rand()%20)-10;
  2318.     }
  2319.     policy = ((rand()%13) *5)+35;
  2320.         pfloat = (float) policy/100;
  2321.     ofstream presfile;
  2322. presfile.open("Presidents.txt");
  2323.     presfile << "FILE SCCUESSFULLY CREATED" << endl;
  2324.     presfile.close();
  2325.     ofstream pmfile;
  2326. pmfile.open("Premieres.txt");
  2327.     pmfile << "FILE SCCUESSFULLY CREATED" << endl;
  2328.     pmfile.close();
  2329.  
  2330.     ofstream erecord;
  2331. erecord.open("Elections.txt");
  2332.     erecord << "FILE SCCUESSFULLY CREATED" << endl;
  2333.     erecord.close();
  2334.  
  2335.     trending = rand()%5;
  2336.  
  2337.     game:
  2338.         system("CLS");
  2339.     cout << "Votes are being counted..." << endl;
  2340.     upturnout();
  2341.     calcto();
  2342.     int pvb[5];
  2343.     //cout << votingpops << endl;
  2344.     //string asl;
  2345.     //cin >> asl;
  2346.     float cdt = turnout*100;
  2347.     int rct = (int) cdt;
  2348.     int i= votingpops;
  2349.     while(i > votingpops*0.01)
  2350.     {
  2351.  
  2352.         count_total();
  2353.         for(int b=0; b!=5; b++)
  2354.         {
  2355.             av_correspond =b;
  2356.             pvb[b] = par_votes[b];
  2357.             float mik = (float) 0.01+ (popularity[av_correspond]/100);
  2358.             //cout << mik << endl;
  2359.             //cin>> userinput;
  2360.             par_votes[b] += add_votes(i*mik);
  2361.             int slr = par_votes[b] - pvb[b];
  2362.             i-= slr;
  2363.         }
  2364.  
  2365.         count_total();
  2366.         //i -= totalvotes- prvtot;
  2367.  
  2368.         //string inp;
  2369.         //cin >> inp;
  2370.         vcalc();
  2371.     converttoint();
  2372.  
  2373.  
  2374.     system("CLS");
  2375.     /*cout << "Total Votes: " << totalvotes << endl;
  2376.         cout << "voters remaining: " << i << endl;
  2377.         cout << "turnout: " << turnout << endl;*/
  2378.     if(snap == false)
  2379.     {
  2380.         if(midterm == true)
  2381.         {
  2382.             cout << year << " Parliamentary Elections Opinion Polls:" << endl;
  2383.         } else
  2384.         {
  2385.             cout << year << " General Elections Opinion Polls:" << endl;
  2386.         }
  2387.     } else
  2388.     {
  2389.         cout << year << " Snap Elections Opinion Polls:" << endl;
  2390.     }
  2391.             cout << "President: " << pname << "("<< president << ")" << endl;
  2392.             cout << "Prime Minister: " << pmname << "("<< primeminister << ")"  << endl;
  2393.             cout << "Opposition: " << pcannames[oppositionnum] << "("<< opposition << ")"  << endl;
  2394.             cout << endl;
  2395.             /*int lowerhouse = round(seats * pfloat);
  2396.     int upperhouse = round(seats - lowerhouse);
  2397.             cout << "Seats Last Election: " << seats << endl;
  2398.             cout << "-Upper House: " << upperhouse << endl;
  2399.             cout << "-Lower House: " << lowerhouse << endl;*/
  2400.         for(int i =0; i!=5; i++)
  2401.     {
  2402.         cout << "======================================" << endl;
  2403.         if(cannames[i] == pcannames[i])
  2404.         {
  2405.             cout << cannames[i] << " - " << par_name[i] << " (" << pcro[i] << ")\n" << par_votes_int[i] << " (" << par_percent_int[i] << "%)" << endl;
  2406.         }else
  2407.         {
  2408.             cout << cannames[i] << " / " << pcannames[i] << " - " << par_name[i] << " (" << pcro[i]<< ")\n" << par_votes_int[i] << " (" << par_percent_int[i] << "%)" << endl;
  2409.         }
  2410.  
  2411.         for(int b=0; b< par_percent_int[i]; b++)
  2412.         {
  2413.             cout << "|";
  2414.         }
  2415.  
  2416.         cout << endl;
  2417.         cout << "FLAGSHIP POLICY: " << flags[pflags[i]] << endl;
  2418.     }
  2419.     //std::this_thread::sleep_for(std::chrono::milliseconds(500));
  2420.  
  2421.     }
  2422.     system("CLS");
  2423.     prevtot = totalvotes;
  2424.     count_total();
  2425.     vcalc();
  2426.     converttoint();
  2427.     calcdif();
  2428.     countplural();
  2429.         cutoff();
  2430.     if(fair == true)
  2431.     {
  2432.        /*if(mode == 0)
  2433.         {
  2434.             sainteleague();
  2435.         } else if(mode == 1)
  2436.         {
  2437.             dsdhondt();
  2438.         }*/
  2439.         dsdhondt();
  2440.  
  2441.     }else
  2442.     {
  2443.         discont();
  2444.     }
  2445.     seatcalc();
  2446.     checkmajors();
  2447.  
  2448.  
  2449.     if(snap == false)
  2450.     {
  2451.         if(midterm == true)
  2452.         {
  2453.             cout << year << " Parliamentary Elections" << endl;
  2454.         } else
  2455.         {
  2456.             cout << year << " General Elections" << endl;
  2457.         }
  2458.     } else
  2459.     {
  2460.         cout << year << " Snap Elections" << endl;
  2461.     }
  2462.  
  2463.     calsplu();
  2464.     if(midterm == false || snap == true)
  2465.     {
  2466.         prescalc();
  2467.         //cout << "elected Pres" << endl;
  2468.     } else if(midterm == true || snap == true)
  2469.     {
  2470.         gmem[0] = presidentnum;
  2471.     govseats += par_seats_int[presidentnum];
  2472.     govper += par_percent_int[presidentnum];
  2473.     govmembers++;
  2474.     //cout << "Appointed Gov" << endl;
  2475.     }
  2476.  
  2477.  
  2478.     countplural();
  2479.     //cout << "counted plurality" << endl;
  2480.     oppoprimaries();
  2481.     coalitionform();
  2482.     //cout << "formed coalitions" << endl;
  2483.     pmcalc();
  2484.     //cout << "Appointed PM" << endl;
  2485.  
  2486.     cout << endl;
  2487. int lowerhouse =0;
  2488.     for(int i=0; i!=5; i++)
  2489.     {
  2490.         lowerhouse += lhgains[i];
  2491.     }
  2492.     int upperhouse = 0;
  2493.     for(int i=0; i!=5; i++)
  2494.     {
  2495.         upperhouse += par_seats_int[i] - lhgains[i];
  2496.     }
  2497.     /*cout << "Calculated House" << endl;
  2498.     system("CLS");
  2499.     if(midterm == true)
  2500.     {
  2501.         cout << year << " Parliamentary Elections" << endl;
  2502.     } else
  2503.     {
  2504.         cout << year << " General Elections" << endl;
  2505.     }*/
  2506.     cout << "President: " << pname << "("<< par_name[presidentnum] << ")" << endl;
  2507.     cout << "Prime Minister: " << pmname << "("<< par_name[primeministernum] << ")"  << endl;
  2508.     cout << "Opposition: " << pcannames[oppositionnum] << "("<< par_name[oppositionnum] << ")"  << endl;
  2509.     cout << "\nFlagship Policy: " << flags[pflags[presidentnum]];
  2510.     if(primeministernum != presidentnum && flags[pflags[primeministernum]] != flags[pflags[presidentnum]] && primeministernum != 6)
  2511.     {
  2512.         cout << " And " << flags[pflags[primeministernum]];
  2513.     }
  2514.     cout << endl;
  2515.     cout << "\nTotal Seats: " << upperhouse + lowerhouse;
  2516.     cout << " (Upper Seats: " << upperhouse;
  2517.     cout << " | Lower Seats: " << lowerhouse << ")" <<endl;
  2518.  
  2519.     float gfloat = govseats;
  2520.     float ofloat = opposeats;
  2521.     float ifloat = indepseats;
  2522.     seats = upperhouse + lowerhouse;
  2523.     cout << "Composition:" << endl;
  2524.     if(govseats >0)
  2525.     {
  2526.         if(indepseats >0)
  2527.         {
  2528.             cout << "Government: " << govseats << " Seats (" << round((gfloat/seats)*100)  << "% | "<< round((gfloat/(seats-indepseats))*100) << "%)"<< endl;
  2529.         }else
  2530.         {
  2531.          cout << "Government: " << govseats << " Seats (" << round((gfloat/seats)*100)  << "%)" << endl;
  2532.         }
  2533.         cout << "Members: ";
  2534.         for(int i=0; i!=govmembers; i++)
  2535.         {
  2536.             cout << par_name[gmem[i]];
  2537.             if(i != govmembers-1)
  2538.             {
  2539.                 cout << ", ";
  2540.             }
  2541.         }
  2542.     }
  2543.     if(opposeats > 0)
  2544.     {
  2545.         if(indepseats >0)
  2546.         {
  2547.             cout << "\n=====\nOpposition: " << opposeats << " Seats (" << round((ofloat/seats)*100)  << "% | "<< round((ofloat/(seats-indepseats))*100) << "%)"<< endl;
  2548.         }else
  2549.         {
  2550.          cout << "\n=====\nOpposition: " << opposeats << " Seats (" << round((ofloat/seats)*100)  << "%)" << endl;
  2551.         }
  2552.         for(int i=0; i!=oppomembers; i++)
  2553.         {
  2554.             cout << par_name[omem[i]];
  2555.             if(i != oppomembers-1)
  2556.             {
  2557.                 cout << ", ";
  2558.             }
  2559.         }
  2560.     }
  2561.  
  2562.     if(indepseats > 0)
  2563.     {
  2564.         cout << "\n=====\nBoycotting: " << indepseats<< " Seats (" << round((ifloat/seats)*100)  << "%)" << endl;
  2565.         for(int i=0; i!=indepmembers; i++)
  2566.         {
  2567.             cout << par_name[imem[i]];
  2568.             if(i != indepmembers-1)
  2569.             {
  2570.                 cout << ", ";
  2571.             }
  2572.         }
  2573.     }
  2574.     cout << endl;
  2575.  
  2576.     pecheck();
  2577.     covalues();
  2578.     mchange();
  2579.     pshift();
  2580.     cout << "\nMilitary Status: ";
  2581.     //cout << military << endl;
  2582.     switch(military/10)
  2583.     {
  2584.     case 1:
  2585.         cout << "General Dissatisfaction" << endl;
  2586.         break;
  2587.     case 2:
  2588.         cout << "Discontent Among Lower Ranks" << endl;
  2589.         break;
  2590.     case 3:
  2591.         cout << "Divided" << endl;
  2592.         break;
  2593.     case 4:
  2594.         cout << "Slight Disagreements" << endl;
  2595.         break;
  2596.     case 5:
  2597.         cout << "Low Support for Government" << endl;
  2598.         break;
  2599.     case 6:
  2600.         cout << "Apolitical Military" << endl;
  2601.         break;
  2602.     case 7:
  2603.         cout << "Generally Supportive" << endl;
  2604.         break;
  2605.     case 8:
  2606.         cout << "Secretly Endorses the Government" << endl;
  2607.         break;
  2608.     case 9:
  2609.         cout << "Open Military Endorsement" << endl;
  2610.         break;
  2611.     case 10:
  2612.         cout << "Fanatically Loyal" << endl;
  2613.     break;
  2614.     case 0:
  2615.         cout << "Strained Relations with the Government" << endl;
  2616.         break;
  2617.     case -1:
  2618.         cout << "Officers Openly Denouncing Government" << endl;
  2619.         break;
  2620.     case -2:
  2621.         cout << "Generally Disloyal Army" << endl;
  2622.         break;
  2623.     case -3:
  2624.         cout << "Small Outbreaks of Mutinies" << endl;
  2625.         break;
  2626.     case -4:
  2627.         cout << "Officers Leading Mutinies" << endl;
  2628.         break;
  2629.     case -5:
  2630.         cout << "Widespread Military Defections" << endl;
  2631.         break;
  2632.         default:
  2633.             if(military < 0)
  2634.             {
  2635.                 cout << "Military Coup Imminent" << endl;
  2636.             } else
  2637.             {
  2638.                 cout << "Fanatically Loyal" << endl;
  2639.             }
  2640.  
  2641.             break;
  2642.     }
  2643.  
  2644.     //cout << "Military-backed Party: " << par_name[milfav] << endl;
  2645.     //cout << "Military-opposed Party: " << par_name[milenem] << endl;
  2646.     cout << "National Status: ";
  2647.     //cout << people << endl;
  2648.     switch(people/10)
  2649.     {
  2650.     case 10:
  2651.     case 9:
  2652.         cout << "Nationwide Support" << endl;
  2653.         break;
  2654.     case 8:
  2655.     case 7:
  2656.     case 6:
  2657.     case 5:
  2658.         cout << "Supportive Populace" << endl;
  2659.         break;
  2660.     case 4:
  2661.     case 3:
  2662.     case 2:
  2663.     case 1:
  2664.         cout << "Indifferent People" << endl;
  2665.         break;
  2666.     case 0:
  2667.     case -1:
  2668.         cout << "Divided" << endl;
  2669.         break;
  2670.     case -2:
  2671.     case -3:
  2672.         cout << "General Discontent" << endl;
  2673.         break;
  2674.     case -4:
  2675.     case -5:
  2676.     case -6:
  2677.     case -7:
  2678.         cout << "Widespread Protests" << endl;
  2679.         break;
  2680.     case -8:
  2681.     case -9:
  2682.     default:
  2683.         if(people < 0)
  2684.         {
  2685.             cout << "Nationwide Riots" << endl;
  2686.         } else
  2687.         {
  2688.             cout << "Nationwide Support" << endl;
  2689.         }
  2690.         break;
  2691.     }
  2692.  
  2693.     cout << "Economic Status: ";
  2694.     //cout << economy << endl;
  2695.     switch(economy/10)
  2696.     {
  2697.     case 10:
  2698.     case 9:
  2699.     case 8:
  2700.     case 7:
  2701.         cout << "Booming" << endl;
  2702.         break;
  2703.     case 6:
  2704.     case 5:
  2705.     case 4:
  2706.     case 3:
  2707.         cout << "Expanding" << endl;
  2708.         break;
  2709.     case 2:
  2710.     case 1:
  2711.     case 0:
  2712.     case -1:
  2713.         cout << "Contracting" << endl;
  2714.         break;
  2715.     case -2:
  2716.     case -3:
  2717.     case -4:
  2718.     case -5:
  2719.         cout << "Recession" << endl;
  2720.         break;
  2721.     case -6:
  2722.     case -7:
  2723.     case -8:
  2724.     case -9:
  2725.         cout << "Depression" << endl;
  2726.         break;
  2727.     default:
  2728.         if(economy > 0)
  2729.         {
  2730.             cout << "Booming" << endl;
  2731.         }else
  2732.         {
  2733.             cout << "Depression" << endl;
  2734.         }
  2735.         break;
  2736.     }
  2737.     cout << "Freedom   Level: ";
  2738.     //cout << totauth << endl;
  2739.     switch(totauth/10)
  2740.     {
  2741.     case 10:
  2742.     case 9:
  2743.         cout << "High" << endl;
  2744.         break;
  2745.     case 8:
  2746.     case 7:
  2747.     case 6:
  2748.     case 5:
  2749.         cout << "Above Average" << endl;
  2750.         break;
  2751.     case 4:
  2752.     case 3:
  2753.     case 2:
  2754.     case 1:
  2755.     case 0:
  2756.     case -1:
  2757.         cout << "Average" << endl;
  2758.         break;
  2759.     case -2:
  2760.     case -3:
  2761.     case -4:
  2762.     case -5:
  2763.         cout << "Below Average" << endl;
  2764.         break;
  2765.     case -6:
  2766.     case -7:
  2767.     case -8:
  2768.     case -9:
  2769.         cout << "Low" << endl;
  2770.         break;
  2771.     default:
  2772.         if(totauth < 0)
  2773.         {
  2774.             cout << "Low" << endl;
  2775.         } else
  2776.         {
  2777.             cout << "High" << endl;
  2778.         }
  2779.         break;
  2780.     }
  2781.  
  2782.     cout << "Militancy Level: ";
  2783.     //cout << militancy << endl;
  2784.     switch(militancy/10)
  2785.     {
  2786.     case 10:
  2787.     case 9:
  2788.         cout << "None" << endl;
  2789.         break;
  2790.     case 8:
  2791.     case 7:
  2792.     case 6:
  2793.     case 5:
  2794.         cout << "Nothing Significant" << endl;
  2795.         break;
  2796.     case 4:
  2797.     case 3:
  2798.     case 2:
  2799.     case 1:
  2800.     case 0:
  2801.     case -1:
  2802.         cout << "Low Militancy" << endl;
  2803.         break;
  2804.     case -2:
  2805.     case -3:
  2806.     case -4:
  2807.     case -5:
  2808.         cout << "Some Militancy" << endl;
  2809.         break;
  2810.     case -6:
  2811.     case -7:
  2812.     case -8:
  2813.     case -9:
  2814.         cout << "Abundant Militancy" << endl;
  2815.         break;
  2816.     default:
  2817.         if(militancy < 0)
  2818.         {
  2819.             cout << "Abundant Militancy" << endl;
  2820.         } else
  2821.         {
  2822.             cout << "None" << endl;
  2823.         }
  2824.         break;
  2825.     }
  2826.     //cout << "People-backed Party: " << par_name[pefav] << endl;
  2827.     //cout << "People-opposed Party: " << par_name[penem] << endl;
  2828.  
  2829.     //cout << tseats << endl;
  2830.     //cout << remaining << endl;
  2831. //    cout << "DEBUG: " << totalvotes << endl;
  2832. //cout << presidentnum << endl;
  2833. //cout << oppositionnum << endl;
  2834.  
  2835.     erecord.open("Elections.txt", fstream::app);
  2836.         if(midterm == false)
  2837.         {
  2838.             erecord << year << " GENERAL ELECTIONS" << endl;
  2839.             erecord << "WINNERS:" << endl;
  2840.             if(presidentnum == primeministernum)
  2841.             {
  2842.                 erecord << "President & Prime Minister: " << cannames[presidentnum] << " (" << par_name[presidentnum] << ") - " << par_percent_int[presidentnum] << "%" << endl;
  2843.             } else
  2844.             {
  2845.                 erecord << "President: " << cannames[presidentnum] << " (" << par_name[presidentnum] << ") - " << par_percent_int[presidentnum] << "%"  << endl;
  2846.                 erecord << "Prime Minister: " << cannames[primeministernum] << " (" << par_name[primeministernum] << ") - " << par_percent_int[primeministernum] << "%" << endl;
  2847.             }
  2848.             erecord << "\n==========" << endl;
  2849.         } else
  2850.         {
  2851.  
  2852.             erecord << year << " MIDTERM ELECTIONS" << endl;
  2853.             erecord << "WINNER:" << endl;
  2854.             erecord << "Prime Minister: " << cannames[primeministernum] << " (" << par_name[primeministernum] << ") - " << par_percent_int[primeministernum] << "%" << endl;
  2855.             erecord << "\n==========" << endl;
  2856.  
  2857.  
  2858.         }
  2859.         erecord.close();
  2860.  
  2861.  
  2862.  
  2863.  
  2864.         if(snap == true)
  2865.     {
  2866.         snap =false;
  2867.         wassnap = true;
  2868.     }
  2869.         //cout << "A" << endl;
  2870.     if(fair == false)
  2871.     {
  2872.         intervals = par_percent_int[presidentnum] /10;
  2873.     intervals = (rand()%intervals)+1;
  2874.         intervals = intervals *1.5;
  2875.     }
  2876.     //cout << "M" << endl;
  2877.  
  2878.     intervals -= totauth/50;
  2879.     if(fair == true)
  2880.     {
  2881.         intervals = 2;
  2882.     }
  2883.     if(fair == false)
  2884.     {
  2885.         intervals = 5;
  2886.     }
  2887.     //cout << "O" << endl;
  2888.  
  2889.     if(govseats + opposeats < indepseats )
  2890.     {
  2891.         if(midterm == true)
  2892.         {
  2893.             prevmid = true;
  2894.         } else
  2895.         {
  2896.             prevmid = false;
  2897.         }
  2898.  
  2899.  
  2900.         snap = true;
  2901.         intervals = 0;
  2902.         //midterm = false;
  2903.         if(presidentnum == milfav)
  2904.         {
  2905.             military -= 20;
  2906.         } else if(presidentnum == milenem)
  2907.         {
  2908.             military += 10;
  2909.         } else
  2910.         {
  2911.             military -=10;
  2912.         }
  2913.  
  2914.         if(presidentnum == pefav)
  2915.         {
  2916.             people -= 20;
  2917.         } else if(presidentnum == penem)
  2918.         {
  2919.             people += 10;
  2920.         } else
  2921.         {
  2922.             people -=10;
  2923.         }
  2924.     }
  2925.  
  2926.     if(snap == false)
  2927.     {
  2928.         if(midterm == true)
  2929.         {
  2930.             midterm = false;
  2931.         } else if(midterm == false)
  2932.         {
  2933.             midterm = true;
  2934.         }
  2935.  
  2936.     }
  2937.     //cout << "G" << endl;
  2938.  
  2939.     /*cout << "ECONOMY: " << economy << endl;
  2940.     if(boom)
  2941.     {
  2942.         cout << "BOOM ENDS IN " << year + shiffty << endl;
  2943.     }*/
  2944.  
  2945.  
  2946.  
  2947.     tvts = 0;
  2948.     for(int i=0; i!=5; i++)
  2949.     {
  2950.         tvts+= par_votes_int[i];
  2951.     }
  2952.     float tnot = (float) tvts / population;
  2953.     //cout << "U" << endl;
  2954.     cout << "\nVoter Turnout This Election: " << tvts << " (" << round(tnot*100) << "%)" << endl;
  2955.     //cout << "Person Represented Per Seat: " << tvts/seats << endl;
  2956.     cout << "Voter-to-Seat Ratio: " << population/seats+1 << " : 1" << endl;
  2957.     if(primeministernum != 6 && intervals < 1)
  2958.     {
  2959.         intervals =1;
  2960.     }
  2961.     if(primeministernum == 6)
  2962.     {
  2963.         intervals =0;
  2964.     }
  2965.     cout << "\nNext Election: " << year + intervals << endl;
  2966.  
  2967.     if(year >= 2023)
  2968.     {
  2969.         ofstream presfile;
  2970.         presfile.open("Presidents.txt", fstream::app);
  2971.         presfile << presprename << " (" << prevpres << ") " << presyear << " - CURRENT" << endl;
  2972.         presfile.close();
  2973.         presyear = year;
  2974.         prevpres = par_name[presidentnum];
  2975.         presprename = cannames[presidentnum];
  2976.  
  2977.  
  2978.         ofstream pmfile;
  2979.         pmfile.open("Premieres.txt", fstream::app);
  2980.         pmfile << premprename << " (" << prevprem << ") " << premyear << " - CURRENT" << endl;
  2981.         pmfile.close();
  2982.         premyear = year;
  2983.         prevprem = par_name[primeministernum];
  2984.         premprename = cannames[primeministernum];
  2985.     }
  2986.  
  2987.     if(fair ==false)
  2988.     {
  2989.         midterm = false;
  2990.     }
  2991.  
  2992.     cout << "\nInput 1 to show full election results" << endl;
  2993.     cin >> userinput;
  2994.     if(userinput == "1")
  2995.     {
  2996.         dispall();
  2997.         cin >> userinput;
  2998.     }
  2999.  
  3000.  
  3001.     updates();
  3002.     coupcheck();
  3003.     if(ot == false)
  3004.     {
  3005.             revcheck();
  3006.     }
  3007.  
  3008.     year += intervals;
  3009.     restart();
  3010.  
  3011.     if(fair == false && rand()%(year - startyear) < (year - presyear) && totauth > -10 && p_auth[presidentnum] >=1)
  3012.     {
  3013.         fair = true;
  3014.     }
  3015.     /*if(presidentnum == primeministernum && govmembers == 4 && par_seats[presidentnum] > seats * 0.75 && fair == true && rand()%100 < popularity[presidentnum] *100)
  3016.     {
  3017.         fair = false;
  3018.     }*/
  3019.  
  3020.     if(fair == true && presidentnum == primeministernum && govseats > opposeats *2 && rand()%seats < par_seats_int[presidentnum] && totauth < -10 && p_auth[presidentnum]<=0)
  3021.     {
  3022.         fair = false;
  3023.     }
  3024.  
  3025.     goto game;
  3026. }
  3027.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement