Answered by:
a magic 8 ball algorithm or doing cartomancy in small basic with a 90% edge pls correction
Question

Here the monty hall explained:
https://www.youtube.com/watch?v=Zr_xWfThjJ0
So I was thinking if you could do that with cards so I tried.
Soon I realized playing with just 3 cards meant that most probably you would eleimnate your pick or the price so this is what I did:
I extended the option to 52 poker cards and the prizes to both red aces.
I pick after shufle the first 13 cards and start elminating cards till I get a red ace.
Now theres just one red ace left, thats the prize but there has been a change of variable so its in my interest to switch pick.
I did a program that studies this startegy and it gives you an edge as it should matematically.
http://smallbasic.com/program/?PZF902
so what error could it be here really i dont think that can be right
 Edited by antonio glez Thursday, February 2, 2017 9:42 PM
Answers

Antonio glez,
Here's your program changed to what I think is right. In the subroutine "TestOnRandomness" it counts the wins. Also, I put a count to count the number of games played. Then print out the number of games, the number of wins and the percentage which should be 50%. Also,I commented out the else and win in that routine.
JR
re:
shufle()
testonrandomness()
TextWindow.WriteLine("wins "+win+" Games "+Count+" Percentage "+Math.Round(win/Count*100))
Goto re
'this is to shufle 52 cards
sub shufle
i=1
deck=""
While i<53
reshufle:
card= Math.GetRandomNumber(52)
If Array.ContainsValue(deck,card) Then
Goto reshufle
EndIf
deck[i]=card
i=i+1EndWhile
EndSub' i test if theres a 1 among the first 26 cards that should be a 50% chance
Sub testonrandomness
count=count+1
For i=1 To 26
If deck[i]=1 Then
win=win+1'Else'win=win1
EndIfEndFor
EndSub
 Edited by jricestkEditor Saturday, February 4, 2017 10:52 PM Edit
 Proposed as answer by Ed Price  MSFTMicrosoft employee, Owner Tuesday, February 7, 2017 11:18 PM
 Marked as answer by litdevModerator Tuesday, February 14, 2017 8:39 PM

with replacing goto statement with whileendwhile loop it look like this:
________________________________________________________________________________
' test for 2000 games stats, it gives 50% after 2000 ' scale of probalilty
' program CDC842While games <> 2000
shufle()
testonrandomness()
TextWindow.WriteLine("wins "+win+" Games "+Count+" Percentage "+Math.Round(win/Count*100))
games=games+1
endwhile'this is to shufle 52 cards
sub shufle
i=1
deck=""
While i<53
card= Math.GetRandomNumber(52)
double= Array.ContainsValue(deck,card)
While double = "false"
endwhile
deck[i]=card
i=i+1
EndWhile
EndSub
' i test if theres a 1 among the first 26 cards that should be a 50% chance
Sub testonrandomness
count=count+1
For i=1 To 26
If deck[i]=1 Then
win=win+1
'Else
'win=win1
EndIf
EndFor
EndSub Proposed as answer by Ed Price  MSFTMicrosoft employee, Owner Tuesday, February 7, 2017 11:18 PM
 Marked as answer by litdevModerator Tuesday, February 14, 2017 8:39 PM
All replies

Hi !
Here is the output to the text.window screen,it seems that the BOB figure always go +13
and edge start to 100 and steady decrease...
a hint:
round the bob/x*100 value to 2 decimal like this:
___________________________________________________________________________
break2:
edge=math.Round((bob/x)*10000)/100
TextWindow.WriteLine("wins "+bob+" edge "+edge)Goto rey
______________________________________________________________________
results:
 Edited by YLedEditor Thursday, February 2, 2017 10:17 PM
 Proposed as answer by Ed Price  MSFTMicrosoft employee, Owner Tuesday, February 7, 2017 11:18 PM

thanks for the heads up, i corrected the rounding the edge part
also i realized that sometimes the dealers turns face up cards of the 13 picked and that shouldnt be like that, in that case that should be a null game
i corrected the code and now theres a 60 % edge but that can not be posible there has to be something wrong with the code, here it is:
edit:
i think the reason winning grow steady and suddenly drop in the beginning is because the writeline command only happens in the wiinnings so loses dont show up till theres a next win
 Edited by antonio glez Friday, February 3, 2017 6:13 PM

Hi Antonio !
My suggestion:
Seems to me that it would be easier to understand this program by replacing a few goto by subroutines SUB connections.?
 Proposed as answer by Ed Price  MSFTMicrosoft employee, Owner Tuesday, February 7, 2017 11:18 PM


Antonio glez,
Here's your program changed to what I think is right. In the subroutine "TestOnRandomness" it counts the wins. Also, I put a count to count the number of games played. Then print out the number of games, the number of wins and the percentage which should be 50%. Also,I commented out the else and win in that routine.
JR
re:
shufle()
testonrandomness()
TextWindow.WriteLine("wins "+win+" Games "+Count+" Percentage "+Math.Round(win/Count*100))
Goto re
'this is to shufle 52 cards
sub shufle
i=1
deck=""
While i<53
reshufle:
card= Math.GetRandomNumber(52)
If Array.ContainsValue(deck,card) Then
Goto reshufle
EndIf
deck[i]=card
i=i+1EndWhile
EndSub' i test if theres a 1 among the first 26 cards that should be a 50% chance
Sub testonrandomness
count=count+1
For i=1 To 26
If deck[i]=1 Then
win=win+1'Else'win=win1
EndIfEndFor
EndSub
 Edited by jricestkEditor Saturday, February 4, 2017 10:52 PM Edit
 Proposed as answer by Ed Price  MSFTMicrosoft employee, Owner Tuesday, February 7, 2017 11:18 PM
 Marked as answer by litdevModerator Tuesday, February 14, 2017 8:39 PM

with replacing goto statement with whileendwhile loop it look like this:
________________________________________________________________________________
' test for 2000 games stats, it gives 50% after 2000 ' scale of probalilty
' program CDC842While games <> 2000
shufle()
testonrandomness()
TextWindow.WriteLine("wins "+win+" Games "+Count+" Percentage "+Math.Round(win/Count*100))
games=games+1
endwhile'this is to shufle 52 cards
sub shufle
i=1
deck=""
While i<53
card= Math.GetRandomNumber(52)
double= Array.ContainsValue(deck,card)
While double = "false"
endwhile
deck[i]=card
i=i+1
EndWhile
EndSub
' i test if theres a 1 among the first 26 cards that should be a 50% chance
Sub testonrandomness
count=count+1
For i=1 To 26
If deck[i]=1 Then
win=win+1
'Else
'win=win1
EndIf
EndFor
EndSub Proposed as answer by Ed Price  MSFTMicrosoft employee, Owner Tuesday, February 7, 2017 11:18 PM
 Marked as answer by litdevModerator Tuesday, February 14, 2017 8:39 PM