basic-computer-games icon indicating copy to clipboard operation
basic-computer-games copied to clipboard

A little more about the spirit of the project???

Open DualBrain opened this issue 2 years ago • 6 comments

OK, so I'm looking at (specifically) the VB (.NET) conversion done for Acey Ducey and was left wondering the overall spirit of this project. Certainly, the conversion done is VB, but it also increases the complexity of the program significantly by introducing a lot of extra concepts. It's already bad enough that VB has a lot of "boiler plate" that many could argue is not necessary for some types of projects... literally this one being a perfect example of such. I'm not criticizing the conversion, that is totally not my intention. Rather I'm trying to wrap my head around the overall goal/intent.

One could argue that this is a chance to "show off" VB's capabilities or, to my thinking, this is more of an exercise of simplicity... taking what was, no pun intended, pretty basic and show how that could be done in a more modern implementation / platform.

To that end, I took a stab at a translation that a) attempts to stay VERY TRUE to the original, b) KISS and c) attempt to keep everything in view by either remaining in the same (or smaller) number of total lines of code (without, of course, straying too far from item a).

Imports System.Console

Module Program

  Sub Main()

    Dim Q, M As Single

    Randomize(Timer)

    WriteLine(Space(26) & "ACEY DUCEY CARD GAME")
    WriteLine(Space(15) & "CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY")
    WriteLine()
    WriteLine()
    WriteLine("ACEY-DUCEY IS PLAYED IN THE FOLLOWING MANNER ")
    WriteLine("THE DEALER (COMPUTER) DEALS TWO CARDS FACE UP")
    WriteLine("YOU HAVE AN OPTION TO BET OR NOT BET DEPENDING")
    WriteLine("ON WHETHER OR NOT YOU FEEL THE CARD WILL HAVE")
    WriteLine("A VALUE BETWEEN THE FIRST TWO.")
    WriteLine("IF YOU DO NOT WANT TO BET, INPUT A 0")
    'N = 100
Start:
    Q = 100
DisplayPool:
    WriteLine("YOU NOW HAVE " & Q & " DOLLARS.")
    WriteLine()
    GoTo DisplayCards
IncreasePool:
    Q += M
    GoTo DisplayPool
DecreasePool:
    Q -= M
    GoTo DisplayPool
DisplayCards:
    WriteLine("HERE ARE YOUR NEXT TWO CARDS: ")
DetermineFirstCard:
    Dim A = Int(14 * Rnd(1)) + 2
    If A < 2 Then GoTo DetermineFirstCard
    If A > 14 Then GoTo DetermineFirstCard
DetermineSecondCard:
    Dim B = Int(14 * Rnd(1)) + 2
    If B < 2 Then GoTo DetermineSecondCard
    If B > 14 Then GoTo DetermineSecondCard
    If A >= B Then GoTo DetermineFirstCard
    If A < 11 Then WriteLine(A)
    If A = 11 Then WriteLine("JACK")
    If A = 12 Then WriteLine("QUEEN")
    If A = 13 Then WriteLine("KING")
    If A = 14 Then WriteLine("ACE")
    If B < 11 Then WriteLine(B)
    If B = 11 Then WriteLine("JACK")
    If B = 12 Then WriteLine("QUEEN")
    If B = 13 Then WriteLine("KING")
    If B = 14 Then WriteLine("ACE") : WriteLine()
EnterBet:
    WriteLine()
    Write("WHAT IS YOUR BET? ") : Dim valid = Single.TryParse(ReadLine(), M)
    If M <> 0 Then GoTo ValidateBet
    WriteLine("CHICKEN!!")
    WriteLine()
    GoTo DisplayCards
ValidateBet:
    If M <= Q Then GoTo DetermineFinalCard
    WriteLine("SORRY, MY FRIEND, BUT YOU BET TOO MUCH.")
    WriteLine("YOU HAVE ONLY " & Q & " DOLLARS TO BET.")
    GoTo EnterBet
DetermineFinalCard:
    Dim C = Int(14 * Rnd(1)) + 2
    If C < 2 Then GoTo DetermineFinalCard
    If C > 14 Then GoTo DetermineFinalCard
    If C < 11 Then WriteLine(C)
    If C = 11 Then WriteLine("JACK")
    If C = 12 Then WriteLine("QUEEN")
    If C = 13 Then WriteLine("KING")
    If C = 14 Then WriteLine("ACE") : WriteLine()
    If C > A Then GoTo WinCheck
    GoTo Lose
WinCheck:
    If C >= B Then GoTo Lose
    WriteLine("YOU WIN!!!")
    GoTo IncreasePool
Lose:
    WriteLine("SORRY, YOU LOSE")
    If M < Q Then GoTo DecreasePool
    WriteLine() : WriteLine()
    WriteLine("SORRY, FRIEND, BUT YOU BLEW YOUR WAD.")
    WriteLine() : WriteLine()
    Write("TRY AGAIN (YES OR NO)? ") : Dim yesNo$ = ReadLine()
    WriteLine() : WriteLine()
    If yesNo$?.ToUpper = "YES" Then GoTo Start
    WriteLine("O.K., HOPE YOU HAD FUN!")

  End Sub

End Module

Now with an actual example to illustrate more of what I'm asking (wondering), what is the goal (or goals) related to conversions - most likely a very specific set of question(s) for VB as there are a lot of things VB is capable of doing that still harkens back to the early days of MBASIC?

Thanks.

(Also, if there are any errors in this posted example - please understand that I threw this together in about 20 minutes.)

DualBrain avatar Jul 14 '22 01:07 DualBrain