BeBot - An Anarchy Online and Age Of Conan chat automaton

General => Feedback and Suggestions => Topic started by: xdave78 on June 12, 2009, 05:52:04 pm

Title: Flip-always returns HEADS
Post by: xdave78 on June 12, 2009, 05:52:04 pm
Hey,

there must be sth wrong with the flip-command. It always returns Heads!

Regards
Title: Re: Flip-always returns HEADS
Post by: redmagician on June 13, 2009, 04:50:38 am
Yep, confirmed.
15 rolls on the current version all resulted in heads.

To fix it change this line in Roll.php

$result['result'] = ((rand(1, 2)) ? 'heads' : 'tails');

to

$result['result'] = ((rand(0, 1)) ? 'heads' : 'tails');

The random number generator seems a bit skewed though.
A test of 15 runs with the 'fix' produced 11 heads to 4 tails.
Title: Re: Flip-always returns HEADS
Post by: Temar on June 15, 2009, 04:00:45 am
what happened is rand was told to roll the number 1 or 2
the ? is a way of doing if() of wats before, 1 and 2 would be true so both output head
0 and 1 howeva wont the 0 will register as false and give tails
SimplePortal 2.3.7 © 2008-2024, SimplePortal