Jump to content

Pig the dice game: Difference between revisions

Added uBasic/4tH version
imported>Thebeez
(Added uBasic/4tH version)
Line 5,057:
Bert is a winner, on 101</pre>
 
=={{header|uBasic/4tH}}==
<syntaxhighlight lang="qbasic">n = 2
m = 100
Dim @s(n)
 
p = 0
s = 0
 
Do
r = Ask(Join ("Player ", Str(p+1)," rolling? (Y/N) "))
 
If OR(Peek(r, 0), 32) = Ord("y") Then
r = Rnd(6) + 1
Print "Player ";p+1;" rolled ";r
 
If r = 1 Then
Print "Bust! you lose player ";p+1;" but still keep your previous score of ";@s(p)
Print : p = (p + 1) % n : s = 0
Else
s = s + r
EndIf
 
Else
@s(p) = @s(p) + s
 
If (@s(p) < m) = 0 Then
Print "Player ";p+1;" wins with a score of ";@s(p)
Break
EndIf
 
Print : p = (p + 1) % n : s = 0
EndIf
Loop</syntaxhighlight>
=={{header|VBA}}==
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.