Microsoft Small Basic

Program Listing: WTT654
' bob the gambler loves so much to gamble that i put him in a
'winning gambling infinite loop that starts in rey
rey:
'x is to keep track of the amount bob the gambler bets
x=x+13
i=1
a=""
'a[]is the deck of cards has a limit of 52 and starts in 1
'this is to shufle a french deck
'everytime a repeated card appears it remits to this restart
re:
card= Math.GetRandomNumber(52)
If Array.ContainsValue(a,card) Then
Goto re
EndIf

a[i]=card
i=i+1
'it finishees after the 52 cards have been dealt
If i>52 Then
Goto fin
EndIf
Goto re
fin:

' i pick the first 13 cards

top=52
' i start eleliminating cards from the top till i find a red ace(1 or 2))
restart:

'if all cards have been dealt and there hasnt appeared a red ace bob decides not to bet and the game is null
If a[top]=13 Then
Goto rey
EndIf

' i start turning face up each card till i get a red ace (a 1 or 2)
If a[top]=1 Or a[top]= 2 Then
a[top]=""
Goto break
EndIf
top=top-1
Goto restart

break:

'i bet as the monty hall that the red ace prize is not gonna be in my intitial pick
' the pot is the total cards left minus the ones left i pick
total=top

For i= 1 To 13
If a[i]=1 Or a[i]=2 Then
bob=bob-(total-13)
Goto break2
Else
bob=bob+13
Goto break2
EndIf
EndFor
break2:
edge=math.Round((bob/x)*10000)/100
TextWindow.WriteLine("wins "+bob+" edge "+edge)
Goto rey