diff --git a/00_Alternate_Languages/60_Mastermind/MiniScript/README.md b/00_Alternate_Languages/60_Mastermind/MiniScript/README.md new file mode 100644 index 000000000..088a33011 --- /dev/null +++ b/00_Alternate_Languages/60_Mastermind/MiniScript/README.md @@ -0,0 +1,17 @@ +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 mastermind.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 "mastermind" + run +``` \ No newline at end of file diff --git a/00_Alternate_Languages/60_Mastermind/MiniScript/mastermind.ms b/00_Alternate_Languages/60_Mastermind/MiniScript/mastermind.ms new file mode 100644 index 000000000..93ea30820 --- /dev/null +++ b/00_Alternate_Languages/60_Mastermind/MiniScript/mastermind.ms @@ -0,0 +1,260 @@ +// +// MASTERMIND II +// STEVE NORTH +// CREATIVE COMPUTING +// PO BOX 789-M MORRISTOWN NEW JERSEY 07960 +// +// Converted to MiniScript by Joe Strout (Sep 2023) + +// Advance the given combination to the next possible combination. +// Note that (unlike the BASIC program) our values are 0-based, not 1-based. +incrementCombo = function(combo) + idx = 0 + while true + combo[idx] += 1 + if combo[idx] < colorCount then return + combo[idx] = 0 + idx += 1 + end while +end function + +// Convert a numeric combination like [2, 0, 1] into a color string like "RBW". +comboToColorString = function(combo) + result = "" + for q in combo + result += colorCodes[q] + end for + return result +end function + +// Get a random color code like "RBW". +getRandomCode = function + // We do this by starting with a numeric combo of all 0's (first color), + // and then stepping through subsequent combos a random number of times. + combo = [0] * posCount + steps = floor(possibilities * rnd) + while steps + incrementCombo combo + steps -= 1 + end while + return comboToColorString(combo) +end function + +// Return [blackPins, whitePins] for the given guess and actual code. +// blackPins is how many guess entries are the correct color AND position; +// whitePins is how many guess entries have the right color, but wrong position. +// This works with either color strings or numeric combos. +calcResult = function(guess, actual) + if guess isa string then guess = guess.split("") else guess = guess[:] + if actual isa string then actual = actual.split("") else actual = actual[:] + black = 0; white = 0 + for i in guess.indexes + if guess[i] == actual[i] then + black += 1 + actual[i] = null + else + for j in actual.indexes + if guess[i] == actual[j] and guess[j] != actual[j] then + white += 1 + actual[j] = null + break + end if + end for + end if + guess[i] = null + end for + return [black, white] +end function + +// Pad a string with spaces, to the given width. +pad = function(s, width=12) + return (s + " "*width)[:width] +end function + +// Print the history of guesses and results. +printBoard = function + print + print "BOARD" + print "Move Guess Black White" + for i in guessHistory.indexes + print pad(i+1, 9) + pad(guessHistory[i], 15) + + pad(guessResult[i][0], 10) + guessResult[i][1] + end for + print +end function + +// Quit the game (after reporting the computer's secret code). +quit = function(computerCode) + print "Quitter! My combination was: " + computerCode + print + print "Good bye" + exit +end function + +// Prompt the user for a guess (e.g. "RBW"). +// Also handle "BOARD" and "QUIT" commands. +inputGuess = function(guessNum, secretCode) + while true + guess = input("Move #" + guessNum + " Guess? ").upper + if guess == "BOARD" then + printBoard + else if guess == "QUIT" then + quit secretCode + else if guess.len != posCount then + print "Bad number of positions." + else + ok = true + for c in guess + if colorCodes.indexOf(c) == null then + print "'" + c + "' is unrecognized." + ok = false + break + end if + end for + if ok then return guess + end if + end while +end function + +// Play one half-round where the computer picks a code, +// and the human tries to guess it. +doHumanGuesses = function + print "Guess my combination." + print + secretCode = getRandomCode + //print "My secret combo is: " + secretCode // (for debugging purposes) + + globals.guessHistory = [] // list of guesses, e.g. "RBW" + globals.guessResult = [] // result of each guess, as [BlackPins, WhitePins] + + for guessNum in range(1, 10) + guess = inputGuess(guessNum, secretCode) + result = calcResult(guess, secretCode) + if result[0] == posCount then + print "You guessed it in " + guessNum + " moves!" + break + end if + // Tell human results + print "You have " + result[0] + " blacks and " + result[1] + " whites." + // Save all this stuff for board printout later + guessHistory.push guess + guessResult.push result + end for + if guess != secretCode then + print "You ran out of moves! That's all you get!" + print "The actual combination was: " + secretCode + end if + globals.humanScore += guessNum +end function + +// Play one half-round where the human picks a code, +// and the computer tries to guess it. +// Return true if this goes OK, and false if we need a do-over. +doComputerGuesses = function + print "Now I guess. Think of a combination." + input "Hit Return when ready:" + + // Make a list of possible combination *numbers*, from 0 to possibilities-1. + // We'll remove entries from this list as we eliminate them with our guesses. + possible = range(0, possibilities-1) + + gotIt = false + for guessNum in range(1, 10) + if not possible then + print "You have given me inconsistent information." + print "Try again, and this time please be more careful." + return false + end if + guessIdx = possible[rnd * possible.len] + guessCombo = [0] * posCount + if guessIdx > 0 then + for x in range(0, guessIdx-1) + incrementCombo guessCombo + end for + end if + + print "My guess is: " + comboToColorString(guessCombo) + + while true + s = input(" Blacks, Whites? ").replace(",", " ").replace(" ", " ").split + if s.len == 2 then break + end while + actualResult = [s[0].val, s[1].val] + + if actualResult[0] == posCount then + print "I got it in " + guessNum + " moves!" + gotIt = true + break + end if + + // Now zip through all possibilities, and if it's still in our + // possible list but doesn't match the given result, remove it. + combo = [0] * posCount + for x in range(0, possibilities-1) + if x > 0 then incrementCombo combo + idx = possible.indexOf(x) + if idx == null then continue // (already eliminated) + result = calcResult(combo, guessCombo) + if result != actualResult then + //print "Eliminating #" + x + ", " + comboToColorString(combo) + possible.remove idx + end if + end for + end for + + if not gotIt then + print "I used up all my moves!" + print "I guess my CPU is just having an off day." + end if + globals.computerScore += guessNum + return true +end function + +// Show the score (with the given header). +showScore = function(header="Score") + print header + ":" + print " COMPUTER " + computerScore + print " HUMAN " + humanScore + print +end function + +// Initialization of global variables +colorCodes = "BWRGOYPT" +colorNames = "Black,White,Red,Green,Orange,Yellow,Purple,Tan".split(",") +computerScore = 0 +humanScore = 0 + +// Main program +print " "*30 + "Mastermind" +print " "*15 + "Creative Computing Morristown, New Jersey" +print; print; print +while true + colorCount = input("Number of colors? ").val + if 0 < colorCount <= 8 then break + print "No more than 8, please!" +end while +posCount = input("Number of positions? ").val +roundCount = input("Number of rounds? ").val +possibilities = colorCount ^ posCount +print "Total possibilities = " + possibilities + +print; print +print "Color Letter" +print "===== ======" +for x in range(0, colorCount-1) + print pad(colorNames[x], 9) + colorCodes[x] +end for +print + +for round in range(1, roundCount) + print + print "Round number " + round + " ----" + print + doHumanGuesses + showScore + while not doComputerGuesses; end while + showScore +end for + +print "GAME OVER" +showScore "Final score" 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 000000000..ac7b913c2 --- /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 000000000..74ed63496 --- /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 + 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 000000000..ac7b913c2 --- /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 000000000..8ba5f7fb2 --- /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 diff --git a/00_Alternate_Languages/63_Name/MiniScript/README.md b/00_Alternate_Languages/63_Name/MiniScript/README.md new file mode 100644 index 000000000..819ecf501 --- /dev/null +++ b/00_Alternate_Languages/63_Name/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 name.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 name.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 "name" + run +``` \ No newline at end of file diff --git a/00_Alternate_Languages/63_Name/MiniScript/name.ms b/00_Alternate_Languages/63_Name/MiniScript/name.ms new file mode 100644 index 000000000..bb3d2da23 --- /dev/null +++ b/00_Alternate_Languages/63_Name/MiniScript/name.ms @@ -0,0 +1,25 @@ +print " "*34 + "Name" +print " "*15 + "Creative Computing Morristown, New Jersey" +print; print; print +print "Hello."; print "My name is Creative Computer." +name = input("What's your name (first and last)? ") + +s = "" +for i in range(name.len - 1) + s += name[i] +end for +print; print "Thank you, " + s + "." +print "Oops! I guess I got it backwards. A smart" +print "computer like me shouldn't make a mistake like that!"; print +print "But i just noticed your letters are out of order." +s = name.split("").sort.join("") +print "Let's put them in order like this: " + s +yn = input("Don't you like that better? ").lower +print +if yn and yn[0] == "y" then + print "I knew you'd agree!!" +else + print "I'm sorry you don't like it that way." +end if +print; print "I really enjoyed meeting you " + name + "." +print "Have a nice day!" diff --git a/00_Alternate_Languages/65_Nim/MiniScript/README.md b/00_Alternate_Languages/65_Nim/MiniScript/README.md new file mode 100644 index 000000000..0265ff51f --- /dev/null +++ b/00_Alternate_Languages/65_Nim/MiniScript/README.md @@ -0,0 +1,18 @@ +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 nim.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 "nim" + run +``` \ No newline at end of file diff --git a/00_Alternate_Languages/65_Nim/MiniScript/nim.ms b/00_Alternate_Languages/65_Nim/MiniScript/nim.ms new file mode 100644 index 000000000..f241c6964 --- /dev/null +++ b/00_Alternate_Languages/65_Nim/MiniScript/nim.ms @@ -0,0 +1,194 @@ +print " "*33 + "Nim" +print " "*15 + "Creative Computing Morristown, New Jersey" +print; print; print + +askYesNo = function(prompt) + while true + answer = input(prompt + "? ").lower + if answer and answer[0] == "y" then return "yes" + if answer and answer[0] == "n" then return "no" + print "Please answer yes or no." + end while +end function + +print "This is the game of Nim." +if askYesNo("Do you want instructions") == "yes" then + print "The game is played with a number of piles of objects." + print "Any number of objects are removed from one pile by you and" + print "the machine alternately. On your turn, you may take" + print "all the objects that remain in any pile, but you must" + print "take at least one object, and you may take objects from" + print "only one pile on a single turn. You must specify whether" + print "winning is defined as taking or not taking the last object," + print "the number of piles in the game, and how many objects are" + print "originally in each pile. Each pile may contain a" + print "different number of objects." + print "The machine will show its move by listing each pile and the" + print "number of objects remaining in the piles after each of its" + print "moves." +end if + +allEmpty = function(piles) + for i in range(1, piles.len-1) + if piles[i] then return false + end for + return true +end function + +// Do the computer's turn; return true if game over, false otherwise. +doComputerTurn = function(pile, winCondition) + n = pile.len - 1 + d = [0,0,0] + b = [null] + for i in range(1, n) + b.push [0]*11 + end for + + if winCondition == 2 then + c = 0 + broke = false + for i in range(1, n) + if pile[i] == 0 then continue + c += 1 + if c == 3 then; broke = true; break; end if + d[c] = i + end for + if not broke then + if c == 2 and (pile[d[1]] == 1 or pile[d[2]] == 1) then + print "Machine wins" + return true + end if + if pile[d[1]] > 1 then + print "Machine wins" + return true + end if + print "Machine loses" + return true + end if + c = 0 + broke = false + for i in range(1, n) + if pile[i] > 1 then; broke = true; break; end if + if pile[i] == 0 then continue + c += 1 + end for + if not broke and c/2 != floor(c/2) then + print "Machine loses" + return true + end if + end if + + for i in range(1, n) + e = pile[i] + for j in range(0, 10) + f = e/2 + b[i][j] = 2*(f-floor(f)) + e = floor(f) + end for + end for + broke = false + for j in range(10, 0) + c = 0 + h = 0 + for i in range(1, n) + if b[i][j] == 0 then continue + c += 1 + if pile[i] <= h then continue + h = pile[i] + g = i + end for + if c/2 != floor(c/2) then; broke = true; break; end if + end for + if not broke then + while true + e = floor(n*rnd+1) + if pile[e] != 0 then break + end while + f = floor(pile[e]*rnd+1) + pile[e] -= f + else + pile[g] = 0 + for j in range(0, 10) + b[g][j] = 0 + c=0 + for i in range(1,n) + if b[i][j] == 0 then continue + c += 1 + end for + pile[g] += 2*(c/2-floor(c/2))*2^j + end for + if winCondition != 1 then + c = 0 + broke = false + for i in range(1, n) + if pile[i]>1 then; broke = true; break; end if + if pile[i] == 0 then continue + c += 1 + end for + if not broke and c/2 == floor(c/2) then pile[g]= 1 - pile[g] + end if + end if + + print "Pile Size" + for i in range(1, n) + print i + " " + pile[i] + end for + if winCondition == 1 and allEmpty(pile) then + print "Machine wins" + return true + end if + return false +end function + +// Do the human player's turn; return true if game over, false otherwise. +doPlayerTurn = function(pile, winCondition) + n = pile.len - 1 + while true + inp = input("Your move - pile, number to be removed? ") + inp = inp.replace(",", " ").replace(" ", " ").split + if inp.len != 2 then continue + x = inp[0].val; y = inp[1].val + if x == floor(x) and y == floor(y) and 1 <= x <= n and 1 <= y <= pile[x] then break + end while + + pile[x] -= y + if allEmpty(pile) then + if winCondition == 1 then print "Machine loses" else print "Machine wins" + return true + end if + return false +end function + +playOneGame = function + print + while true + w = input("Enter win option - 1 to take last, 2 to avoid last? ").val + if w == 1 or w == 2 then break + end while + while true + n = input("Enter number of piles? ").val + if n == floor(n) and 1 <= n <= 100 then break + end while + + print "Enter pile sizes" + pile = [null] + [0]*n // (null at element 0 to make our array 1-based) + for i in range(1, n) + while true + pile[i] = input(i + "? ").val + if pile[i] == floor(pile[i]) and 1 <= pile[i] <= 2000 then break + end while + end for + + if askYesNo("Do you want to move first") == "yes" then + if doPlayerTurn(pile, w) then return + end if + while true + if doComputerTurn(pile, w) then return + if doPlayerTurn(pile, w) then return + end while +end function + +while true + playOneGame + if askYesNo("Do you want to play another game") == "no" then break +end while diff --git a/00_Alternate_Languages/67_One_Check/MiniScript/README.md b/00_Alternate_Languages/67_One_Check/MiniScript/README.md new file mode 100644 index 000000000..d79b401fb --- /dev/null +++ b/00_Alternate_Languages/67_One_Check/MiniScript/README.md @@ -0,0 +1,18 @@ +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 onecheck.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 "onecheck" + run +``` \ No newline at end of file diff --git a/00_Alternate_Languages/67_One_Check/MiniScript/onecheck.ms b/00_Alternate_Languages/67_One_Check/MiniScript/onecheck.ms new file mode 100644 index 000000000..fee41c8c4 --- /dev/null +++ b/00_Alternate_Languages/67_One_Check/MiniScript/onecheck.ms @@ -0,0 +1,101 @@ +print "Solitaire Checker Puzzle by David Ahl" +print +print "48 checkers are placed on the 2 outside spaces of a" +print "standard 64-square checkerboard. The object is to" +print "remove as many checkers as possible by diagonal jumps" +print "(as in standard checkers). Use the numbered board to" +print "indicate the square you wish to jump from and to. On" +print "the board printed out on each turn '1' indicates a" +print "checker and '0' an empty square. When you have no" +print "possible jumps remaining, input a '0' in response to" +print "question 'Jump from?'" +print +input "(Press Return.)" +print + +pad4 = function(n) + return (" " + n)[-4:] +end function + +printBoard = function + // Idea: This program could be greatly improved by printing the board + // as the index numbers (1-64), indicating which of those positions + // contain checkers via color or punctuation, e.g. "(42)" vs " 42 ". + // This would make it much easier for the user to figure out what + // numbers correspond to the positions they have in mind. + print + for j in range(1, 57, 8) + print " " + board[j:j+8].join(" ") + end for +end function + +initBoard = function + globals.board = [null] + [1] * 64 // treat this as 1-based array + for j in range(19, 43, 8) + for i in range(j, j+3) + board[i] = 0 + end for + end for +end function + +isLegal = function(from, to) + if board[from] == 0 then return false + if board[to] == 1 then return false + if board[(to+from)/2] == 0 then return false + fromRow = floor((from-1) / 8) // row in range 0-7 + fromCol = from - fromRow*8 // column in range 1-8 + toRow = floor((to-1) / 8) + toCol = to - toRow*8 + if fromRow > 7 or toRow > 7 or fromCol > 8 or toCol > 8 then return false + if abs(fromRow-toRow) != 2 or abs(fromCol-toCol) != 2 then return false + return true +end function + +askYesNo = function(prompt) + while true + answer = input(prompt + "? ").lower + if answer and answer[0] == "y" then return "yes" + if answer and answer[0] == "n" then return "no" + print "Please answer 'yes' or 'no'." + end while +end function + +print "Here is the numerical board:" +print +for j in range(1, 57, 8) + print pad4(j) + pad4(j+1) + pad4(j+2) + pad4(j+3) + + pad4(j+4) + pad4(j+5) + pad4(j+6) + pad4(j+7) +end for + +while true + initBoard + print + print "And here is the opening position of the checkers." + printBoard + jumps = 0 + while true + fromPos = input("Jump from? ").val + if fromPos == 0 then break + toPos = input("To? ").val + print + if not isLegal(fromPos, toPos) then + print "Illegal move. Try again..." + continue + end if + board[fromPos] = 0 + board[toPos] = 1 + board[(toPos+fromPos)/2] = 0 + jumps += 1 + printBoard + end while + // End game summary + sum = board[1:].sum + print "You made " + jumps + " jumps and had " + sum + " pieces" + print "remaining on the board." + print + if askYesNo("Try again") == "no" then break +end while +print +print "O.K. Hope you had fun!!" + + \ No newline at end of file diff --git a/00_Alternate_Languages/68_Orbit/MiniScript/README.md b/00_Alternate_Languages/68_Orbit/MiniScript/README.md new file mode 100644 index 000000000..cc0c29669 --- /dev/null +++ b/00_Alternate_Languages/68_Orbit/MiniScript/README.md @@ -0,0 +1,18 @@ +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 orbit.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 "orbit" + run +``` \ No newline at end of file diff --git a/00_Alternate_Languages/68_Orbit/MiniScript/orbit.ms b/00_Alternate_Languages/68_Orbit/MiniScript/orbit.ms new file mode 100644 index 000000000..5c624c42b --- /dev/null +++ b/00_Alternate_Languages/68_Orbit/MiniScript/orbit.ms @@ -0,0 +1,95 @@ +print " "*33 + "Orbit" +print " "*15 + "Creative Computing Morristown, New Jersey" +print; print; print +print "Somewhere above your planet is a Romulan ship." +print +print "The ship is in a constant polar orbit. Its" +print "distance from the center of your planet is from" +print "10,000 to 30,000 miles and at its present velocity can" +print "circle your planet once every 12 to 36 hours." +print +print "Unfortunately, they are using a cloaking device so" +print "you are unable to see them, but with a special" +print "instrument you can tell how near their ship your" +print "photon bomb exploded. You have seven hours until they" +print "have built up sufficient power in order to escape" +print "your planet's gravity." +print +print "Your planet has enough power to fire one bomb an hour." +print +print "At the beginning of each hour you will be asked to give an" +print "angle (between 0 and 360) and a distance in units of" +print "100 miles (between 100 and 300), after which your bomb's" +print "distance from the enemy ship will be given." +print +print "An explosion within 5,000 miles of the romulan ship" +print "will destroy it." +print; input "(Press Return.)" +print +print "Below is a diagram to help you visualize your plight." +print +print +print " 90" +print " 0000000000000" +print " 0000000000000000000" +print " 000000 000000" +print " 00000 00000" +print " 00000 xxxxxxxxxxx 00000" +print " 00000 xxxxxxxxxxxxx 00000" +print " 0000 xxxxxxxxxxxxxxx 0000" +print " 0000 xxxxxxxxxxxxxxxxx 0000" +print " 0000 xxxxxxxxxxxxxxxxxxx 0000" +print "180<== 00000 xxxxxxxxxxxxxxxxxxx 00000 ==>0" +print " 0000 xxxxxxxxxxxxxxxxxxx 0000" +print " 0000 xxxxxxxxxxxxxxxxx 0000" +print " 0000 xxxxxxxxxxxxxxx 0000" +print " 00000 xxxxxxxxxxxxx 00000" +print " 00000 xxxxxxxxxxx 00000" +print " 00000 00000" +print " 000000 000000" +print " 0000000000000000000" +print " 0000000000000" +print " 270" +print +print "x - your planet" +print "o - the orbit of the romulan ship" +print; input "(Press Return.)" +print +print "On the above diagram, the romulan ship is circling" +print "counterclockwise around your planet. Don't forget that" +print "without sufficient power the romulan ship's altitude" +print "and orbital rate will remain constant." +print +print "Good luck. The federation is counting on you." + +while true + a=floor(360*rnd) + d=floor(200*rnd + 200) + r=floor(20*rnd + 10) + for h in range(1,7) + print + print + print "This is hour " + h + ", at what angle do you wish to send" + a1 = input("your photon bomb? ").val + d1 = input("How far out do you wish to detonate it? ").val + print + print + a += r + if a >= 360 then a -= 360 + t = abs(a-a1) + if t >= 180 then t = 360 - t + c = sqrt(d*d + d1*d1 - 2*d*d1*cos(t*pi/180)) + print "Your photon bomb exploded " + round(c) + " * 10^2 miles from the" + print "Romulan ship." + if c<=50 then break + end for + if c <= 50 then + print "You have succesfully completed your mission." + else + print "You have allowed the Romulans to escape." + end if + print "Another romulan ship has gone into orbit." + yn = input("Do you wish to try to destroy it? ").lower + " " + if yn[0] != "y" then break +end while +print "good bye." diff --git a/00_Alternate_Languages/73_Reverse/MiniScript/README.md b/00_Alternate_Languages/73_Reverse/MiniScript/README.md new file mode 100644 index 000000000..18812f302 --- /dev/null +++ b/00_Alternate_Languages/73_Reverse/MiniScript/README.md @@ -0,0 +1,16 @@ +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 reverse.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 "reverse" + run diff --git a/00_Alternate_Languages/73_Reverse/MiniScript/reverse.ms b/00_Alternate_Languages/73_Reverse/MiniScript/reverse.ms new file mode 100644 index 000000000..a83d6b107 --- /dev/null +++ b/00_Alternate_Languages/73_Reverse/MiniScript/reverse.ms @@ -0,0 +1,71 @@ +num = 9 + +reverse = function(i) + if i == null then return i + ret = [] + for item in i + ret.insert(0,item) + end for + return ret +end function + +showRules = function + print + print "This is the game of 'Reverse'. To win, all you have" + print "to do is arrange a list of numbers (1 through " + num + ")" + print "in numerical order from left to right. To move, you" + print "tell me how many numbers (counting from the left) to" + print "reverse. For example, if the current list is:" + print; print "2 3 4 5 1 6 7 8 9" + print; print "and you reverse 4, the result will be:" + print; print "5 4 3 2 1 6 7 8 9" + print; print "Now if reverse 5, you win!" + print; print "1 2 3 4 5 6 7 8 9" + print + print "No doubt you will like this game, but" + print "if you want to quit, reverse 0 (zero)." + print + return +end function + +printState = function + print;print digits.join(" "); print +end function + +print " " * 32 + "REVERSE" +print " " * 15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY" +print; print; print +print "Reverse -- a game of skill" +print + +ans = input("Do you want the rules? ") +if ans != null and ans[0].lower == "y" then showRules + +while 1 + turns = 0 + digits = range(1, num) + digits.shuffle + print;print "Here we go ... the list is:" + while 1 + printState + amt = input("How many shall I reverse? ").val + if amt == null or amt == 0 then break + + if amt > num then + print "OOPS! Too many! I can reverse at most " + num + else + turns += 1 + digits = reverse(digits[:amt]) + digits[amt:] + end if + if digits == range(1,num) then + printState + print "You won it in " + turns + " moves!!" + break + end if + end while + print + ans = input("Try again (YES or NO)? ") + print + if ans == null or ans[0].lower == "n" then break +end while +print "O.K. Hope you had fun!!" \ No newline at end of file diff --git a/00_Alternate_Languages/82_Stars/MiniScript/README.md b/00_Alternate_Languages/82_Stars/MiniScript/README.md new file mode 100644 index 000000000..bcbbd39a6 --- /dev/null +++ b/00_Alternate_Languages/82_Stars/MiniScript/README.md @@ -0,0 +1,16 @@ +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 stars.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 "stars" + run \ No newline at end of file diff --git a/00_Alternate_Languages/82_Stars/MiniScript/stars.ms b/00_Alternate_Languages/82_Stars/MiniScript/stars.ms new file mode 100644 index 000000000..b42346220 --- /dev/null +++ b/00_Alternate_Languages/82_Stars/MiniScript/stars.ms @@ -0,0 +1,48 @@ +kMaxNum = 100 +kTries = 7 + +instructions = function + print "I am thinking of a whole number from 1 to " + kMaxNum + print "Try to guess my number. After you guess, I" + print "will output one or more stars (*). The more" + print "stars I type, the closer you are to my number." + print "One star (*) means far away, seven stars (*******)" + print "means really close! You get " + kTries + " guesses." + print +end function + +print " " * 34 + "STARS" +print " " * 15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY" +print; print; print + +ans = input("Do you want instructions? ").lower +if ans[0] == "y" then + instructions +end if + +while 1 + print + print "OK, I am thinking of a number, start guessing." + starNum = floor(rnd * kMaxNum) + 1 + try = 0 + while try < kTries + print + guess = input("Your guess: ").val + + if guess == starNum then + break + else + d = abs(guess - starNum) + print "*" * (7 - floor(log(d,2))) + end if + try += 1 + end while + + if try < kTries then + print "*" * 59 + print "You got it in " + (try + 1) + " guesses! Let's play again." + else + print "Sorry, that's " + try + " guesses. The number was " + starNum + end if + print +end while diff --git a/00_Alternate_Languages/85_Synonym/MiniScript/README.md b/00_Alternate_Languages/85_Synonym/MiniScript/README.md new file mode 100644 index 000000000..f887013c7 --- /dev/null +++ b/00_Alternate_Languages/85_Synonym/MiniScript/README.md @@ -0,0 +1,17 @@ +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 synonym.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 "synonym" + run +``` diff --git a/00_Alternate_Languages/85_Synonym/MiniScript/synonym.ms b/00_Alternate_Languages/85_Synonym/MiniScript/synonym.ms new file mode 100644 index 000000000..684482d25 --- /dev/null +++ b/00_Alternate_Languages/85_Synonym/MiniScript/synonym.ms @@ -0,0 +1,47 @@ +words = [["first", "start", "beginning", "onset", "initial"], +["similar", "alike", "same", "like", "resembling"], +["model", "pattern", "prototype", "standard", "criterion"], +["small", "insignificant", "little", "tiny", "minute"], +["stop", "halt", "stay", "arrest", "check", "standstill"], +["house", "dwelling", "residence", "domicile", "lodging", "habitation"], +["pit", "hole", "hollow", "well", "gulf", "chasm", "abyss"], +["push", "shove", "thrust", "prod","poke","butt", "press"], +["red", "rouge", "scarlet", "crimson", "flame", "ruby"], +["pain", "suffering", "hurt", "misery", "distress", "ache", "discomfort"]] + +words.shuffle + +responses = ["Right","Correct","Fine","Good!","Check"] + +print " " * 33 + "SYNONYM" +print " " * 15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY" +print; print; print +print "A synonym of a word means another word in the English" +print "language which has the same or very nearly the same meaning." +print "I choose a word -- you type a synonym." +print "If you can't think a synonym, type the word 'HELP'" +print "and I will tell you a synonym." +print + +for synonyms in words + word = synonyms[0] + synonyms = synonyms[1:] + responses.shuffle + + print + while 1 + guess = input(" What is a synonym of " + word + "? ").lower + if guess == "help" then + synonyms.shuffle + print "**** A synonym of " + word + " is " + synonyms[0] + "." + print + else if guess == word or synonyms.indexOf(guess) == null then + print " Try again." + else + print responses[0] + break + end if + end while +end for +print +print "Synonym drill completed." diff --git a/00_Alternate_Languages/86_Target/MiniScript/README.md b/00_Alternate_Languages/86_Target/MiniScript/README.md new file mode 100644 index 000000000..c06194764 --- /dev/null +++ b/00_Alternate_Languages/86_Target/MiniScript/README.md @@ -0,0 +1,17 @@ +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 target.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 "target" + run +``` diff --git a/00_Alternate_Languages/86_Target/MiniScript/target.ms b/00_Alternate_Languages/86_Target/MiniScript/target.ms new file mode 100644 index 000000000..125fe2ff5 --- /dev/null +++ b/00_Alternate_Languages/86_Target/MiniScript/target.ms @@ -0,0 +1,114 @@ +degToRad = function(n) + return n * pi / 180 +end function + +radToDeg = function(n) + return n * 180 / pi +end function + +roundDown = function(n, r) + return floor(n / r) * r +end function + +getCoord = function(distance, radX, radZ) + xc = sin(radZ)*cos(radX)*distance + yc = sin(radZ)*sin(radX)*distance + zc = cos(radZ)*distance + return [xc,yc,zc] +end function + +distanceBetween = function (d1,d2) + return ((d1[0]-d2[0])^2 + (d1[1]-d2[1])^2 + (d1[2]-d2[2])^2)^.5 +end function + +coordStr = function(coords) + return "X = " + round(coords[0]) + + " Y = " + round(coords[1]) + " Z = " + round(coords[2]) +end function + +print " " * 33 + "TARGET" +print " " * 15 + "Creative Computing Morristown, New Jersey" +print; print; print + +print "You are the weapons officer on the Starship Enterprise" +print "and this is a test to see how accurae a shot you" +print "are in a 3-dimensional range. You will be told" +print "the radian offset for the X and Z axes, the location" +print "of the target in 3-dimensional rectangular coordinates," +print "the approximate number of degrees from the X and Z" +print "axes, and the approximate distance to the target." +print "You will then proceed to shoot at the target until it is" +print "destroyed!" +print; print +print "Good luck!" +roundToList = [20,10,2,1] +ready = true +while ready + turns = -1 + radX = rnd * 2 * pi + radZ = rnd * 2 * pi + print "Radians from X axis = " + radX + " from Z axis = " + radZ + + distance = 100000 * rnd * rnd + coords = getCoord(distance, radX, radZ) + + print "Target sighted: Approx Coordinates: " + coordStr(coords) + + gameRunning = true + while gameRunning + turns += 1 + if turns >=4 then + estDistance = distance + else + estDistance = roundDown(distance, roundToList[turns]) + end if + + print " Estimated Distance: " + estDistance + print + tx = input("Input angle deviation from X in degrees: ").val + tz = input("Input angle deviation from Z in degrees: ").val + tdist = input("Input distance: ").val + print + if tdist < 20 then + print "You blew yourself up!!" + gameRunning = false + else + tx = degToRad(tx) + tz = degToRad(tz) + + print "Radians from X-axis = " + tx + " from Z-axis = " + tz + targeted = getCoord(tdist, tx,tz) + distBet = distanceBetween(coords, targeted) + if distBet > 20 then + dx = targeted[0] - coords[0] + dy = targeted[1] - coords[1] + dz = targeted[2] - coords[2] + xMsg = {false: "Shot in front of target ", true: "Shot behind target "} + print xMsg[dx<0] + dx + " kilometers." + yMsg = {false: "Shot to left of target ", true: "Shot to right of target "} + print yMsg[dy<0] + dy + " kilometers." + zMsg = {false: "Shot above target ", true: "Shot below target "} + print zMsg[dz<0] + dz + " kilometers." + + print "Approx position of explosion: " + coordStr(targeted) + print " Distance from target = " + distBet + print + print + + else + print + print " * * * HIT * * * Target is non-functional" + print + print "Distance of explosion from target was " + distBet + "kilometers." + print + print "Mission accomplished in " + (turns+1) + " shots." + print + gameRunning = false + end if + end if + end while + print + ans = input("Ready for next target? ").lower + ready = ans and ans[0].lower == "y" + print +end while diff --git a/00_Alternate_Languages/90_Tower/MiniScript/README.md b/00_Alternate_Languages/90_Tower/MiniScript/README.md new file mode 100644 index 000000000..d8c97a891 --- /dev/null +++ b/00_Alternate_Languages/90_Tower/MiniScript/README.md @@ -0,0 +1,16 @@ +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 tower.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 "tower" + run \ No newline at end of file diff --git a/00_Alternate_Languages/90_Tower/MiniScript/tower.ms b/00_Alternate_Languages/90_Tower/MiniScript/tower.ms new file mode 100644 index 000000000..a1846545a --- /dev/null +++ b/00_Alternate_Languages/90_Tower/MiniScript/tower.ms @@ -0,0 +1,202 @@ +kInvalidDisk = 100 +kNotTopDisk = 200 +kNotTower = 300 +kGameOver = 300 + +Tower = {"disks": []} +Tower.init = function + noob = new Tower + noob.disks = [] + return noob +end function + +Tower.height = function + return self.disks.len +end function + +Tower.top = function + if self.height == 0 then return 100 + return self.disks[-1] +end function + +Game = {} +Game.towers = [] +Game.numOfDisks = 0 +Game.rangeOfDisks = [] +Game.selectedDisk = 0 +Game.selectedDiskOn = 0 +Game.selectedTower = 0 +Game.inputErrors = 0 +Game.turns = 0 + +Game.display = function + print + for r in range(7,1) + rowstr = "" + for tower in self.towers + if r > tower.height then + rowstr += " " * 12 + "#" + " " * 7 + else + spaces = (15 - tower.disks[r-1])/2 + disks = " " * 4 + tower.disks[r-1] + rowstr += disks[-5:] + " " * spaces + rowstr += "#" * tower.disks[r-1] + rowstr += " " * spaces + end if + rowstr += " " + end for + print rowstr + end for + rowstr = (" " * 5 + "=" * 15 + " ") * 3 + print rowstr + print +end function + +Game.init = function(num) + if num < 1 or num > 7 then + self.inputErrors += 1 + return false + end if + Game.towers = [] + for i in range(0,2) + Game.towers.push(Tower.init) + end for + + first = self.towers[0] + first.disks = range(15, 17 - num * 2, -2) + self.numOfDisks = num + self.rangeOfDisks = range(17 -num * 2, 15, 2) + + // This game doesn't like to be bothered + // and keeps track of how many incorrect inputs + // are made before it stops the game + self.inputErrors = 0 + self.turns = 0 + return true +end function + +Game.diskStatus = function + n = self.selectedDisk + if self.rangeOfDisks.indexOf(n) == null then + self.inputErrors +=1 + return kInvalidDisk + end if + self.inputErrors = 0 + for i in range(0, self.towers.len - 1) + if self.towers[i].top == n then + self.selectedDiskOn = i + self.inputErrors = 0 + return i + end if + end for + return kNotTopDisk +end function + +Game.pickDisk = function + self.selectedDisk = input("Which disk would you like to move? ").val + return self.diskStatus +end function + +Game.pickTower = function + self.selectedTower = input("Place disk on which needle? ").val - 1 + if not(0<= self.selectedTower and self.selectedTower <= 2) then + self.inputErrors += 1 + return kNotTower + end if + return self.selectedTower +end function + +Game.doneWithYou = function + return self.inputErrors >= 2 +end function + +Game.isFinish = function + return self.towers[0].disks.len == 0 and self.towers[1].disks.len == 0 +end function + +Game.move = function + print "Take turn # " + (self.turns + 1) + status = -1 + self.inputErrors = 0 + while 1 + status = self.pickDisk + if 0 <= status and status <= 2 then break + if status == kInvalidDisk and self.doneWithYou then + print "Stop wasting my time. Go bother someone else." + exit + else if status == kInvalidDisk then + msg = "Illegal entry ... you may only type " + msg += self.rangeOfDisks[0:-1].join(",") + " " + if self.rangeOfDisks.len > 1 then + msg += "or " + end if + msg += "15" + print msg + else if status == kNotTopDisk then + print "That disk is below another. Make another choice." + end if + end while + + self.inputErrors = 0 + while 1 + status = self.pickTower + if 0 <= status and status <= 2 then break + if status == kNotTower and self.doneWithYou then + print "I tried to warn you. But you wouldn't listen." + print "Bye bye, big shot." + exit + else if status == kNotTower then + print "I'll assume you hit the wrong key this time. But watch it," + print "I only allow one mistake." + end if + end while + + if self.selectedDisk > self.towers[self.selectedTower].top then + print "You can't place a larger disk on a top of a smaller one," + print "it may crush it!" + else + n=self.towers[self.selectedDiskOn].disks.pop + self.towers[self.selectedTower].disks.push(n) + self.turns += 1 + self.inputErrors = 0 + end if +end function + + +print " " * 33 + "TOWERS" +print " " * 15 + "Creative Computing Morristown, New Jersey" +print; print +print "You must transfer the disks from the left to the right" +print "tower, one at a time, never putting a larger disk on a" +print "smaller disk." +print + +ans = "Y" +while ans[0].upper == "Y" + while 1 + disks = input("How many disks do you want to move (7 is MAX)? ").val + status = Game.init(disks) + if status == false and Game.doneWithYou then + print "All right, wise guy, if you can't play the game right, I'll" + print "take my puzzle and go home. So long." + exit + else if not status then + print "Sorry, but I can't do that job for you" + else + break + end if + end while + + while not Game.isFinish + Game.display + + Game.move + end while + Game.display + print "Congratulations!" + print "You performed the task in " + Game.turns + " moves." + print + ans = input("Play again (Yes or No)? ") + " " +end while +print +print "Thanks for the game!" diff --git a/00_Alternate_Languages/93_23_Matches/MiniScript/23matches.ms b/00_Alternate_Languages/93_23_Matches/MiniScript/23matches.ms new file mode 100644 index 000000000..645082acf --- /dev/null +++ b/00_Alternate_Languages/93_23_Matches/MiniScript/23matches.ms @@ -0,0 +1,70 @@ +print " "*31 + "23 MATCHES" +print " "*15 + "Creative Computing Morristown, New Jersey" +print; print; print + +print "This is a game called '23 Matches'." +print +print "When it is your turn, you may take one, two, or three" +print "matches. The object of the game is not to have to take" +print "the last match." +print +print "Let's flip a coin to see who goes first." +print "If it comes up heads, I will win the toss." +print +matches = 23 +humanTurn = floor(rnd * 2) + +if humanTurn then + print "Tails! You go first." + prompt = "How many do you wish to remove? " +else + print "Heads! I win! Ha! Ha!" + print "Prepare to lose, meatball-nose!!" +end if + +choice = 2 +while matches > 0 + if humanTurn then + if matches < 23 then print "Your turn -- you may take 1, 2 or 3 matches." + prompt = "How many do you wish to remove? " + choice = 0 + if matches == 1 then choice = 1 + while choice == 0 + choice = input(prompt).val + if choice < 1 or choice > 3 or choice > matches then + choice = 0 + print "Very funny! Dummy!" + print "Do you want to play or goof around?" + prompt = "Now, how many matches do you want? " + end if + end while + matches = matches - choice + if matches == 0 then + print "You poor boob! You took the last match! I gotcha!!" + print "Ha ! Ha ! I beat you !!" + print + print "Good bye loser!" + else + print "There are now " + matches + " matches remaining." + print + end if + else + choice_comp = 4 - choice + if matches == 1 then + choice_comp = 1 + else if 1 < matches and matches < 4 then + choice_comp = matches - 1 + end if + matches = matches - choice_comp + if matches == 0 then + print "You won, floppy ears!" + print "Think you're pretty smart!" + print "Let's play again and I'll blow your shoes off!!" + else + print "My turn! I remove " + choice_comp + " matches" + print "The number of matches is now " + matches + print + end if + end if + humanTurn = not humanTurn +end while diff --git a/00_Alternate_Languages/93_23_Matches/MiniScript/README.md b/00_Alternate_Languages/93_23_Matches/MiniScript/README.md new file mode 100644 index 000000000..9156a730e --- /dev/null +++ b/00_Alternate_Languages/93_23_Matches/MiniScript/README.md @@ -0,0 +1,16 @@ +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 23matches.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 "23matches" + run \ No newline at end of file diff --git a/00_Alternate_Languages/95_Weekday/MiniScript/README.md b/00_Alternate_Languages/95_Weekday/MiniScript/README.md new file mode 100644 index 000000000..218cb4cc9 --- /dev/null +++ b/00_Alternate_Languages/95_Weekday/MiniScript/README.md @@ -0,0 +1,17 @@ +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 weekday.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 "weekday" + run +``` \ No newline at end of file diff --git a/00_Alternate_Languages/95_Weekday/MiniScript/weekday.ms b/00_Alternate_Languages/95_Weekday/MiniScript/weekday.ms new file mode 100644 index 000000000..65641ebc3 --- /dev/null +++ b/00_Alternate_Languages/95_Weekday/MiniScript/weekday.ms @@ -0,0 +1,182 @@ +TAB = char(9) + +Age = {"m": 0, "d": 0, "y": 0} +Age.init = function(m,d,y) + noob = new Age + noob.m = m;noob.d = d;noob.y = y + return noob +end function + +Age.sub = function(a) + m1 = self.m; d1 = self.d; y1 = self.y + d1 = d1 - a.d + if d1 < 0 then + d1 = d1 + 30 + m1 = m1 - 1 + end if + m1 = m1 - a.m + if m1 < 0then + m1 = m1 + 12 + y1 = y1 - 1 + end if + y1 = y1 - a.y + return Age.init(m1,d1,y1) +end function + +Age.multiply = function(multiplier) + ageInDays = self.y *365 + self.m * 30 + self.d + floor(self.m / 2) + newAge = ageInDays * multiplier + years = floor(newAge/ 365) + leftover = newAge % 365 + months = floor(leftover / 30) + days = floor(leftover % 30) + return Age.init(months, days, years) +end function + +Date = {"m": null, "d": null, "y": null} + +// the number of days between the 1st of one month to the next +Date.daysPerMonth = [0,31,28,31,30,31,30, 31,31,30,31,30] +Date.dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", +"Thursday", "Friday", "Saturday"] + +Date.init = function(dt) + d = dt.split(",") + if d.len != 3 then return + noob = new Date + noob.m = d[0].val + noob.d = d[1].val + noob.y = d[2].val + return noob +end function + +Date.diff = function(mdy) + dday = self.d - mdy.d + dmonth = self.m - mdy.m + if dday < 0 then + dmonth -= 1 + dday += 30 + end if + + dyear = self.y - mdy.y + if dmonth <0 then + dyear -= 1 + dmonth += 12 + end if + return Age.init(dmonth, dday, dyear) +end function + +Date._isLeapYear = function + return (self.y % 4 == 0 and self.y % 100 != 0) or self.y % 400 == 0 +end function + +Date.value = function + //Not accepting dates Jan 1st 1583 this because the + //transistion to Gregorian calendar occurred in 1582. + + //calculating days since the end of 1582 + years = self.y - 1583 + days = years * 365 + self._leapYears + Date.daysPerMonth[:self.m].sum + self.d + return days // returns 1 for 1,1,1583 +end function + +Date.dayOfWeek = function + // 1,1,1583 is a Saturday + // Date.value calculates a value of 1 for that date + return (self.value + 5) % 7 +end function + +Date.weekday = function + return Date.dayNames[self.dayOfWeek] +end function + +// get # of lear yeaps since the change to Gregorian +Date._leapYears = function + ly = floor((self.y - 1580) / 4) + + //exclude centuries + centuries = floor((self.y - 1500) / 100) + + //unless centuries divisible by 400 + centuries400 = floor((self.y - 1200) / 400) + ly = ly - centuries + centuries400 + + if self._isLeapYear and self.m < 3 then ly -= 1 + return ly +end function + +print " "*32 + "WEEKDAY" +print " "*15 + "Creative Computing Morristown, New Jersey" +print; print; print + +print "WEEKDAY is a computer demonstration that" +print "gives facts about a date of interest to you." +print + +mdy = input("Enter today's date in the form: 3,24,1979? ") +today = Date.init(mdy) + + +mdy = input("Enter day of birth (or other day of interest)? ") +dob = Date.init(mdy) + +print +if dob.y < 1583 then + print "Not prepared to give day of the week prior to 1583" + exit +end if + +verb = " was a " +if today.value < dob.value then verb= " will be a " +if today.value == dob.value then verb = " is a " + +if dob.d == 13 and dob.weekday == "Friday" then + endMsg = " The Thirteenth--Beware!" +else + endMsg = "." +end if +print dob.m + "/" + dob.d + "/" + dob.y + verb + dob.weekday + endMsg + +age = today.diff(dob) + +totalAge = Age.init(age.m,age.d,age.y) +if verb == " was a " then + if dob.d == today.d and dob.m == today.m then print "***HAPPY BIRTHDAY***" + + lines= [["", "YEARS", "MONTHS", "DAYS"]] + lines.push(["", "-----", "------", "----"]) + lines.push(["Your age (if birthdate)", age.y,age.m, age.d]) + + spent = age.multiply(.35) + lines.push(["You have slept", spent.y,spent.m, spent.d]) + totalAge = totalAge.sub(spent) + + spent = age.multiply(.17) + lines.push(["You have eaten", spent.y,spent.m, spent.d]) + totalAge = totalAge.sub(spent) + + if totalAge.y <= 3 then + phrase = "You have played" + else if totalAge.y <= 9 then + phrase = "You have played/studied" + else + phrase = "You have worked/played" + end if + + spent = age.multiply(.23) + lines.push([phrase, spent.y,spent.m, spent.d]) + totalAge = totalAge.sub(spent) + + relaxed = totalAge + lines.push(["You have relaxed", relaxed.y, relaxed.m, relaxed.d]) + for line in lines + col0 = (" " * 25 + line[0])[-25:] + col1 = (line[1] + " " * 6)[:6] + col2 = (line[2] + " " * 7)[:7] + col3 = (line[3] + " " * 5)[:5] + print (col0+" " + col1+col2+col3) + end for +end if + +print +print " "*16 + "*** You may retire in " + (dob.y + 65) + " ***" diff --git a/00_Alternate_Languages/96_Word/MiniScript/README.md b/00_Alternate_Languages/96_Word/MiniScript/README.md new file mode 100644 index 000000000..567a84baf --- /dev/null +++ b/00_Alternate_Languages/96_Word/MiniScript/README.md @@ -0,0 +1,17 @@ +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 word.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 "word" + run +``` \ No newline at end of file diff --git a/00_Alternate_Languages/96_Word/MiniScript/word.ms b/00_Alternate_Languages/96_Word/MiniScript/word.ms new file mode 100644 index 000000000..190ad6117 --- /dev/null +++ b/00_Alternate_Languages/96_Word/MiniScript/word.ms @@ -0,0 +1,63 @@ +words = ["dinky", "smoke", "water", "grass", "train", "might", + "first", "candy", "champ", "would", "clump", "dopey"] + +playGame = function + secret = words[rnd * words.len] + guesses = 0 + exact = ["-"]*5 + + print "You are starting a new game..." + while true + guess = "" + while guess == "" + print + guess = input("Guess a five letter word. ").lower + if guess == "?" then break + if guess.len != 5 then + guess = "" + print "You must guess a five letter word. Try again." + end if + end while + guesses += 1 + + if guess == "?" then + print "The secret word is " + secret + break + else + common = "" + for i in range(0, 4) + if secret.indexOf(guess[i]) != null then + common += guess[i] + if secret[i] == guess[i] then + exact[i] = guess[i] + end if + end if + end for + print "There were " + common.len + " matches and the common letters were..." + common + print "From the exact letter matches, you know"+"."*16 + exact.join("") + + if secret == guess or secret == exact.join("") then + print "You have guessed the word. It took " + guesses + " guesses!" + break + else if common.len < 2 then + print + print "If you give up, type '?' for your next guess." + end if + end if + end while +end function + +print " " * 33 + "WORD" +print " " * 15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY" +print +print "I am thinking of a word -- you guess it. I will give you" +print "clues to help you get it. Good luck!" +print + +playing = "y" +while playing == "y" + playGame + print + playing = input("Want to play again? ") + " " + playing = playing[0].lower +end while diff --git a/60_Mastermind/README.md b/60_Mastermind/README.md index 7820eed7b..05383f106 100644 --- a/60_Mastermind/README.md +++ b/60_Mastermind/README.md @@ -86,7 +86,7 @@ solutions reporting their black and white pegs against `RBW`. | BRW | 1 | 2 | | WRW | 1 | 1 | | RRW | 2 | 0 | | BRR | 0 | 2 | | WRR | 0 | 2 | | RRR | 1 | 0 | -Now we are going to eliminate every solution that **DOESN'T** matches 0 black and 2 white. +Now we are going to eliminate every solution that **DOESN'T** match 0 black and 2 white. | Guess | Black | White | | Guess | Black | White | | Guess | Black | White | |----------|-------|-------|-----|----------|-------|-------|-----|----------|-------|-------| @@ -130,7 +130,7 @@ report 1 black and 0 whites. | ~~~WWB~~ | 0 | 1 | | ~~~WRR~~ | 2 | 0 | -Only one solution matches and its our secret code! The computer will guess this +Only one solution matches and it's our secret code! The computer will guess this one next as it's the only choice left, for a total of three moves. Coincidentally, I believe the expected maximum number of moves the computer will make is the number of positions plus one for the initial guess with no information. @@ -150,4 +150,8 @@ WB first, the most you can logically deduce if you get 1 black and 1 white is that it is either WW, or BB which could bring your total guesses up to three which is the number of positions plus one. So if your computer's turn is taking longer than the number of positions plus one to find the answer then something -is wrong with your code. \ No newline at end of file +is wrong with your code. + +#### Known Bugs + +- Line 622 is unreachable, as the previous line ends in a GOTO and that line number is not referenced anywhere. It appears that the intent was to tell the user the correct combination after they fail to guess it in 10 tries, which would be a very nice feature, but does not actually work. (In the MiniScript port, I have made this feature work.) diff --git a/65_Nim/README.md b/65_Nim/README.md index 11243f0fc..fae886395 100644 --- a/65_Nim/README.md +++ b/65_Nim/README.md @@ -28,3 +28,7 @@ http://www.vintage-basic.net/games.html #### Porting Notes This can be a real challenge to port because of all the `GOTO`s going out of loops down to code. You may need breaks and continues, or other techniques. + +#### Known Bugs + +- If, after the player moves, all piles are gone, the code prints "MACHINE LOSES" regardless of the win condition (when line 1550 jumps to line 800). This should instead jump to line 800 ("machine loses") if W=1, but jump to 820 ("machine wins") if W=2. diff --git a/68_Orbit/README.md b/68_Orbit/README.md index 9e4e9afdf..be765b557 100644 --- a/68_Orbit/README.md +++ b/68_Orbit/README.md @@ -20,7 +20,7 @@ of orbit < ^ ship ``` -The distance of the bomb from the ship is computed using the law of consines. The law of cosines states: +The distance of the bomb from the ship is computed using the law of cosines. The law of cosines states: ``` D = SQUAREROOT( R**2 + D1**2 - 2*R*D1*COS(A-A1) ) diff --git a/69_Pizza/README.md b/69_Pizza/README.md index 56548b645..7f9e3fcf2 100644 --- a/69_Pizza/README.md +++ b/69_Pizza/README.md @@ -15,6 +15,10 @@ As published in Basic Computer Games (1978): Downloaded from Vintage Basic at http://www.vintage-basic.net/games.html +#### Known Bugs + +- The program does no validation of its input, and crashes if you enter coordinates outside the valid range. (Ports may choose to improve on this, for example by repeating the prompt until valid coordinates are given.) + #### Porting Notes (please note any difficulties or challenges in porting here)