Guest User

aiwar!

a guest
Dec 4th, 2012
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.23 KB | None | 0 0
  1. package arcen;
  2.  
  3. import java.util.Random;
  4.  
  5. /**
  6.  * @author Pluto
  7.  */
  8. public class ArcenGames {
  9.     //Global random generator, never know what you find when you get out.
  10.     Random r = new Random();
  11.  
  12.     ArcenGames() {
  13.         for (Game g : Game.values()) {
  14.             Keith keith = new Keith(r);
  15.             for (int hour = 9; hour < 17; hour++) {
  16.                 switch (g) {
  17.                     case AI_WAR:
  18.                         if (!g.getGameKilled()) {
  19.                             AIWar a = new AIWar();
  20.                             int weight = r.nextInt(100);
  21.                             if (weight > 80) {
  22.                                 keith.addPain(a);
  23.                             } else if (weight <= 80 && weight > 5) {
  24.                                 keith.fixBugs(a);
  25.                             } else if (weight <= 5 && weight > 0) {
  26.                                 keith.addToExpansion(a);
  27.                             } else {
  28.                                 //He killed it.
  29.                                 g.setGameKilled(true);
  30.                                 close();
  31.                             }
  32.                         }
  33.                         break;
  34.                     case A_VALLEY_WITHOUT_WIND:
  35.                         if (!g.getGameKilled()) {
  36.                             keith.idunknowwhatthisgamereallyis(10);
  37.                         }
  38.                         break;
  39.                     case TIDALIS:
  40.                         if (!g.getGameKilled()) {
  41.                             keith.ialsodontknowwhatsinthisgame();
  42.                         }
  43.                         break;
  44.                 }
  45.             }
  46.         }
  47.     }
  48.  
  49.     private void close() {
  50.         Runtime.getRuntime().exit(0);
  51.     }
  52. }
  53.  
  54. //Arcen's games.
  55. class Keith {
  56.  
  57.     //Keith is a person.  Person's have health.  Some people are healthy.  Some people are not.
  58.     double health;
  59.     //Keith has feelings!  Though sometimes I wonder...
  60.     double feelings;
  61.     //Keith is fickle.  Very very fickle.
  62.     double fickleness;
  63.     //Keith has a work load. This is part of having a job.
  64.     double workLoad;
  65.     Random r;
  66.  
  67.     Keith(Random r) {
  68.         health = r.nextDouble();
  69.         feelings = r.nextDouble();
  70.         fickleness = r.nextDouble();
  71.         workLoad = r.nextDouble();
  72.         this.r = r;
  73.     }
  74.  
  75.     double getHealth() {
  76.         return health;
  77.     }
  78.  
  79.     double getFeelings() {
  80.         return feelings;
  81.     }
  82.  
  83.     double getFickleness() {
  84.         return fickleness;
  85.     }
  86.  
  87.     double getWorkLoad() {
  88.         return workLoad;
  89.     }
  90.  
  91.     /**
  92.      * This should be self explanatory.
  93.      */
  94.     void idunknowwhatthisgamereallyis(int i) {
  95.         //umm, what?
  96.         throw new UnsupportedOperationException("Not yet implemented");
  97.     }
  98.  
  99.     /**
  100.      * This should also be self explanatory.
  101.      */
  102.     void ialsodontknowwhatsinthisgame() {
  103.         //yeah, above.
  104.         throw new UnsupportedOperationException("Not yet implemented");
  105.     }
  106.  
  107.     /**
  108.      * Keith adds something to make AI War more painful.
  109.      *
  110.      * @param a
  111.      */
  112.     void addPain(AIWar a) {
  113.         if (this.works()) {
  114.             //No limit in the pain threshold.
  115.             a.setPainThreshold(a.getPainThreshold() + 1);
  116.         }
  117.     }
  118.  
  119.     /**
  120.      * Keith fixes bugs inherent in AI war.
  121.      *
  122.      * @param a
  123.      */
  124.     void fixBugs(AIWar a) {
  125.         if (this.works()) {
  126.             //Constantly fix bugs.
  127.             if (a.getNumBugs() > 0) {
  128.                 a.setNumBugs(a.getNumBugs() - 1);
  129.             } else {
  130.                 //...  but if they all get fixed, inevitably more have creeped in.
  131.                 a.setNumBugs(7);
  132.             }
  133.         }
  134.     }
  135.  
  136.     /**
  137.      * Keith adds to the expansion progress of AI war.
  138.      *
  139.      * @param a
  140.      */
  141.     void addToExpansion(AIWar a) {
  142.         if (this.works()) {
  143.             //Still working towards the next expansion!
  144.             if (a.getExpansionProgress() < 100) {
  145.                 a.setExpansionProgress(a.getExpansionProgress() + 1);
  146.             } else {
  147.                 //And if it's finished, there's always a new one to start.
  148.                 a.setExpansionProgress(0);
  149.             }
  150.         }
  151.     }
  152.  
  153.     /**
  154.      * Simple determination of whether Keith gets work done.
  155.      *
  156.      * @return Whether Keith works.
  157.      */
  158.     private boolean works() {
  159.         if (workLoad <= .4) {
  160.             //Keith got lazy and procrastinated as he thought he didn't have much to do.
  161.             workLoad += .1;
  162.             return false;
  163.         }
  164.         if (feelings <= .2) {
  165.             //Keith is in too bad of a mood to work.
  166.             //But, the mood goes up slowly.
  167.             feelings += .1;
  168.             return false;
  169.         }
  170.         if (health <= .5) {
  171.             //Keith is not feeling well.  He takes a trip around go.
  172.             health += .2;
  173.             return false;
  174.         }
  175.         if (fickleness >= .5) {
  176.             //Keith feels fickle.  He goes swimming with Old Greg.
  177.             fickleness -= .1;
  178.             return false;
  179.         }
  180.  
  181.         //Keith does work!
  182.         workLoad -= .02;
  183.         feelings -= .02;
  184.         health -= .02;
  185.         fickleness += .02;
  186.         return true;
  187.     }
  188. }
  189.  
  190. class AIWar extends ArcenGames {
  191.  
  192.     int painThreshold = 75;
  193.     int numBugs = 7;
  194.     int expansionProgress = 25;
  195.  
  196.     public int getExpansionProgress() {
  197.         return expansionProgress;
  198.     }
  199.  
  200.     public void setExpansionProgress(int expansionProgress) {
  201.         this.expansionProgress = expansionProgress;
  202.     }
  203.  
  204.     public int getNumBugs() {
  205.         return numBugs;
  206.     }
  207.  
  208.     public void setNumBugs(int numBugs) {
  209.         this.numBugs = numBugs;
  210.     }
  211.  
  212.     public int getPainThreshold() {
  213.         return painThreshold;
  214.     }
  215.  
  216.     public void setPainThreshold(int painThreshold) {
  217.         this.painThreshold = painThreshold;
  218.     }
  219. }
  220.  
  221. //Arcen's games.
  222. enum Game {
  223.  
  224.     AI_WAR(false),
  225.     A_VALLEY_WITHOUT_WIND(false),
  226.     TIDALIS(false);
  227.     private boolean GAME_KILLED;
  228.  
  229.     Game(boolean g) {
  230.         this.GAME_KILLED = g;
  231.     }
  232.  
  233.     boolean getGameKilled() {
  234.         return GAME_KILLED;
  235.     }
  236.  
  237.     void setGameKilled(boolean state) {
  238.         this.GAME_KILLED = state;
  239.     }
  240. }
Advertisement
Add Comment
Please, Sign In to add comment