diff --git a/00_Alternate_Languages/50_Horserace/MiniScript/README.md b/00_Alternate_Languages/50_Horserace/MiniScript/README.md new file mode 100644 index 00000000..c9a5cd1f --- /dev/null +++ b/00_Alternate_Languages/50_Horserace/MiniScript/README.md @@ -0,0 +1,23 @@ +Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html). + +Conversion to [MiniScript](https://miniscript.org). + +Ways to play: + +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 horserace.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 "horserace" + run + + +## Porting Notes + +- The original program, designed to be played directly on a printer, drew a track 27 rows long. To fit better on modern screens, I've shortened the track to 23 rows. This is adjustable via the "trackLen" value assigned on line 72. + +- Also because we're playing on a screen instead of a printer, I'm clearing the screen and pausing briefly before each new update of the track. This is done via the `clear` API when running in Mini Micro, or by using a VT100 escape sequence in other contexts. diff --git a/00_Alternate_Languages/50_Horserace/MiniScript/horserace.ms b/00_Alternate_Languages/50_Horserace/MiniScript/horserace.ms new file mode 100644 index 00000000..a8750f5e --- /dev/null +++ b/00_Alternate_Languages/50_Horserace/MiniScript/horserace.ms @@ -0,0 +1,149 @@ +print " "*31 + "Horserace" +print " "*15 + "Creative Computing Morristown, New Jersey" +print; print; print + +print "Welcome to South Portland High Racetrack" +print " ...owned by Laurie Chevalier" + +// show directions, if wanted +x = input("Do you want directions? ").lower +if not x or x[0] != "n" then + print "Up to 10 may play. A table of odds will be printed. You" + print "may bet any + amount under 100000 on one horse." + print "During the race, a horse will be shown by its" + print "number. The horses race down the paper!" + print +end if + +// get player names +qtyPlayers = input("How many want to bet? ").val +if qtyPlayers < 1 then exit +print "When ? appears, type name" +playerNames = [null] +for i in range(1, qtyPlayers) + playerNames.push input("?") +end for +print +pick = [null] + [0]*qtyPlayers +bet = [null] + [0]*qtyPlayers + +d = [0] * 9 // odds denominator +r = 0 // odds numerator + +printInColumns = function(col0, col1, col2) + print (col0+" "*16)[16] + (col1+" "*10)[:10] + (col2+" "*10)[:10] +end function + +setup = function + // initialize the horses + globals.names = [null] + + "Joe Maw,L.B.J.,Mr.Washburn,Miss Karen,Jolly,Horse,Jelly Do Not,Midnight".split(",") + for i in range(1,8) + d[i] = floor(10*rnd+1) + end for + globals.r = d.sum + + // print odds table + printInColumns "Horse", "Number", "Odds" + for i in range(1,8) + printInColumns names[i], i, round(r/d[i],2) + ":1" + end for + + // get the players' bets + print "--------------------------------------------------" + print "Place your bets...Horse # then Amount" + for j in range(1, qtyPlayers) + while true + s = input(playerNames[j] + "? ").replace(",", " ").split + if s.len < 2 then s.push -1 + pick[j] = s[0].val + bet[j] = s[-1].val + if pick[j] < 1 or pick[j] > 8 or bet[j] < 1 or bet[j] >=100000 then + print "You can't do that!" + else + break + end if + end while + end for +end function + +// Draw a racetrack, with each horse the given number +// of lines down from START to FINISH. +trackLen = 23 +drawTrack = function(horsePositions) + print + if version.hostName == "Mini Micro" then clear else print char(27)+"c" + if horsePositions[1] == 0 then print "1 2 3 4 5 6 7 8" else print + print "XXXXSTARTXXXX" + for row in range(1, trackLen) + for h in range(1,8) + p = horsePositions[h] + if p > trackLen then p = trackLen + if p == row then print h, " " + end for + print + end for + print "XXXXFINISHXXXX", "" + if version.hostName != "Mini Micro" then print +end function + +runRace = function + pos = [0]*9 + maxPos = 0 + while true + drawTrack pos + wait 1 + if maxPos >= trackLen then break + for i in range(1,8) + q = floor(100*rnd+1) + x = floor(r/d[i]+0.5) + if q < 10 then + speed = 1 + else if q < x+17 then + speed = 2 + else if q < x+37 then + speed = 3 + else if q < x+57 then + speed = 4 + else if q < x+77 then + speed = 5 + else if q < x+92 then + speed = 6 + else + speed = 7 + end if + pos[i] += speed + if pos[i] > maxPos then maxPos = pos[i] + end for + end while + + print + print "---------------------------------------------" + print + print "The race results are:" + results = [] + for i in range(1,8) + results.push {"num":i, "pos":pos[i]} + end for + results.sort "pos", false + for place in range(1, 8) + h = results[place-1].num + print " " + place + " Place Horse No. " + h + " at " + round(r/d[h],2) + ":1" + print + end for + for p in range(1, qtyPlayers) + if pick[p] == results[0].num then + print playerNames[p] + " wins $" + round((r/d[pick[p]])*bet[p], 2) + end if + end for +end function + +// Main loop +while true + setup + runRace + print "Do you want to bet on the next race ?" + yn = input("Yes or no? ").lower + if not yn or yn[0] != "y" then break +end while + diff --git a/00_Alternate_Languages/51_Hurkle/MiniScript/README.md b/00_Alternate_Languages/51_Hurkle/MiniScript/README.md new file mode 100644 index 00000000..0f4ff6a6 --- /dev/null +++ b/00_Alternate_Languages/51_Hurkle/MiniScript/README.md @@ -0,0 +1,19 @@ +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 hurkle.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 hurkle.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 "hurkle" + run diff --git a/00_Alternate_Languages/51_Hurkle/MiniScript/hurkle.ms b/00_Alternate_Languages/51_Hurkle/MiniScript/hurkle.ms new file mode 100644 index 00000000..a1b22822 --- /dev/null +++ b/00_Alternate_Languages/51_Hurkle/MiniScript/hurkle.ms @@ -0,0 +1,56 @@ +print " "*33 + "Hurcle" +print " "*15 + "Creative Computing Morristown, New Jersey" +print; print; print +n = 5 // number of guesses allowed +g = 10 // grid size +print +print "A hurkle is hiding on a " + g + " by " + g + " grid. Homebase" +print "on the grid is point 0,0 in the southwest corner," +print "and any point on the grid is designated by a" +print "pair of whole numbers seperated by a comma. The first" +print "number is the horizontal position and the second number" +print "is the vertical position. You must try to" +print "guess the hurkle's gridpoint. You get " + n + "tries." +print "After each try, I will tell you the approximate" +print "direction to go to look for the hurkle." +print + +playOneGame = function + a = floor(g*rnd) + b = floor(g*rnd) + for k in range(1, n) + s = input("Guess #" + k + "? ").replace(",", " ").split + x = s[0].val + y = s[-1].val + if x == a and y == b then + print + print "You found him in " + k + " guesses!" + return + end if + if y == b then + if x == a then + print + print "You found him in " + k + " guesses!" + return + else if x < a then + dir = "east" + else + dir = "west" + end if + else if y < b then + dir = "north" + else + dir = "south" + end if + print "Go " + dir + end for + print "Sorry, that's " + n + " guesses." + print "The hurkle is at " + a + "," + b +end function + +while true + playOneGame + print + print "Let's play again, hurkle is hiding." + print +end while