|
Post by bluatigro on Feb 13, 2022 8:32:16 GMT -5
there is a demon whit 4 dice you may choise 1 of the dice end then the computer rols the dice 100 times if the demon has less then 50% you win
try to win from the demon
'' bluatigro 13 feb 2022 '' demon dice dim dice( 3 , 5 ) for d = 0 to 3 for i = 0 to 5 read a dice( d , i ) = a next i next d data 1 , 1 , 5 , 1 , 1 , 5 data 2 , 2 , 2 , 2 , 6 , 6 data 3 , 3 , 3 , 3 , 3 , 3 data 0 , 0 , 4 , 4 , 4 , 4 input "Whitch dice do you choise ? [ 0...3 ]" ; in$ human = val( in$ ) comp = ( human + 1 ) and 3 tel = 0 for i = 0 to 999 humandice = dice( human , int( rnd(0) * 6 ) ) compdice = dice( comp , int( rnd(0) * 6 ) ) print i , "I : " ; compdice , "You : " ; humandice , ; if compdice > humandice then print "I win ." tel = tel + 1 else print "You win ." end if next i print "I won " ; tel/10 ; " % ."
|
|
|
Post by bluatigro on Feb 15, 2022 5:21:25 GMT -5
i chaged the code a litle now you hae a slim chance that you win
'' bluatigro 13 feb 2022 '' demon dice dim dice( 3 , 5 ) for d = 0 to 3 for i = 0 to 5 read a dice( d , i ) = a next i next d data 1 , 1 , 5 , 1 , 1 , 5 data 2 , 2 , 2 , 2 , 6 , 6 data 3 , 3 , 3 , 3 , 3 , 3 data 0 , 0 , 4 , 4 , 4 , 4 print "demon dice :" print print "choise 1 of the folowing dice :" print "dice 0 : 1 , 5 ." print "dice 1 : 2 , 6 ." print "dice 2 : 3 ." print "dice 3 : 0 , 4 ." input "whitch dice do you choise ? [ 0...3 ]" ; in$ human = val( in$ ) comp = ( human + 1 ) and 3 print "i choise dice : " ; comp tel = 0 for i = 0 to 9 humandice = dice( human , int( rnd(0) * 6 ) ) compdice = dice( comp , int( rnd(0) * 6 ) ) print i , "i : " ; compdice , "you : " ; humandice , ; if compdice > humandice then print "i win ." tel = tel + 1 else print "you win ." end if next i print "i won " ; tel * 10 ; " % ." if tel < 5 then print "you win !!" else if tel > 5 then print "i win !!" else print "equal !!" end if end if
|
|
|
Post by dan1101 on Feb 16, 2022 6:35:47 GMT -5
I have been having fun analyzing your Demon Dice program. I was interested in seeing how likely it was for the human to win versus the computer. In the original version, I believed that it was impossible for the human player to win. To test this theory, I created a simple shell around your program to automate playing a million games and analyze the results. To speed things up, I removed all the print statements except at the conclusion. I later modified this to show the progress every 1000 games.
The results for your original game showed that the computer had a better than 99.99 percent chance of winning. The human won 56 games out of one million, so I was wrong, it was POSSIBLE for the human to win, but extremely unlikely.
I created a similar shell for your new version (included below). It takes my computer a bit under two minutes to play one million games of the new version. If you want to run it for more or fewer games, change the value of Max. The value of Max represents 1000 games. So as written it plays 1000 X 1000 or one million games.
The results: The computer now wins only 76 percent of the time, the human just over 10 percent, and about 13 percent result in a tie.
These results represent the human player randomly choosing between the four dice offered. By changing the statement where the 'human' player randomly selects the dice to a direct statement such as 'human=2', we could see the differing odds for each selection, one at a time. You could also simply add an array to track each of the four separately, if you wish.
Thank you for sharing your program.
'' bluatigro 13 feb 2022 '' demon dice
PlayerWins=0 ComputerWins=0 tie=0
dim dice( 3 , 5 ) for d = 0 to 3 for i = 0 to 5 read a dice( d , i ) = a next i next d data 1 , 1 , 5 , 1 , 1 , 5 data 2 , 2 , 2 , 2 , 6 , 6 data 3 , 3 , 3 , 3 , 3 , 3 data 0 , 0 , 4 , 4 , 4 , 4
Max=1000
For Count=1 to Max
For J=1 to 1000
rem Original program starts here *****************************
'dim dice( 3 , 5 ) 'for d = 0 to 3 ' for i = 0 to 5 ' read a ' dice( d , i ) = a ' next i 'next d 'data 1 , 1 , 5 , 1 , 1 , 5 'data 2 , 2 , 2 , 2 , 6 , 6 'data 3 , 3 , 3 , 3 , 3 , 3 'data 0 , 0 , 4 , 4 , 4 , 4
'print "demon dice :" 'print 'print "choise 1 of the folowing dice :" 'print "dice 0 : 1 , 5 ." 'print "dice 1 : 2 , 6 ." 'print "dice 2 : 3 ." 'print "dice 3 : 0 , 4 ." 'input "whitch dice do you choise ? [ 0...3 ]" ; in$
rem The statement below automates play so the 'human' now randomly chooses one of the four dice offered
human=INT(rnd(1)*4): rem Randomly chooses a number from 0 to 3
'human = val( in$ ) comp = ( human + 1 ) and 3 'print "i choise dice : " ; comp tel = 0 for i = 0 to 9 humandice = dice( human , int( rnd(0) * 6 ) ) compdice = dice( comp , int( rnd(0) * 6 ) ) ' print i , "i : " ; compdice , "you : " ; humandice , ; if compdice > humandice then ' print "i win ." tel = tel + 1 else ' print "you win ." end if next i 'print "i won " ; tel * 10 ; " % ." 'if tel < 5 then ' print "you win !!" 'else ' if tel > 5 then ' print "i win !!" ' else ' print "equal !!" ' end if 'end if
rem Original program ends here *****************************
If tel > 5 then ComputerWins=ComputerWins+1 If tel < 5 then PlayerWins=PlayerWins+1 If tel = 5 then tie = tie + 1
Next J
Print "Games: ";Count*1000; " Computer: ";ComputerWins; " Human: ";PlayerWins; " Tie: ";tie
Next Count
Print Print "Computer won: ";ComputerWins Print "Player won: ";PlayerWins Print "Tie: ";tie Print Print "The Computer won ";(ComputerWins/Max)/10;"% of the time." Print Print "The Player won ";(PlayerWins/Max)/10;"% of the time." Print Print "Ties occurred ";(tie/Max)/10;"% of the time."
|
|