Package util

Examples of util.Dice


    // ITC mechanism
    Bag<Stamp> bag = new Bag<Stamp>();
    Stamp seed = new Stamp();
    bag.push(seed);

    Dice dice = new Dice();
    int i, j;

    for (i = 0; i < nRep - 1; i++) {

      //fork
      Stamp s = bag.pop();
      Stamp s2 = s.fork();
      bag.push(s);
      bag.push(s2);

      //size
      float size = 0.0f;
      float size_for_one = 0.0f;
      for (Stamp st : bag.getList()) {
        size += st.sizeInBytes();
      }
      size_for_one = (size / nRep);

      //printing
      if (i % 5000 == 0) {
        System.out.println("It " + i + " - nRep " + bag.getSize() + " - sizeBytes T: " + size + " A:" + size_for_one);
      }
      out.write(i + "\t" + size_for_one + "\n");
    }

    for (; i < nIter; i++) {
      Stamp s;
      Stamp s2;

      //fork
      int sizeBag = bag.getSize();
      int nForks = (nRep + 1) - sizeBag;
//      System.out.println("nForks "+nForks);
      for (j = 0; j < nForks; j++) {
        s = bag.pop();
        s2 = s.fork();
        bag.push(s);
        bag.push(s2);
      }

      //event
      s = bag.pop();
      s.event();
      bag.push(s);

      //join
      s = bag.pop();
      s2 = bag.pop();
      if (dice.roll() >= (ratio_loss * 100)) {
        s = Stamp.join(s, s2);
      } else {
//        System.out.println("LOSS");
      }
      bag.push(s);
View Full Code Here

TOP

Related Classes of util.Dice

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.