question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.)

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
AnthonyMichaelTDMcommented, Nov 11, 2022

I’d just make a pull request for that

1reaction
coding-horrorcommented, Oct 12, 2022

I would say we want the project to reflect modern coding practices, so essentially convert the gotos to subroutines would be preferable versus a “straight” port.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The spirit of project management
Many buildings were used to worship a God or higher power and used glorious images to assist that process. As human beings evolved...
Read more >
8. The Spirit and the Fruit - Tim Mackie (The Bible Project)
I wish there was a church and a pastor with such deep insight and beautiful way of teaching as Tim has. He has...
Read more >
11. The Spirit and the Temple - Tim Mackie (The Bible Project)
REDISCOVERING GOD AS FATHER-SON- SPIRIT. ... and the Temple - I Am Who I Am - Tim Mackie (The Bible Project ). 51K...
Read more >
12. Born of the Spirit - I Am Who I Am - Tim Mackie ... - YouTube
REDISCOVERING GOD AS FATHER-SON- SPIRIT. ... of the Spirit - I Am Who I Am - Tim Mackie (The Bible Project ). 84K...
Read more >
All Things New [Ephesians] Tim Mackie (The Bible Project)
5. Be Filled With The Spirit - All Things New [Ephesians] Tim Mackie (The Bible Project ). 133K views · 5 years ago...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found