41 lines
800 B
Plaintext
41 lines
800 B
Plaintext
If OpenConsole()
|
|
PLAYER.i = 1
|
|
COMP.i = 0
|
|
|
|
sum.i = 0
|
|
total.i = 0
|
|
turn.i = Random(1) + 0.5
|
|
Dim precomp.i(3)
|
|
precomp(0) = 1
|
|
precomp(1) = 1
|
|
precomp(2) = 3
|
|
precomp(3) = 2
|
|
|
|
While sum < 21
|
|
turn = 1 - turn
|
|
PrintN("The sum is " + Str(sum))
|
|
If turn = PLAYER
|
|
PrintN("It is your turn.")
|
|
While total < 1 Or total > 3 Or total + sum > 21
|
|
Print("How many would you like to total? ")
|
|
total = Val(Input())
|
|
Wend
|
|
Else
|
|
PrintN("It is the computer's turn.")
|
|
total = precomp(sum % 4)
|
|
PrintN("The computer totals " + Str(total) + ".")
|
|
EndIf
|
|
PrintN("")
|
|
sum + total
|
|
total = 0
|
|
Wend
|
|
|
|
If turn = PLAYER
|
|
PrintN("Congratulations. You win.")
|
|
Else
|
|
PrintN("Bad luck. The computer wins.")
|
|
EndIf
|
|
|
|
Input()
|
|
EndIf
|