codesimian
Class Chaos

java.lang.Object
  extended by codesimian.Chaos

public class Chaos
extends java.lang.Object

A source of randomness, anything that depends on quantum physics. No pseudorandom algorithms. Nothing based on the current time alone because that is predictable, but based on the difference in time of 2 partially random events is ok.



TODO: Rewrite all the payments to be in units of truly random bits. For example, a pseudorandom generator that starts with a truly random 64 bit seed and produces 64000 numbers, may trade 5000 of its numbers for 5 (or less?) truly random numbers. Their cost would be .001 each. The earlier numbers (after a random seeding) should cost more.



Example: If a slow operation takes an odd or even number of milliseconds, is 1 bit. Example: Which direction the Human moves the mouse is a few bits. Example: Every 199th bit from the microphone hole of the computer is random enough.

Should Chaos be an InputStream? Random data comes in asynchronously and unpredictably, and may be available or not at any one time.

Chaos extends class Liquid because truly random numbers (chaos) should be traded directly for Liquid type "liquidChaos".

SHOULD ALL FUNCTIONS OF THIS CLASS BE STATIC OR INSTANCE?

GAMBLING SHOULD BE ADDED LATER, BECAUSE IF YOU CAN GAMBLE AND WIN, ITS PROBABLY NOT RANDOM.


Nested Class Summary
static class Chaos.NextFreeChaosInt
          canGamble(x,Liquid) for any x > maxPredictBitLength always returns false.
 
Field Summary
static double logBase2OfHowManyAtomsInKnownUniverse
           
 
Method Summary
static int bitsAvailable(double howRandomIsItExponentOf2)
           
static boolean buyBoolean(double howRandomIsItExponentOf2, Liquid payment)
           
static boolean[] buyBooleans(int quantity, double howRandomIsItExponentOf2, Liquid payment)
           
static boolean[] buyBooleans(int quantity, Liquid payment)
           
static int buyInt(double howRandomIsItExponentOf2, Liquid payment)
           
static int buyIntFrom0ToThisMinus1(int quantityPossibleValues, double howRandomIsItExponentOf2, Liquid payment)
          returns an int between 0 and quantityPossibleValues-1.
static int buySomeBitsOfInt(int howManyBits, double howRandomIsItExponentOf2, Liquid payment)
           
static double costPerBit(double howRandomIsItExponentOf2)
           
static boolean getBoolean(double howRandomIsItExponentOf2)
           
static boolean getBoolean(double howRandomIsItExponentOf2, java.lang.String whyDoYouWantTheBoolean)
          same as buyBoolean(Liquid) except asks for the Liquid from class FreeLiquid, but if can not get that Liquid, an Exception is thrown.
static boolean[] getBooleans(int quantity, double howRandomIsItExponentOf2)
          because this depends on FreeLiquid having Liquid type "liquidChaos", it may throw a NeedLiquid
static boolean[] getBooleans(int quantity, double howRandomIsItExponentOf2, java.lang.String whyDoYouWantTheBooleans)
           
static int getInt(double howRandomIsItExponentOf2)
           
static int getInt(double howRandomIsItExponentOf2, java.lang.String whyDoYouWantTheInt)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logBase2OfHowManyAtomsInKnownUniverse

public static final double logBase2OfHowManyAtomsInKnownUniverse
Method Detail

costPerBit

public static double costPerBit(double howRandomIsItExponentOf2)

bitsAvailable

public static int bitsAvailable(double howRandomIsItExponentOf2)

getBoolean

public static boolean getBoolean(double howRandomIsItExponentOf2)
                          throws NeedLiquid
Throws:
NeedLiquid

getBoolean

public static boolean getBoolean(double howRandomIsItExponentOf2,
                                 java.lang.String whyDoYouWantTheBoolean)
same as buyBoolean(Liquid) except asks for the Liquid from class FreeLiquid, but if can not get that Liquid, an Exception is thrown.


buyBoolean

public static boolean buyBoolean(double howRandomIsItExponentOf2,
                                 Liquid payment)
                          throws NeedLiquid
Throws:
NeedLiquid

buyIntFrom0ToThisMinus1

public static int buyIntFrom0ToThisMinus1(int quantityPossibleValues,
                                          double howRandomIsItExponentOf2,
                                          Liquid payment)
returns an int between 0 and quantityPossibleValues-1. Uses a few more bits than necessary on average.


buyBooleans

public static boolean[] buyBooleans(int quantity,
                                    Liquid payment)
                             throws NeedLiquid
Throws:
NeedLiquid

buySomeBitsOfInt

public static int buySomeBitsOfInt(int howManyBits,
                                   double howRandomIsItExponentOf2,
                                   Liquid payment)
                            throws NeedLiquid
Throws:
NeedLiquid

buyInt

public static int buyInt(double howRandomIsItExponentOf2,
                         Liquid payment)

getInt

public static int getInt(double howRandomIsItExponentOf2)

getInt

public static int getInt(double howRandomIsItExponentOf2,
                         java.lang.String whyDoYouWantTheInt)

buyBooleans

public static boolean[] buyBooleans(int quantity,
                                    double howRandomIsItExponentOf2,
                                    Liquid payment)

getBooleans

public static boolean[] getBooleans(int quantity,
                                    double howRandomIsItExponentOf2)
                             throws NeedLiquid
because this depends on FreeLiquid having Liquid type "liquidChaos", it may throw a NeedLiquid

Throws:
NeedLiquid

getBooleans

public static boolean[] getBooleans(int quantity,
                                    double howRandomIsItExponentOf2,
                                    java.lang.String whyDoYouWantTheBooleans)
                             throws NeedLiquid
Throws:
NeedLiquid