Пример #1
0
 private void makeflavor() {
   @SuppressWarnings("unchecked")
   Collection<Gob>[] fo = (Collection<Gob>[]) new Collection[cutn.x * cutn.y];
   for (int i = 0; i < fo.length; i++) fo[i] = new LinkedList<Gob>();
   Coord c = new Coord(0, 0);
   Coord tc = gc.mul(cmaps);
   int i = 0;
   Random rnd = new Random(id);
   for (c.y = 0; c.y < cmaps.x; c.y++) {
     for (c.x = 0; c.x < cmaps.y; c.x++, i++) {
       Tileset set = tileset(tiles[i]);
       if (set.flavobjs.size() > 0) {
         if (rnd.nextInt(set.flavprob) == 0) {
           Resource r = set.flavobjs.pick(rnd);
           double a = rnd.nextDouble() * 2 * Math.PI;
           Gob g = new Flavobj(c.add(tc).mul(tilesz).add(tilesz.div(2)), a);
           g.setattr(new ResDrawable(g, r));
           Coord cc = c.div(cutsz);
           fo[cc.x + (cc.y * cutn.x)].add(g);
         }
       }
     }
   }
   this.fo = fo;
 }
Пример #2
0
 /**
  * Creates a random Id. For testing purposed only -- should NOT be used to generate real node or
  * object identifiers (low quality of random material).
  *
  * @param rng random number generator
  * @return a random Id
  */
 public static Id makeRandomId(Random rng) {
   byte material[] = new byte[IdBitLength / 8];
   rng.nextBytes(material);
   return build(material);
 }
Пример #3
0
 public Random mkrandoom() {
   Random r = new Random(Grid.this.id);
   r.setSeed(r.nextInt() ^ rc.x);
   r.setSeed(r.nextInt() ^ rc.y);
   return (r);
 }