From c347d6a1ef6c47cb0f7575bfbe31c2e6bc39bc92 Mon Sep 17 00:00:00 2001 From: JoeStrout Date: Wed, 13 Sep 2023 15:56:08 -0700 Subject: [PATCH] Added MiniScript version of 61_Math_Dice. --- .../61_Math_Dice/MiniScript/README.md | 21 +++++++ .../61_Math_Dice/MiniScript/mathdice.ms | 58 +++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 00_Alternate_Languages/61_Math_Dice/MiniScript/README.md create mode 100644 00_Alternate_Languages/61_Math_Dice/MiniScript/mathdice.ms diff --git a/00_Alternate_Languages/61_Math_Dice/MiniScript/README.md b/00_Alternate_Languages/61_Math_Dice/MiniScript/README.md new file mode 100644 index 00000000..ac7b913c --- /dev/null +++ b/00_Alternate_Languages/61_Math_Dice/MiniScript/README.md @@ -0,0 +1,21 @@ +Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html). + +Conversion to [MiniScript](https://miniscript.org). + +Ways to play: + +0. Try-It! Page: +Go to https://miniscript.org/tryit/, clear the sample code from the code editor, and paste in the contents of mathdice.ms. Then click the "Run Script" button. Program output (and input) will appear in the green-on-black terminal display to the right of or below the code editor. + +1. Command-Line MiniScript: +Download for your system from https://miniscript.org/cmdline/, install, and then run the program with a command such as: +``` + miniscript mathdice.ms +``` + +2. Mini Micro: +Download Mini Micro from https://miniscript.org/MiniMicro/, launch, and then click the top disk slot and chose "Mount Folder..." Select the folder containing the MiniScript program and this README file. Then, at the Mini Micro command prompt, enter: +``` + load "mathdice" + run +``` \ No newline at end of file diff --git a/00_Alternate_Languages/61_Math_Dice/MiniScript/mathdice.ms b/00_Alternate_Languages/61_Math_Dice/MiniScript/mathdice.ms new file mode 100644 index 00000000..74ed6349 --- /dev/null +++ b/00_Alternate_Languages/61_Math_Dice/MiniScript/mathdice.ms @@ -0,0 +1,58 @@ +print " "*31 + "Math Dice" +print " "*15 + "Creative Computing Morristown, New Jersey" +print; print; print +print "This program generates successive pictures of two dice." +print "When two dice and an equal sign followed by a question" +print "mark have been printed, type your answer and the return key." +print "To conclude the lesson, type Control-C as your answer." +print + +printDie = function(d) + print + print " -----" + if d == 1 then + print "| |" + else if d == 2 or d == 3 then + print "| * |" + else + print "| * * |" + end if + if d == 2 or d == 4 then + print "| |" + else if d == 6 then + print "| * * |" + else + print "| * |" + end if + if d == 1 then + print "| |" + else if d == 2 or d == 3 then + print "| * |" + else + print "| * * |" + end if + print " -----" + print +end function + +while true + d1 = floor(6 * rnd + 1) + printDie d1 + print " +" + d2 = floor(6 * rnd + 1) + printDie d2 + total = d1 + d2 + answer = input(" =? ").val + if answer != total then + print "No, count the spots and give another answer." + answer = input(" =? ").val + end if + if answer == total then + print "Right!" + else + print "No, the answer is " + total + end if + print + print "The dice roll again..." +end while +