Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use "random"
- use "time"
- // How should one use the Random class?
- // if it is reading from a psudo file, then should we have one file descriptor
- // for that file?
- actor Main
- new create(env: Env) =>
- env.out.print("Hello World")
- // seed and prepare the PRNG once
- (let a: I64, let b: I64) = Time.now()
- let r: Random = Rand(a.u64(), b.u64())
- r.u128() // throw away the first bits - because the first bits seem to be predicable from XorOshiro128Plus
- // pass it around for classes to claim random elements.
- let g: Genes val = Genes.create(8, r)
- class val Genes
- let _genes: Array[U8] val
- new val create(chromosones: USize, rand: Random) =>
- // rand: Random
- // this parameter must be sendable (iso, val or tag)
- let genes' = recover iso Array[U8](chromosones) end
- var i: USize = 0
- while i < chromosones do
- genes'.push(rand.u8())
- i = i + 1
- end
- _genes = recover val consume genes' end
Add Comment
Please, Sign In to add comment