Advertisement
tangedyn

Mangle Proc Sim

May 8th, 2012
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 2.37 KB | None | 0 0
  1. package tangedyn.manglesim;
  2.  
  3. import ec.util.MersenneTwisterFast;
  4.  
  5. public class MangleSim {
  6.     private static int MAXTIME = 1000 * 24 * 60 * 60 * 10;
  7.     private static int REACTION = 5;
  8.    
  9.     private MersenneTwisterFast mRandom = new MersenneTwisterFast(System.nanoTime());
  10.  
  11.     private int nextGCD = -1;
  12.     private int mangleReady = -1;
  13.     private int nextLacerateTick = -1;
  14.     private int nextThrashTick = -1;
  15.     private int lacerateTicksRemaining = 0;
  16.     private int thrashTicksRemaining = 0;
  17.     private int lacerateReady = -1;
  18.     private int time = 0;
  19.     private int mangles = 0;
  20.     private int swipes = 0;
  21.     private int thrashes = 0;
  22.     private int lacerates = 0;
  23.    
  24.     public void run() {
  25.         for (time = 0; time < MAXTIME; time += 5) {
  26.             // Check Lacerate Tick
  27.             if (time == nextLacerateTick) {
  28.                 if (mRandom.nextBoolean(.12)) mangleReady = Math.min(time + REACTION, mangleReady);
  29.                 if (--lacerateTicksRemaining > 0) nextLacerateTick += 30;
  30.             }
  31.            
  32.             // Check Thrash Tick
  33.             if (time == nextThrashTick) {
  34.                 if (mRandom.nextBoolean(.12)) mangleReady = Math.min(time + REACTION, mangleReady);
  35.                 if (--thrashTicksRemaining > 0) nextThrashTick += 20;
  36.             }
  37.            
  38.             // Check if GCD is ready
  39.             if (time < nextGCD) continue;
  40.  
  41.             // Check for Mangle
  42.             if (time >= mangleReady) {
  43.                 mangles++;
  44.                 mangleReady = time + 60;
  45.                 nextGCD = time + 15;
  46.                 continue;
  47.             }
  48.            
  49.             // Check for Thrash
  50.             if (thrashTicksRemaining <= 1) {
  51.                 thrashes++;
  52.                 if (nextThrashTick <= time) nextThrashTick = time + 20;
  53.                 thrashTicksRemaining += 8;
  54.                 nextGCD = time + 15;
  55.                 continue;           }
  56.            
  57.             // Check for Lacerate
  58.             if (time >= lacerateReady) {
  59.                 lacerates++;
  60.                 lacerateReady = time + 30;
  61.                 nextGCD = time + 15;
  62.                 lacerateTicksRemaining = 5;
  63.                 if (nextLacerateTick <= time) nextLacerateTick = time + 30;
  64.                 continue;                      
  65.             }
  66.            
  67.             // Swipe
  68.             swipes++;
  69.             nextGCD = time + 15;
  70.         }
  71.  
  72.         double hertz = 10.0 / time;
  73.        
  74.         System.out.println("Mangles per second: " + (mangles * hertz));
  75.         System.out.println("Thrashes per second: " + (thrashes * hertz));
  76.         System.out.println("Lacerates per second: " + (lacerates * hertz));
  77.         System.out.println("Swipes per second: " + (swipes * hertz));
  78.         System.out.println("Actions per second: " + ((swipes + thrashes + lacerates + mangles) * hertz));
  79.     }
  80.    
  81.     public static void main(String args[]) {
  82.         new MangleSim().run();
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement