1 package org.jgap.util; 2 3 23 public class randomLCG extends randomX { 24 long state; 25 26 28 30 31 public randomLCG() { 32 this.setSeed(System.currentTimeMillis()); 33 } 34 35 40 41 public randomLCG(long seed) { 42 this.setSeed(seed); 43 } 44 45 47 52 53 public void setSeed(long seed) { 54 super.setSeed(); state = seed & 0xFFFFFFFFL; 56 } 57 58 67 68 public byte nextByte() { 69 state = (state * 1103515245L + 12345L) & 0x7FFFFFFFL; 70 return (byte) ((state >> 11) & 0xFF); 71 } 72 }; 73 | Popular Tags |