|
Post by bplus on Jul 21, 2024 19:52:16 GMT
Compare to here: www.vintage-basic.net/games.htmlAcey Ducey Update _Title "Acey Ducey 2024-07-21 version" ' b+ 2024-07-21 Randomize Timer ranking$ = "23456789TJQKA" ' one letter or digit to designate card value bank = 100 While bank r1 = Int(Rnd * 13) + 1: r2 = Int(Rnd * 13) + 1: r3 = Int(Rnd * 13) + 1 If r1 < r2 Then low = r1: high = r2 Else low = r2: high = r1 Print Mid$(ranking$, r1, 1); " "; Mid$(ranking$, r2, 1) Print "You have"; bank; "to bet." Input "Enter your bet "; bet If bet > bank Then bet = bank If bet = 0 Then bet = 1 Print "Betting"; bet; Chr$(10); Mid$(ranking$, r3, 1) If r3 >= low And r3 <= high Then bank = bank + bet: Print "You won"; bet: Print If r3 < low Or r3 > high Then bank = bank - bet: Print "You lost"; bet: Print Wend Print "Game Over, no money left to bet." Talk about rescued code ![:)](//storage.proboards.com/forum/images/smiley/smiley.png)
|
|
|
Post by bplus on Jul 21, 2024 23:26:13 GMT
Change Update:
_Title "Change Update" ' b+ 2024-07-21 Dim a&(1 To 10), s$(1 To 10) a&(1) = 5000: a&(2) = 2000: a&(3) = 1000: a&(4) = 500: a&(5) = 100 a&(6) = 50: a&(7) = 25: a&(8) = 10: a&(9) = 5: a&(10) = 1 s$(1) = "$50 bills": s$(2) = "$20 bills": s$(3) = "$10 bills": s$(4) = "$5 bills": s$(5) = "$1 bills" s$(6) = "half dollars": s$(7) = "quarters": s$(8) = "dimes": s$(9) = "nickels": s$(10) = "pennies" restart: Print: Input "Enter amount to collect up to 100.00 (0 to quit)"; collect If collect <= 0 Or collect > 100 Then End Input "Enter amount paid "; paid change = paid - collect If change < 0 Then Print "You did not pay enough.": GoTo restart If change = 0 Then Print "Thank you come again.": GoTo restart c& = change * 100 For i = 1 To 10 amt& = Int(c& / a&(i)): TotChange = TotChange + amt& * a&(i) If amt& Then c& = c& - amt& * a&(i): Print amt&; " "; s$(i) Next GoTo restart
|
|
|
Post by bplus on Jul 22, 2024 17:38:44 GMT
Reverse Update:
_Title "Reverse Update" 'b+ 2024-07-21 directions 7-22 ' compare to Reverse here www.vintage-basic.net/games.html ' David Ahl's compilation of Basic Games and other stuff
' Directions for Reverse Puzzle:
' Reverse goal is to get the given string of digits back in order from 1 to 9. ' Asking to reverse say 5 will swap first with 5th, 2nd with 4th and that leaves 3 unmoved. ' so 5 4 3 2 1 6 7 8 9 reverse 5 ' gets 1 2 3 4 5 6 7 8 9 exactly what we are trying to achieve, you got it! ' reverse always starts on left and counts n to right, note: so reverse 1 does nothing. ' ' Another example from help in original code: ' 2 3 4 5 1 6 7 8 9 ' reverse 4 ' 5 4 3 2 1 6 7 8 9 ' now just reverse 5 ' 1 2 3 4 5 6 7 8 9 You got it! ' ' numbers printed on far left are just counting the number of times you use reverse.
Randomize Timer Dim Shared c$ r$ = " 1 2 3 4 5 6 7 8 9" c$ = r$ restart: cnt = 0 fini% = Int(Rnd * 11) + 2 For i = 1 To fini% r% = Int(Rnd * 8) + 2 c$ = reverse$(r%) Next Do Print cnt, c$ Input "Enter how many to reverse (0 quits)"; n c$ = reverse$(n) If c$ = r$ Then Print cnt, c$; " You did it!": Print: Print: Exit Do Else cnt = cnt + 1 Loop GoTo restart
Function reverse$ (n As Integer) If n = 0 Then End For i = 1 To 2 * n Step 2 b$ = Mid$(c$, i, 2) + b$ Next reverse$ = b$ + Mid$(c$, 2 * n + 1) End Function
|
|
|
Post by bplus on Jul 22, 2024 19:00:30 GMT
Oh ha! The Reverse Game is so easy I made an AI to play it!
_Title "Reverse Update with AI" 'b+ 2024-07-21 directions 7-22 with AI 7-22 ' compare to Reverse here www.vintage-basic.net/games.html ' David Ahl's compilation of Basic Games and other stuff
' Directions for Reverse Puzzle:
' Reverse goal is to get the given string of digits back in order from 1 to 9. ' Asking to reverse say 5 will swap first with 5th, 2nd with 4th and that leaves 3 unmoved. ' so 5 4 3 2 1 6 7 8 9 reverse 5 ' gets 1 2 3 4 5 6 7 8 9 exactly what we are trying to achieve, you got it! ' reverse always starts on left and counts n to right, note: so reverse 1 does nothing. ' ' Another example from help in original code: ' 2 3 4 5 1 6 7 8 9 ' reverse 4 ' 5 4 3 2 1 6 7 8 9 ' now just reverse 5 ' 1 2 3 4 5 6 7 8 9 You got it! ' ' numbers printed on far left are just counting the number of times you use reverse.
Randomize Timer Dim Shared c$ r$ = " 1 2 3 4 5 6 7 8 9" c$ = r$ restart: cnt = 0 fini% = Int(Rnd * 11) + 2 For i = 1 To fini% r% = Int(Rnd * 8) + 2 c$ = reverse$(r%) Next Do Print cnt; " reverses", c$ 'Input "Enter how many to reverse (0 quits)"; n n = reverseAI% If n = 0 Then Print "Already done!": Exit Do Print "AI says reverse"; n c$ = reverse$(n) If c$ = r$ Then Print cnt, c$; " AI did it!": Print: Print: Exit Do Else cnt = cnt + 1 _Delay 10 Loop GoTo restart
Function reverse$ (n As Integer) For i = 1 To 2 * n Step 2 b$ = Mid$(c$, i, 2) + b$ Next reverse$ = b$ + Mid$(c$, 2 * n + 1) End Function
Function reverseAI% ' from right to left find the first digit out of order Dim As Integer i, x, place For i = 9 To 2 Step -1 x$ = Mid$(c$, i * 2, 1) If x$ <> _Trim$(Str$(i)) Then lookup$ = _Trim$(Str$(i)) 'Print "lookup$ "; lookup$ Exit For End If Next place = InStr(c$, lookup$) / 2 'Print "place"; place If place = 1 Then reverseAI% = Val(lookup$) Else reverseAI% = place End Function
I had to slow it way down so a human might be able to follow it.
|
|