Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- #include <unistd.h>
- using namespace std;
- string fac_names[5] = {"Radicals", "Conservatives", "Moderates", "Reformers", "Liberals"};
- string fac_acro[5] = {"Rad", "Con", "Mod", "Ref", "Lib"};
- int fac_influence[5] = {50, 600, 200, 100,50};
- int fac_seats[5] = {0,0,0,0,0};
- int fac_commit[5]= {0,0,0,0,0};
- int fac_bureau[5]= {0,0,0,0,0};
- string fac_leaders[5][5] =
- {
- {"","","","",""},
- {"","","","",""},
- {"","","","",""},
- {"","","","",""},
- {"","","","",""}
- };
- int fac_leaders_age[5][5] =
- {
- {0,0,0,0,0},
- {0,0,0,0,0},
- {0,0,0,0,0},
- {0,0,0,0,0},
- {0,0,0,0,0}
- };
- int seats = 350;
- int commit = 51;
- int bureau = 11;
- int president[2];
- int premier[2];
- int defense[2];
- int chairman[2];
- int speaker[2];
- int year = 1976;
- int week = 1;
- string usr;
- bool haspar = false;
- int paramount[2];
- string indivgen()
- {
- string consonant[20] = {"B","B","K","D","G","H","H","L","L","M","N","P","R","S","S","T","T","W","W","Y"};
- string vowel[13] = {"A","A","A","A","A","E","I","I","I","O","O","O","U"};
- string aftercon[11] = {"NG","NG","M","M","N","K","K","P","P","T","Y"};
- string bloc1,bloc2, bloc3;
- string fname, lname;
- bloc1 = consonant[rand()%20] + vowel[rand()%13];
- if(rand()%10 < 3)
- {
- bloc1 += aftercon[rand()%11];
- }
- bloc2 = consonant[rand()%20] + vowel[rand()%13];
- if(rand()%10 < 3)
- {
- bloc2 += aftercon[rand()%11];
- }
- bloc3 = consonant[rand()%20] + vowel[rand()%13];
- if(rand()%10 < 3)
- {
- bloc3 += aftercon[rand()%11];
- }
- fname = bloc1 + bloc2;
- if(rand()%10 < 5)
- {
- fname += bloc3;
- }
- bloc1 = consonant[rand()%20] + vowel[rand()%13];
- if(rand()%10 < 3)
- {
- bloc1 += aftercon[rand()%11];
- }
- bloc2 = consonant[rand()%20] + vowel[rand()%13];
- if(rand()%10 < 3)
- {
- bloc2 += aftercon[rand()%11];
- }
- bloc3 = consonant[rand()%20] + vowel[rand()%13];
- if(rand()%10 < 3)
- {
- bloc3 += aftercon[rand()%11];
- }
- lname = bloc1 + bloc2;
- if(rand()%10 < 5)
- {
- lname += bloc3;
- }
- string final = fname + " " + lname;
- return final;
- }
- int agegen()
- {
- int a = 40 + (rand()%20);
- return a;
- }
- void setup()
- {
- for(int i=0; i!=5; i++)
- {
- for(int x=0; x!=5; x++)
- {
- fac_leaders[i][x] =indivgen();
- fac_leaders_age[i][x] = agegen();
- }
- }
- }
- void seatdistrib()
- {
- int ogcan[5];
- int winr, w_score =0;
- for(int i=0; i!=5; i++)
- {
- ogcan[i] = fac_influence[i];
- }
- for(int b=0; b!=seats; b++)
- {
- for(int i=0; i!=5; i++)
- {
- if(ogcan[i] >= w_score)
- {
- winr = i;
- w_score = ogcan[i];
- }
- }
- fac_seats[winr]++;
- ogcan[winr] = fac_influence[winr]/fac_seats[winr];
- w_score=0;
- }
- }
- void comdistrib()
- {
- int ogcan[5];
- int winr, w_score =0;
- for(int i=0; i!=5; i++)
- {
- ogcan[i] = fac_seats[i];
- }
- for(int b=0; b!=commit; b++)
- {
- for(int i=0; i!=5; i++)
- {
- if(ogcan[i] >= w_score)
- {
- winr = i;
- w_score = ogcan[i];
- }
- }
- fac_commit[winr]++;
- ogcan[winr] = fac_seats[winr]/fac_commit[winr];
- w_score=0;
- }
- }
- void budistrib()
- {
- int ogcan[5];
- int winr, w_score =0;
- for(int i=0; i!=5; i++)
- {
- ogcan[i] = fac_commit[i];
- }
- for(int b=0; b!=bureau; b++)
- {
- for(int i=0; i!=5; i++)
- {
- if(ogcan[i] >= w_score)
- {
- winr = i;
- w_score = ogcan[i];
- }
- }
- fac_bureau[winr]++;
- ogcan[winr] = fac_commit[winr]/fac_bureau[winr];
- w_score=0;
- }
- }
- void leaderappoints()
- {
- int ogcan[5];
- int winr, w_score =0;
- int points[5]= {0,0,0,0,0};
- for(int i=0; i!=5; i++)
- {
- ogcan[i] = fac_bureau[i];
- }
- for(int b=0; b!=5; b++)
- {
- for(int i=0; i!=5; i++)
- {
- if(ogcan[i] >= w_score)
- {
- winr = i;
- w_score = ogcan[i];
- }
- }
- switch(b)
- {
- case 0:
- president[0] = winr;
- president[1] = points[winr];
- break;
- case 1:
- premier[0] = winr;
- premier[1] = points[winr];
- break;
- case 2:
- defense[0] = winr;
- defense[1] = points[winr];
- break;
- case 3:
- chairman[0] = winr;
- chairman[1] = points[winr];
- break;
- case 4:
- speaker[0] = winr;
- speaker[1] = points[winr];
- break;
- }
- points[winr]++;
- ogcan[winr] = fac_bureau[winr]/(points[winr]+1);
- w_score=0;
- }
- int wnr = 6;
- int wps =0;
- for(int i=0; i!=5; i++)
- {
- if(points[i]> wps)
- {
- wnr =i;
- wps = points[i];
- }
- }
- if(points[wnr] >=3)
- {
- haspar = true;
- paramount[0] = wnr;
- paramount[1] = 0;
- } else
- {
- haspar = false;
- }
- }
- void update()
- {
- for(int i=0; i!=5; i++)
- {
- fac_influence[i] += ((rand()%100)-rand()%100);
- int event = rand()%100;
- if(event <10)
- {
- fac_influence[i] -= fac_influence[i]*0.10;
- }
- if(event > 90)
- {
- fac_influence[i] += fac_influence[i]*0.10;
- }
- if(fac_influence[i] <0)
- {
- fac_influence[i] =0;
- }
- }
- week +=1;
- if(week == 52)
- {
- week = 1;
- year++;
- for(int i=0; i!=5; i++)
- {
- for(int x=0; x!=5; x++)
- {
- fac_leaders_age[i][x]+=1;
- if(fac_leaders_age[i][x] > 70)
- {
- if(rand()%120 < fac_leaders_age[i][x])
- {
- fac_leaders[i][x] = indivgen();
- fac_leaders_age[i][x] = agegen();
- }
- }
- }
- }
- }
- }
- int main()
- {
- srand(time(NULL));
- setup();
- seatdistrib();
- comdistrib();
- budistrib();
- leaderappoints();
- game:
- cout << year << " Government Leadership" << endl;
- cout << "Week " << week << endl;
- cout <<endl;
- if(week == 25 || week == 50)
- {
- for(int i=0; i!=5;i++)
- {
- fac_seats[i] =0;
- fac_commit[i] =0;
- fac_bureau[i] =0;
- }
- seatdistrib();
- comdistrib();
- budistrib();
- }
- if(week == 38)
- {
- leaderappoints();
- }
- if(haspar)
- {
- cout << "Paramount Leader: " << fac_leaders[paramount[0]][paramount[1]] << "(" << fac_acro[paramount[0]] << ")" << endl;
- } else
- {
- cout << "President: " << fac_leaders[president[0]][president[1]] << "(" << fac_acro[president[0]] << ")" << endl;
- }
- cout << "Premier: " << fac_leaders[premier[0]][premier[1]] << "(" << fac_acro[premier[0]] << ")" << endl;
- cout << "Defense Comissioner: " << fac_leaders[defense[0]][defense[1]] << "(" << fac_acro[defense[0]] << ")" << endl;
- cout << "Committee Chairman: " << fac_leaders[chairman[0]][chairman[1]] << "(" << fac_acro[chairman[0]] << ")" << endl;
- cout << "Speaker: " << fac_leaders[speaker[0]][speaker[1]] << "(" << fac_acro[speaker[0]] << ")" << endl;
- cout << endl;
- for(int i=0; i!=5; i++)
- {
- cout << fac_names[i] << ":" << endl;
- cout << "Congress Seats: " << fac_seats[i] << endl;
- cout << "Committee Seats: " << fac_commit[i] << endl;
- cout << "Bureau Seats: " << fac_bureau[i] << endl;
- cout<< "Leaders:" << endl;
- for(int x=0; x!=5; x++)
- {
- cout << fac_leaders[i][x] << " | ";
- }
- cout<< "\n==================" << endl;
- }
- cin>> usr;
- update();
- system("clear");
- goto game;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement