Omnimaga

Calculator Community => Casio Calculators => Topic started by: sjasogun1 on May 30, 2011, 12:58:36 pm

Title: Monopoly
Post by: sjasogun1 on May 30, 2011, 12:58:36 pm
I created a small program to simulate walking over a 40 square monopoly board (without the cards and special squares of course). The odd thing is that after I let it run for one-and-a-half hour (100.000 dice rolls) there were some really big deviations from the expected 2500 per square. They occur with intervals of 7 squares and are in pairs, the first of the pair being around 3100, the second one being around 2000.
They occur on 1, 8-9, 16-17, 24-25, 32-33, 40 (40 and 1 are also a pair). Does anybody know where this comes from? Here is the code (not that complex really):
Code: [Select]
For 1-->A To 40
0-->List 11[A]
Next
0-->A:1-->B:0-->C
Lbl 0
RanInt#(1,6)+RanInt(1,6)-->A
A+B-->B
B>40==>B-40-->B
List 11[B]+1-->List 11[B]
C+1-->C
Locate 1,1,C
Goto 0
Title: Re: Monopoly
Post by: ruler501 on May 30, 2011, 02:51:01 pm
dice rolls of 7 are 6 times as likely as dice rolls of 12. so numbers closest to 7 are most likely causing that strange phenomenon
Title: Re: Monopoly
Post by: sjasogun1 on May 31, 2011, 03:29:59 am
I thought about that already, but if you assume there are only rolls of 7 you'll notice it'll pass every single square on the board once, so that shouldn't be causing it. Besides, investigations by others (with almost 1 billion rolls) confirmed every square will be passed the same amount of times (within two standard deviations of course).
Title: Re: Monopoly
Post by: jsj795 on May 31, 2011, 04:08:46 am
Do u think the random seed is what's causing it? Change the random seed number and try again
Title: Re: Monopoly
Post by: sjasogun1 on May 31, 2011, 06:40:37 am
Do u think the random seed is what's causing it? Change the random seed number and try again

I'm sorry, I don't understand. You mean I should input something like RanInt(3,11) instead?
Title: Re: Monopoly
Post by: ruler501 on May 31, 2011, 06:43:11 am
No you have to have a seed for random numbers. I don't know how this works on calc just n comp, but that seed can define all the random numbers so you need to try again with a different seed to see if that was the problem
Title: Re: Monopoly
Post by: Ashbad on May 31, 2011, 09:38:36 am
RandInt(1,6)+RandInt(1,6) isn't the greatest idea, since the most hit pseudo-random number for each will be 3-4. and while it's similar to RandInt(1,12), it's not always the same.  I would test around with things like this:

Code: [Select]
(RandInt(1,3) * RandInt(1,2)) + (RandInt(1,4) + RandInt(1,2))
Test around with weird setups like these until you hit a consistency that you're aiming towards :)
Title: Re: Monopoly
Post by: Builderboy on May 31, 2011, 01:13:53 pm
I think he's doing it that way to simulate actual dice ;)
Title: Re: Monopoly
Post by: Ashbad on May 31, 2011, 04:11:41 pm
Yeah I know, but based on what platform you're on the RNG may not be truly random, and have certain "sticky places" that are called upon most often.  If you mess around with smaller seeds, though, you may be able to counteract it in many cases :)
Title: Re: Monopoly
Post by: sjasogun1 on June 01, 2011, 04:11:27 am
I don't know how to change the random number seed; the only thing I know is that when I reset my calc the random number sequence will reset itself as well, but that'd only make things worse, wouldn't it?
Title: Re: Monopoly
Post by: DJ Omnimaga on June 03, 2011, 09:02:39 pm
Is it even possible to change the number seed at all on Casio calcs? On the 83+ I know you could do for example 17->Rand, but I'm not sure about Casio
Title: Re: Monopoly
Post by: z80man on June 05, 2011, 10:24:18 pm
Is it even possible to change the number seed at all on Casio calcs? On the 83+ I know you could do for example 17->Rand, but I'm not sure about Casio

Yes you can, by using Ran# (any integer between 1 and 9) which generates a number between 0 and 1. You can also use 0 as a seed but then 0 is always generated.
Title: Re: Monopoly
Post by: m1ac4 on June 06, 2011, 08:19:44 am
Is it even possible to change the number seed at all on Casio calcs? On the 83+ I know you could do for example 17->Rand, but I'm not sure about Casio

Yes you can, by using Ran# (any integer between 1 and 9) which generates a number between 0 and 1. You can also use 0 as a seed but then 0 is always generated.
That will come in handy.  I was having problems with my RPG where I couldn't tell whether the battle system was working or not because the damages dealt didn't "feel" random enough.  Although that perception is subjective this method is still worth a try to make things a bit more random.
Title: Re: Monopoly
Post by: z80man on June 07, 2011, 10:52:31 am
Now is there any sort of timer command available in BASIC because that's what I'd use as a seed. Otherwise you could also use Rmdr to find the modulus of the previous random as a seed. The syntax is (last random) Rmdr 10
Title: Re: Monopoly
Post by: sjasogun1 on June 07, 2011, 11:54:22 am
Never mind, problem solved, somehow the results were random and just appeared not to be. Every other run of the program returned normal results (95% of the values within 2 standard deviations of the average, checked with CALC1). I also removed the lines involving C since the program runs 4 times as fast without the counter on-screen.
Title: Re: Monopoly
Post by: DJ Omnimaga on June 12, 2011, 02:54:15 am
Is it even possible to change the number seed at all on Casio calcs? On the 83+ I know you could do for example 17->Rand, but I'm not sure about Casio

Yes you can, by using Ran# (any integer between 1 and 9) which generates a number between 0 and 1. You can also use 0 as a seed but then 0 is always generated.
Nah I really meant setting the rand seed, not incrementing. On the 83+, do 1->Rand:Rand 10 times. Notice how it's always the same number. Doing such things before running a game can let you manipulate luck. Some games have a Rand command in the title screen loop to keep incrementing the seed, to prevent such luck manipulation or from the game random values from being the same after every mem clear.