Advertisement
Guest User

Turning_Points_of_History.pde

a guest
Nov 27th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.60 KB | None | 0 0
  1. //From "The Turning Points of History", Pyramid 3/41
  2.  
  3. //HOW TO USE:
  4. //1. Download and install Processing (Baby's First Java) from https://processing.org/download
  5. //2. Save this file as blah.pde
  6. //3. Open this file in Processing and click the "Run" button at the upper-left corner of the window
  7. //4. Follow the instructions given at the bottom of the window
  8.  
  9. int count=1;
  10. String[] results;
  11.  
  12. void setup(){
  13.     noLoop();
  14.     results=new String[0];
  15. }
  16.  
  17. void draw(){
  18.     println("Left-click in the little gray window that just appeared to generate a hundred historical events.");
  19.     println("Right-click for a THOUSAND events!");
  20.     println("Middle-click to export everything generated so far as a .txt file.");
  21.     println("");
  22. }
  23.  
  24. int roll(){
  25.     return int(random(1,7));
  26. }
  27.  
  28. void mouseClicked(){
  29.     if(mouseButton==LEFT){
  30.         for(int a=0;a<100;a++){
  31.             event(count);
  32.             count++;
  33.         }
  34.     }else if(mouseButton==RIGHT){
  35.         for(int a=0;a<1000;a++){
  36.             event(count);
  37.             count++;
  38.         }
  39.     }else if(mouseButton==CENTER){
  40.         saveStrings(nf(year(),4)+nf(month(),2)+nf(day(),2)+nf(hour(),2)+nf(minute(),2)+nf(second(),2)+".txt",results);
  41.     }
  42. }
  43.  
  44. void event(int count){
  45.     int roll=int(random(0,72));
  46.     int secondary;
  47.     String result="";
  48.     String string1="",string2="";
  49.     if(roll<2){result="Alliance/peace treaty with "+external();
  50.     }else if(roll<4){
  51.         do{
  52.             string1=internal();
  53.             string2=internal();
  54.         }while(string1.equals(string2));
  55.         result="Assimilation of "+string1+" by "+string2;
  56.     }else if(roll<5){result="Conquest of "+external();
  57.     }else if(roll<6){result="Conquest by "+external();
  58.     }else if(roll<7){result="Major democratization in favor of "+internal();
  59.     }else if(roll<9){result="Minor democratization in favor of "+internal();
  60.     }else if(roll<11){result="Fragmentation of "+internal();
  61.     }else if(roll<12){result="Significant legislation";
  62.     }else if(roll<14){result="Migration of "+external()+" into the area";
  63.     }else if(roll<16){result="Centralization";
  64.     }else if(roll<17){result="Prosperity";
  65.     }else if(roll<18){result="Raids by "+external();
  66.     }else if(roll<20){result="Revolt of "+internal();
  67.     }else if(roll<22){
  68.         if(random(1)<0.5){result="Rise of "+internal()+" to importance";
  69.         }else{result="Rise of member of "+internal()+" to importance";
  70.         }
  71.     }else if(roll<24){result="Suppression of "+internal();
  72.     }else if(roll<25){result="Successful war with "+external();
  73.     }else if(roll<26){result="Unsuccessful war with "+external();
  74.     }else if(roll<27){result="Bad omens";
  75.     }else if(roll<28){result="Blizzards";
  76.     }else if(roll<30){
  77.         secondary=int(random(4));
  78.         if(secondary==0){result="Climate becomes hotter";
  79.         }else if(secondary==1){result="Climate becomes colder";
  80.         }else if(secondary==2){result="Climate becomes wetter";
  81.         }else{result="Climate becomes drier";
  82.         }
  83.     }else if(roll<31){result="Diabolic influence";
  84.     }else if(roll<32){result="Dragons";
  85.     }else if(roll<34){result="Drought";
  86.     }else if(roll<36){result="Earthquake";
  87.     }else if(roll<38){result="Famine";
  88.     }else if(roll<39){result="Fire";
  89.     }else if(roll<41){result="Flood";
  90.     }else if(roll<42){result="Hauntings";
  91.     }else if(roll<43){result="Heavy weather";
  92.     }else if(roll<44){result="Massacre";
  93.     }else if(roll<45){
  94.         secondary=int(random(2));
  95.         if(secondary==0){result="Malignant otherworldly breakthrough";
  96.         }else{result="Benign otherworldly breakthrough";
  97.         }
  98.     }else if(roll<47){result="Plague";
  99.     }else if(roll<48){result="Crime/atrocity";
  100.     }else if(roll<49){result="Death of prominent person";
  101.     }else if(roll<51){result="Decadence";
  102.     }else if(roll<52){result="Divine contact";
  103.     }else if(roll<53){result="Domestic changes";
  104.     }else if(roll<54){
  105.         secondary=int(random(2));
  106.         if(secondary==0){result="Demise of prominent dynasty";
  107.         }else{result="Rise of prominent dynasty";
  108.         }
  109.     }else if(roll<56){result="Invention/development in art";
  110.     }else if(roll<57){result="Invention/development in magic";
  111.     }else if(roll<59){result="Invention/development in materials";
  112.     }else if(roll<60){result="Invention/development in mechanics";
  113.     }else if(roll<62){result="Invention/development in the military";
  114.     }else if(roll<63){result="Invention/development in science";
  115.     }else if(roll<65){result="Invention/development in subsistence";
  116.     }else if(roll<66){result="Invention/development in transportation";
  117.     }else if(roll<67){result="Heroism";
  118.     }else if(roll<68){result="New fashion";
  119.     }else if(roll<70){result="New religion";
  120.     }else{result="Religious revival";
  121.     }
  122.     results=append(results,result);
  123.     println(count+". "+result);
  124. }
  125.  
  126. String internal(){
  127.     int roll1=roll();
  128.     int roll2=roll();
  129.     String result;
  130.     if(roll1<=2){
  131.         if(roll2<=1){result="fringe clergy";
  132.         }else if(roll2<=2){result="mainstream clergy";
  133.         }else if(roll2<=3){result="craftsmen";
  134.         }else if(roll2<=5){result="ethnic minority";
  135.         }else{result="rural gentry";
  136.         }
  137.     }else if(roll1<=4){
  138.         if(roll2<=1){result="urban gentry";
  139.         }else if(roll2<=2){result="magicians";
  140.         }else if(roll2<=3){result="merchants";
  141.         }else if(roll2<=5){result="peasants";
  142.         }else{result="religious minority";
  143.         }
  144.     }else{
  145.         if(roll2<=1){result="ruling class";
  146.         }else if(roll2<=2){result="slaves";
  147.         }else if(roll2<=3){result="urban poor";
  148.         }else if(roll2<=4){result="soldiers";
  149.         }else if(roll2<=5){result="officers";
  150.         }else{result="intellectuals";
  151.         }
  152.     }
  153.     return result;
  154. }
  155.  
  156. String external(){
  157.     int roll1=roll()+roll();
  158.     String result;
  159.     if(roll1<=6){result="neighboring state";
  160.     }else if(roll1<=7){result="neighboring tribe";
  161.     }else if(roll1<=8){result="migrating tribe";
  162.     }else if(roll1<=9){result="pirates/raiders";
  163.     }else if(roll1<=10){result="refugees";
  164.     }else{result="semi-autonomous "+internal();
  165.     }
  166.     return result;
  167. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement