Message Boards Message Boards

Translate a Commodore 64 game to Wolfram Language?

Posted 5 years ago

What is wrong with my code? I am translating a Commodore 64 game to Mathematica, programmed in C64 basic.

(* Important initial information*)
dollars = 500
Print["With whom do I have the pleasure " 
  " of playing High Card Slice? "
  Input[name$
    Print["High Card wins this game! "
      Dimension [suit$ (4)], card$[14], : Read card$ (i) : Nexti
      (*                                 *)

image

POSTED BY: Leighton Cooper
Posted 5 years ago

Hi Leighton,

A line-by-line transliteration from Basic to WL is not the best approach. Try to translate concepts and functionality, not lines of code.

To generate a deck of cards:

ranks = {2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A};
suits = {\[DiamondSuit], \[ClubSuit], \[HeartSuit], \[SpadeSuit]};
deck = Tuples[{ranks, suits}]

enter image description here

Pick a card at random

RandomChoice@deck
(* {K, \[DiamondSuit]} *)

Hope that helps.

POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract