diff --git a/00_Alternate_Languages/62_Mugwump/MiniScript/README.md b/00_Alternate_Languages/62_Mugwump/MiniScript/README.md new file mode 100644 index 00000000..ac7b913c --- /dev/null +++ b/00_Alternate_Languages/62_Mugwump/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/62_Mugwump/MiniScript/mugwump.ms b/00_Alternate_Languages/62_Mugwump/MiniScript/mugwump.ms new file mode 100644 index 00000000..8ba5f7fb --- /dev/null +++ b/00_Alternate_Languages/62_Mugwump/MiniScript/mugwump.ms @@ -0,0 +1,65 @@ +print " "*33 + "Mugwump" +print " "*15 + "Creative Computing Morristown, New Jersey" +print; print; print +// Courtesy People's Computer Company +print "The object of this game is to find four mugwumps" +print "hidden on a 10 by 10 grid. Homebase is position 0,0." +print "Any guess you make must be two numbers with each" +print "number between 0 and 9, inclusive. First number" +print "is distance to right of homebase and second number" +print "is distance above homebase." +print +print "You get 10 tries. After each try, I will tell" +print "you how far you are from each mugwump." +print + +playOneGame = function + mugwump = {} // key: number 1-4; value: [x,y] position + for i in range(1, 4) + mugwump[i] = [floor(10*rnd), floor(10*rnd)] + end for + + found = 0 + for turn in range(1, 10) + print + print + while true + inp = input("Turn no. " + turn + " -- what is your guess? ") + inp = inp.replace(",", " ").replace(" ", " ").split + if inp.len == 2 then break + end while + x = inp[0].val; y = inp[1].val + for i in range(1, 4) + pos = mugwump[i] + if pos == null then continue // (already found) + if pos == [x,y] then + print "You have found mugwump " + i + mugwump[i] = null + found += 1 + else + d = sqrt( (pos[0] - x)^2 + (pos[1] - y)^2 ) + print "You are " + round(d, 1) + " units from mugwump " + i + end if + end for + if found == 4 then + print + print "You got them all in " + turn + " turns!" + return + end if + end for + print + print "Sorry, that's 10 tries. Here is where they're hiding:" + for i in range(1, 4) + pos = mugwump[i] + if pos == null then continue + print "Mugwump " + i + " is at (" + pos[0] + "," + pos[1] + ")" + end for +end function + +// Main loop +while true + playOneGame + print + print "That was fun! Let's play again......." + print "Four more mugwumps are now in hiding." +end while