crazysaint Posted July 16, 2007 Share Posted July 16, 2007 i would like to come up with two codes in ASP that will a) simulate the throeing of a dice: when run it should display the face value of the dice(between 1 and 6) b)then also i would like to come up with another code that shows that all faces have equal liklihood of being shown.(should throw it for about 6000 times). i know it has something to do with using a counter for eah face and increment as it wins. Link to comment https://forums.phpfreaks.com/topic/60182-randomization-code/ Share on other sites More sharing options...
ToonMariner Posted July 16, 2007 Share Posted July 16, 2007 hmmm maybe you should try an asp forum. in php this may help (assumes you really want to do the 6000 throws)... $throw = rand(1,6); echo $throw; $throwarr = array(); for($i = 0; $i < 6000; $i++) { $throwarr[] = rand(1,6); } $numbers = array_unique($throwarr); $tally = array(); foreach ($numbers as $val) { $tally[$val] = count(array_keys($throwarr,$val)); } print_r($tally); Link to comment https://forums.phpfreaks.com/topic/60182-randomization-code/#findComment-299376 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.