RandomGenerator.st
author Stefan Vogel <sv@exept.de>
Tue, 30 Mar 2010 14:32:10 +0200
changeset 2438 3601d0065aff
parent 2432 77c3b2c22e9c
child 2439 8ef4ad63fb9b
permissions -rw-r--r--
changed: #new - use microSecondTime to add entropy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1925
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
     1
"
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
     2
 COPYRIGHT (c) 2007 by eXept Software AG
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
     3
              All Rights Reserved
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
     4
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
     5
 This software is furnished under a license and may be used
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
     6
 only in accordance with the terms of that license and with the
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
     8
 be provided or otherwise made available to, or used by, any
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
     9
 other person.  No title to or ownership of the software is
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
    10
 hereby transferred.
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
    11
"
1606
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libbasic2' }"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    13
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    14
Object subclass:#RandomGenerator
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:''
2432
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
    16
	classVariableNames:'RandFile SharedGenerator'
1606
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    18
	category:'Magnitude-Numbers'
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    19
!
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    20
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    21
!RandomGenerator class methodsFor:'documentation'!
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    22
1925
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
    23
copyright
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
    24
"
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
    25
 COPYRIGHT (c) 2007 by eXept Software AG
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
    26
              All Rights Reserved
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
    27
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
    28
 This software is furnished under a license and may be used
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
    29
 only in accordance with the terms of that license and with the
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
    31
 be provided or otherwise made available to, or used by, any
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
    32
 other person.  No title to or ownership of the software is
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
    33
 hereby transferred.
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
    34
"
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
    35
!
1db437e31d6e copyright
Claus Gittinger <cg@exept.de>
parents: 1840
diff changeset
    36
1606
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    37
documentation
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    38
"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    39
    This is a Random number generator, which uses either a OS random number generator,
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    40
    or a ST/X internal random number generator.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    41
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    42
    [author:]
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    43
        Stefan Vogel
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    44
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    45
    [see also:]
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    46
        Random HashRandom Rc4Stream
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    47
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    48
    [instance variables:]
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    49
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    50
    [class variables:]
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    51
        RandFile        the FileStream we get random numbers from
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    52
"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    53
! !
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    54
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    55
!RandomGenerator class methodsFor:'initialization'!
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    56
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    57
initialize
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    58
    "want to be informed when returning from snapshot"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    59
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    60
    ObjectMemory addDependent:self.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    61
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    62
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    63
!
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    64
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    65
openRandFile
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    66
    "try to open a random device"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    67
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    68
    |randDevName|
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    69
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    70
    RandFile isStream ifTrue:[
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    71
        RandFile close.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    72
    ].
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    73
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    74
    RandFile := false.              "prevent retry"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    75
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    76
    randDevName := self randPath.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    77
    randDevName notNil ifTrue:[
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    78
        randDevName := randDevName asFilename.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    79
        randDevName isReadable ifTrue:[
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    80
            RandFile := randDevName readStream
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    81
        ].
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    82
    ].
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    83
! !
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    84
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    85
!RandomGenerator class methodsFor:'instance creation'!
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    86
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    87
new
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    88
    "return a new random number generator.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    89
     Try to get system random numbers from device (e.g. in LINUX).
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    90
     If no system random nubers are available, fall back to
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    91
     a cryptographic secure PRNG (part of the extra libcrypt package). 
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    92
     As last resort fallback to the cryptographic insecure linear builtin PRNG"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    93
2432
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
    94
    SharedGenerator notNil ifTrue:[
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
    95
        "each time, we do an new, add some entropy to the SharedGenerator"
2438
3601d0065aff changed: #new - use microSecondTime to add entropy
Stefan Vogel <sv@exept.de>
parents: 2432
diff changeset
    96
        SharedGenerator addEntropy:OperatingSystem getMicrosecondTime.
2432
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
    97
        ^ SharedGenerator.
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
    98
    ].
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
    99
1606
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   100
    RandFile isNil ifTrue:[
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   101
        self openRandFile.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   102
    ].
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   103
    RandFile isStream ifTrue:[
2432
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   104
        SharedGenerator := self basicNew.
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   105
        ^ SharedGenerator.
1606
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   106
    ].
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   107
2432
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   108
    Rc4Cipher notNil ifTrue:[
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   109
        SharedGenerator := Rc4Cipher random.
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   110
        ^ SharedGenerator.
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   111
    ].
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   112
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   113
    SharedGenerator := Random sharedGenerator.
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   114
    ^ SharedGenerator.
1606
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   115
!
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   116
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   117
random
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   118
    "alias for new - protocol compatibility with StreamCiphers"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   119
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   120
    ^ self new
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   121
! !
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   122
2432
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   123
!RandomGenerator class methodsFor:'adding entropy'!
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   124
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   125
addEntropy:entropyBytes
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   126
    SharedGenerator notNil ifTrue:[
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   127
        SharedGenerator addEntropy:entropyBytes
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   128
    ].
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   129
! !
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   130
1606
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   131
!RandomGenerator class methodsFor:'change & update'!
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   132
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   133
update:something with:aParameter from:changedObject
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   134
    "handle image restarts and flush any device resource handles"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   135
2432
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   136
    SharedGenerator := nil.
1606
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   137
    RandFile notNil ifTrue:[
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   138
        RandFile := nil.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   139
        self openRandFile.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   140
    ].
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   141
! !
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   142
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   143
!RandomGenerator class methodsFor:'queries'!
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   144
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   145
randPath
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   146
    "path to a file/device that is a source or random numbers"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   147
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   148
    OperatingSystem isUNIXlike ifTrue:[^ '/dev/urandom'].
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   149
    ^ nil.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   150
! !
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   151
2432
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   152
!RandomGenerator methodsFor:'adding entropy'!
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   153
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   154
addEntropy:entropyBytes
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   155
    "add some entropy - ignored here, since I am file based"
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   156
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   157
    ^ self
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   158
! !
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   159
1606
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   160
!RandomGenerator methodsFor:'reading'!
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   161
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   162
next
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   163
    "return the next random number in the range 0..1"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   164
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   165
    ^ self nextInteger / 16r3fffffff asFloat
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   166
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   167
    "
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   168
     |r|
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   169
     r := RandomGenerator new.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   170
     Transcript showCR:r next.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   171
     Transcript showCR:r next.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   172
     Transcript showCR:r next.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   173
     Transcript showCR:r next.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   174
    "
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   175
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   176
    "Modified: / 11.11.1999 / 10:31:35 / stefan"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   177
!
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   178
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   179
nextBetween:start and:stop
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   180
    "return a random number between start and stop."
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   181
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   182
    |rnd|
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   183
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   184
    rnd := self next.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   185
    rnd := rnd * (stop - start) asFloat.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   186
    rnd := rnd + start asFloat.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   187
    ^ rnd
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   188
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   189
    "
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   190
     |r|
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   191
     r := RandomGenerator new.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   192
     Transcript showCR:(r nextBetween:1 and:10).
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   193
     Transcript showCR:(r nextBetween:1 and:10).
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   194
     Transcript showCR:(r nextBetween:1 and:10).
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   195
     Transcript showCR:(r nextBetween:1 and:10).
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   196
    "
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   197
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   198
    "Created: / 11.11.1999 / 10:27:56 / stefan"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   199
!
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   200
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   201
nextBoolean
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   202
    "return true or false by random"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   203
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   204
    ^ self nextByte <= 127
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   205
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   206
    "
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   207
     |r|
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   208
     r := RandomGenerator new.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   209
     Transcript showCR:r nextBoolean.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   210
     Transcript showCR:r nextBoolean.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   211
     Transcript showCR:r nextBoolean.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   212
     Transcript showCR:r nextBoolean.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   213
    "
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   214
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   215
    "
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   216
     |r bag|
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   217
     r := RandomGenerator new.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   218
     bag := Bag new.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   219
     1000000 timesRepeat:[
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   220
         bag add:(r nextBoolean).
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   221
     ].
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   222
     Transcript showCR:bag contents
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   223
    "
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   224
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   225
    "Created: / 11.11.1999 / 09:25:39 / stefan"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   226
    "Modified: / 12.11.1999 / 17:22:01 / stefan"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   227
!
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   228
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   229
nextByte
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   230
    "get the next random byte"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   231
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   232
    ^ RandFile nextByte
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   233
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   234
    "
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   235
      RandomGenerator new nextByte
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   236
    "
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   237
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   238
    "Created: / 11.11.1999 / 09:25:39 / stefan"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   239
!
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   240
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   241
nextBytes:cnt
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   242
    "get the next cnt random bytes"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   243
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   244
    ^ RandFile nextBytes:cnt.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   245
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   246
    "
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   247
      RandomGenerator new nextBytes:4
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   248
    "
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   249
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   250
    "Created: / 11.11.1999 / 09:25:39 / stefan"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   251
    "Modified: / 11.11.1999 / 09:52:26 / stefan"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   252
!
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   253
1640
2c08e5efee48 new: #nextCharacters:
Stefan Vogel <sv@exept.de>
parents: 1606
diff changeset
   254
nextCharacters:cnt
2c08e5efee48 new: #nextCharacters:
Stefan Vogel <sv@exept.de>
parents: 1606
diff changeset
   255
    "get the next cnt printable characters.
2c08e5efee48 new: #nextCharacters:
Stefan Vogel <sv@exept.de>
parents: 1606
diff changeset
   256
     We answer characters in the ascii range (codepoints 32 - 127)"
2c08e5efee48 new: #nextCharacters:
Stefan Vogel <sv@exept.de>
parents: 1606
diff changeset
   257
2c08e5efee48 new: #nextCharacters:
Stefan Vogel <sv@exept.de>
parents: 1606
diff changeset
   258
    |bytes string|
2c08e5efee48 new: #nextCharacters:
Stefan Vogel <sv@exept.de>
parents: 1606
diff changeset
   259
2c08e5efee48 new: #nextCharacters:
Stefan Vogel <sv@exept.de>
parents: 1606
diff changeset
   260
    bytes := self nextBytes:cnt.
2c08e5efee48 new: #nextCharacters:
Stefan Vogel <sv@exept.de>
parents: 1606
diff changeset
   261
    string := String new:cnt.
2c08e5efee48 new: #nextCharacters:
Stefan Vogel <sv@exept.de>
parents: 1606
diff changeset
   262
2c08e5efee48 new: #nextCharacters:
Stefan Vogel <sv@exept.de>
parents: 1606
diff changeset
   263
    bytes keysAndValuesDo:[:eachIndex :eachByte|
2c08e5efee48 new: #nextCharacters:
Stefan Vogel <sv@exept.de>
parents: 1606
diff changeset
   264
        string at:eachIndex put:(Character value:(eachByte \\ 95 + 32)).
2c08e5efee48 new: #nextCharacters:
Stefan Vogel <sv@exept.de>
parents: 1606
diff changeset
   265
    ].
2c08e5efee48 new: #nextCharacters:
Stefan Vogel <sv@exept.de>
parents: 1606
diff changeset
   266
2c08e5efee48 new: #nextCharacters:
Stefan Vogel <sv@exept.de>
parents: 1606
diff changeset
   267
    ^ string
2c08e5efee48 new: #nextCharacters:
Stefan Vogel <sv@exept.de>
parents: 1606
diff changeset
   268
2c08e5efee48 new: #nextCharacters:
Stefan Vogel <sv@exept.de>
parents: 1606
diff changeset
   269
2c08e5efee48 new: #nextCharacters:
Stefan Vogel <sv@exept.de>
parents: 1606
diff changeset
   270
    "
2c08e5efee48 new: #nextCharacters:
Stefan Vogel <sv@exept.de>
parents: 1606
diff changeset
   271
      RandomGenerator new nextCharacters:8
2c08e5efee48 new: #nextCharacters:
Stefan Vogel <sv@exept.de>
parents: 1606
diff changeset
   272
    "
2c08e5efee48 new: #nextCharacters:
Stefan Vogel <sv@exept.de>
parents: 1606
diff changeset
   273
!
2c08e5efee48 new: #nextCharacters:
Stefan Vogel <sv@exept.de>
parents: 1606
diff changeset
   274
1606
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   275
nextInteger
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   276
    "return the next integral random number,
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   277
     in the range 0 .. 16r3FFFFFFF."
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   278
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   279
    |res|
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   280
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   281
    res := self nextBytes:4.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   282
    ^ ((((((res at:1) bitAnd:16r3F) * 256) + (res at:2)) * 256) + (res at:3)) * 256 + (res at:4)
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   283
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   284
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   285
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   286
    "
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   287
     |r|
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   288
     r := RandomGenerator new.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   289
     Transcript showCR:r nextInteger.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   290
     Transcript showCR:r nextInteger.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   291
     Transcript showCR:r nextInteger.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   292
     Transcript showCR:r nextInteger.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   293
    "
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   294
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   295
    "Modified: / 11.11.1999 / 10:08:10 / stefan"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   296
!
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   297
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   298
nextIntegerBetween:start and:stop
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   299
    "return an integral random number between start and stop"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   300
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   301
    |rnd|
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   302
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   303
    rnd := self next.                               
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   304
    rnd := rnd * ((stop - start) asFloat + 1.0).    
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   305
    ^ rnd truncated + start
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   306
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   307
    "
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   308
     |r|
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   309
     r := RandomGenerator new.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   310
     Transcript showCR:(r nextIntegerBetween:1 and:10).
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   311
     Transcript showCR:(r nextIntegerBetween:1 and:10).
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   312
     Transcript showCR:(r nextIntegerBetween:1 and:10).
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   313
     Transcript showCR:(r nextIntegerBetween:1 and:10).
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   314
    "
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   315
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   316
    "
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   317
     |r bag|
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   318
     r := RandomGenerator new.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   319
     bag := Bag new.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   320
     1000000 timesRepeat:[
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   321
         bag add:(r nextIntegerBetween:-1 and:1).
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   322
     ].
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   323
     Transcript showCR:bag contents
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   324
    "
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   325
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   326
    "Created: / 11.11.1999 / 10:28:36 / stefan"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   327
!
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   328
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   329
nextMatchFor: aNumber
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   330
    "generate the next random, return true iff it has the same
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   331
     value as aNumber. Redefined to avoid endless reading."
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   332
1840
6cc7e54f6a62 formatting
Stefan Vogel <sv@exept.de>
parents: 1640
diff changeset
   333
    ^ self next = aNumber
1606
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   334
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   335
    "Created: / 11.11.1999 / 10:29:32 / stefan"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   336
! !
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   337
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   338
!RandomGenerator methodsFor:'writing'!
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   339
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   340
nextPut:something
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   341
    "change the random pool by feeding in something.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   342
     Something should be some unpredictable, random event.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   343
     Ignored here"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   344
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   345
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   346
!
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   347
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   348
nextPutAll:something
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   349
    "change the random pool by feeding in something.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   350
     Something should be some unpredictable, random event.
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   351
     Ignored here"
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   352
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   353
! !
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   354
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   355
!RandomGenerator class methodsFor:'documentation'!
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   356
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   357
version
2438
3601d0065aff changed: #new - use microSecondTime to add entropy
Stefan Vogel <sv@exept.de>
parents: 2432
diff changeset
   358
    ^ '$Header: /cvs/stx/stx/libbasic2/RandomGenerator.st,v 1.6 2010-03-30 12:32:10 stefan Exp $'
2432
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   359
!
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   360
77c3b2c22e9c Keep a shared RandomGenerator.
Stefan Vogel <sv@exept.de>
parents: 1925
diff changeset
   361
version_CVS
2438
3601d0065aff changed: #new - use microSecondTime to add entropy
Stefan Vogel <sv@exept.de>
parents: 2432
diff changeset
   362
    ^ '$Header: /cvs/stx/stx/libbasic2/RandomGenerator.st,v 1.6 2010-03-30 12:32:10 stefan Exp $'
1606
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   363
! !
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   364
ad25ac239337 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   365
RandomGenerator initialize!