This is an object that provides a simple way to do probability simulations and such. It comes with documentation and an example. I've spent all morning working on it, but I can't guarantee that there are no bugs left in it - if you find anything let me know.
http://notthecheatr.phatcode.net/downlo ... _AI_pm.zip
Code: Select all
'' ntc.AI probability machine - coin-flipping example
Dim As pmObject probMachine = pmObject()
'Store how many times heads or tails is chosen
Dim As uInteger ht (1 To 2)
'How many times to flip?
Dim As uInteger numFlips
'Add two choices, each with a 50% chance
'Find out how many times to flip the coin
Print "How many flips do you want?"
'Flip that many times
For i As uInteger = 1 To numFlips
'We add 1 to the index because choose() returns 0 or 1.
ht(probMachine.choose() + 1) += 1
'How many times was each chosen?
Print "Heads: " + Str(ht(1))
Print "Tails: " + Str(ht(2))