From 1b40ef39e174f6fd3dd9add75d11ab3c2d114106 Mon Sep 17 00:00:00 2001 From: chinhouse Date: Tue, 19 Sep 2023 16:07:39 -0700 Subject: [PATCH 1/5] Create slots.ms --- .../80_Slots/MiniScript/slots.ms | 125 ++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 00_Alternate_Languages/80_Slots/MiniScript/slots.ms diff --git a/00_Alternate_Languages/80_Slots/MiniScript/slots.ms b/00_Alternate_Languages/80_Slots/MiniScript/slots.ms new file mode 100644 index 000000000..40748e574 --- /dev/null +++ b/00_Alternate_Languages/80_Slots/MiniScript/slots.ms @@ -0,0 +1,125 @@ +center = function(s,n) + h = floor((n - s.len)/2) + s = " " * h + s + " " * n + return s[:n] +end function + +Machine = {"symbols": ["Bar", "Bell", "Orange", "Lemon", "Plum ", "Cherry"]} +Machine.money = 0 +Machine.bet = 0 +Machine.playing = true +Machine.reels = [0,0,0] +Machine.results = null + +Machine.reelsSpin = function(n, msg, row) + env = [1,.95,.9,.85,.25,.2,.15,.1,.05,0] + bell = new Sound + bell.init .1, 800, env, Sound.sineWave + for i in range(1,2) + s1 = new Sound + s1.init .2, i * 800 + 800, env, Sound.sineWave + bell.mix(s1, 1 / (2 ^ i)) + end for + for i in range(1,n) + bell.play + ix = 0 + while bell.isPlaying + text.row = row + ix = (ix + 1) % self.symbols.len + print msg + center(self.symbols[ix],8) + end while + end for +end function + +Machine.makeBet = function() + while true + bet = floor(input("Your bet? ").val) + if bet > 100 then + print "House limits are $100" + else if bet < 1 then + print "Minimum bet is $1" + else + break + end if + end while + Machine.bet = bet +end function + +Machine.pullHandle = function + if text.row < 3 then + print; print + text.row = text.row + 2 + end if + row = text.row + msg = "" + for i in range(0,2) + self.reelsSpin(5 + 5 * (i==0), msg, row) + wait .1 + symIx = floor(rnd * self.symbols.len) + msg += center(self.symbols[symIx],9) + self.reels[i] = symIx + text.row = row + print msg + end for +end function + +Machine.winnings = function + bet = Machine.bet + barIdx = self.symbols.indexOf("Bar") + numBars = 0 + multiples = 0 + for i in range(0,2) + numBars += (self.reels[i] == barIdx) + multiples += (self.reels[i] == self.reels[(i + 1) % 3]) + end for + + if numBars == 3 then return {"won": bet * 101, "msg": "***Jackpot***"} + if numBars == 2 then return {"won": bet * 6, "msg": "*Double Bar*"} + if multiples == 3 then return {"won": bet * 11, "msg": "**Top Dollar**"} + if multiples == 1 then return {"won": bet * 3, "msg": "Double!!"} + return {"won": -bet, "msg": "You lost."} +end function + +Machine.results = function + result = Machine.winnings + self.money += result.won + print result.msg + if result.won > 0 then + print "You Won!!" + end if + print "Your standings are $" + self.money + return +end function + +Machine.playAgain = function + ans = input("Again? ") + " " + self.playing = (ans[0].lower == "y") + if self.playing then return + print + if self.money < 0 then + print "Pay up! Please leave your money on the terminal." + else if self.money == 0 then + print "Hey, you broke even." + else + print "Collect your winnings from the H&M cashier." + end if +end function + +clear +print " " * 30 + "Slots" +print " " * 15 + "Creative Computing Morristown, New Jersey" +print;print;print +print "You are in the H&M Casino, in front of one of our" +print "one-arm bandits. Bet from $1 to $100." +print "to pull the arm, punch the return key after making your bet." + +print +while Machine.playing + Machine.makeBet + print + Machine.pullHandle + print + Machine.results + Machine.playAgain + print +end while From b9031ce637929db39dfcff4d9d5243ba5012299d Mon Sep 17 00:00:00 2001 From: chinhouse Date: Tue, 19 Sep 2023 16:08:09 -0700 Subject: [PATCH 2/5] Add files via upload --- .../80_Slots/MiniScript/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 00_Alternate_Languages/80_Slots/MiniScript/README.md diff --git a/00_Alternate_Languages/80_Slots/MiniScript/README.md b/00_Alternate_Languages/80_Slots/MiniScript/README.md new file mode 100644 index 000000000..e8cc201ec --- /dev/null +++ b/00_Alternate_Languages/80_Slots/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 slots.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 "slots" + run \ No newline at end of file From 7db163b2f302ea70d8c518851b7224b805f6a228 Mon Sep 17 00:00:00 2001 From: chinhouse Date: Thu, 21 Sep 2023 22:28:27 -0700 Subject: [PATCH 3/5] Create README.md --- .../81_Splat/MiniScript/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 00_Alternate_Languages/81_Splat/MiniScript/README.md diff --git a/00_Alternate_Languages/81_Splat/MiniScript/README.md b/00_Alternate_Languages/81_Splat/MiniScript/README.md new file mode 100644 index 000000000..f7d3b016b --- /dev/null +++ b/00_Alternate_Languages/81_Splat/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 splat.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 "splat" + run From 5126e835982c61d6adfe12c975f4442e13f31574 Mon Sep 17 00:00:00 2001 From: chinhouse Date: Thu, 21 Sep 2023 22:28:49 -0700 Subject: [PATCH 4/5] Add files via upload --- .../81_Splat/MiniScript/splat.ms | 133 ++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 00_Alternate_Languages/81_Splat/MiniScript/splat.ms diff --git a/00_Alternate_Languages/81_Splat/MiniScript/splat.ms b/00_Alternate_Languages/81_Splat/MiniScript/splat.ms new file mode 100644 index 000000000..befff4319 --- /dev/null +++ b/00_Alternate_Languages/81_Splat/MiniScript/splat.ms @@ -0,0 +1,133 @@ +within5pct = function(n) + return n * (1 + rnd / 20 - rnd / 20) +end function + +splatMsg = ["Requiescat in pace.", "May the Angel of Heaven lead you into Paradise.", + "Rest in piece.", "Son-Of-A-Gun.", "#$%&&%!$", + "A kick in the pants is a boost if you're headed right.", + "Hmm. Should have picked a shorter time.", "Mutter. Mutter. Mutter.", + "Pushing up daisies.", "Easy come, easy go."] + +history = [] +clear +print " " * 33 + "Splat" +print " " * 15 + "Creative Computing Morristown, New Jersey" +print;print;print +print "Welcome to 'Splat' -- the game that simulates a parachute" +print "jump. Try to open your chute at the last possible" +print "moment without going splat." +ans = "y" +while ans == "y" + print;print + + distance = floor(9001 * rnd) + 1000 + + ans = input("Select your own terminal velocity (Yes or No)? ") + " " + if ans[0].lower == "y" then + terminalVel = input("What terminal velocity (mi/hr)? ").val + else + terminalVel = floor(1000 * rnd) + print "Ok. Terminal velocity = " + terminalVel + "mi/hr" + end if + + terminalVel = terminalVel * 5280/3600 + velocity = within5pct(terminalVel) + + ans = input("Want to select acceleration due to gravity (Yes or No)? ") + " " + if ans[0].lower == "y" then + acceleration = input("What acceleration (ft/sec/sec)? ").val + acceleration = within5pct(acceleration) + else + bodies = ["Mercury", "Venus", "Earth", "the moon", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "the Sun"] + gravity = [12.2, 28.3,32.16,5.15,12.5,85.2,37.6,33.8,39.6,896] + + initialStmt = ["Fine. You're on ", "All right. You're on ", "Then you're on "] + + i = floor(rnd * 10) + acceleration = gravity[i] + stmt = initialStmt[i%3] + bodies[i] + ". Acceleration=" + acceleration + " ft/sec/sec." + print stmt + end if + + actAccel = within5pct(acceleration) + print + print " Altitude = " + distance + " ft" + print " Term. Velocity = " + terminalVel + " ft/sec +/-5%" + print " Acceleration = " + acceleration + " ft/sec/sec +/-5%" + print "Set the timer for your freefall." + sec = input("How many seconds? ").val + + print "Here we go."; print + + print "Time (sec)" + char(9) + "Dist to Fall (ft)" + print "==========" + char(9) + "=================" + termVelHit = false + for i in range(0, sec, sec/8) + sec = velocity/actAccel + if i <= sec and termVelHit == false then + dist = distance - ((actAccel/2)*i^2) + else if termVelHit == false then + termVelHit = true + print "Terminal velocity reached a T plus " + velocity/actAccel + " seconds." + end if + if termVelHit then + dist = distance - ((velocity^2/(2*actAccel))+(velocity*(i-sec))) + end if + + if dist <= 0 then break + print (" " + i + " " * 9)[:9] + char(9) + " " + dist + end for + + if dist > 0 then + print "Chute open" + history.push(dist) + numJumps = history.len + numLowerJumps = 0 + for d in history + numLowerJumps += (dist <= d) + end for + + jumpDiff = numJumps - numLowerJumps + if numJumps < 4 then + ordinal = ["1st", "2nd", "3rd"] + print "Amazing!! Not bad for your " + ordinal[numJumps-1] + " successful jump!!!" + else if jumpDiff <= numJumps * 0.10 then + print "Wow! That's some jumping. Of the " + numJumps + " successful jumps" + print "before yours, only " + jumpDiff + " opened their chutes lower than" + print "you did." + else if jumpDiff <= numJumps * 0.25 then + print "Pretty good! " + numJumps + " successful jumps preceded yours and only" + print jumpDiff + " of them got lower than you did before their chute" + print "opened." + else if jumpDiff <= numJumps * 0.50 then + print "Not bad. There have been " + numJumps + " successful jumps before yours." + print "You were beaten out by " + jumpDiff + " of them." + else if jumpDiff <= numJumps * 0.75 then + print "Conservative, aren't you? You ranked only " + jumpDiff + " in the" + print numJumps + " successful jumps before yours." + else if jumpDiff <= numJumps * 0.90 then + print "Humph! Don't you have any sporting blood? There were" + print numJumps + " successful jumps before yours and you came in " + numLowerJumps + " jumps" + print "better than the worst. Shape up!!!" + else + print "Hey! You pulled the rip code much too soon. " + numJumps + " successful" + print "jumps before yours and you came in number " + jumpDiff + "! Get with it." + end if + else if dist <= 0 and not termVelHit then + print (2 * distance / actAccel) ^ .5 + " " * 5 + "Splat" + else if dist <= 0 and termVelHit then + print velocity/actAccel + ((distance - (velocity^2/(2*actAccel)))/velocity) + " " *5 + "Splat" + end if + + if dist <=0 then + splatMsg.shuffle + print splatMsg[0] + print "I'll give you another chance." + end if + + ans = input("Do you want to play again? ") + " " + ans = ans[0].lower +end while + +print "S" * 10 +print \ No newline at end of file From 7e3fe0279e93142398a020077390584ba3ed9784 Mon Sep 17 00:00:00 2001 From: chinhouse Date: Fri, 22 Sep 2023 22:34:39 -0700 Subject: [PATCH 5/5] Add tictactoe2.ms --- .../89_Tic-Tac-Toe/MiniScript/tictactoe2.ms | 155 ++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 00_Alternate_Languages/89_Tic-Tac-Toe/MiniScript/tictactoe2.ms diff --git a/00_Alternate_Languages/89_Tic-Tac-Toe/MiniScript/tictactoe2.ms b/00_Alternate_Languages/89_Tic-Tac-Toe/MiniScript/tictactoe2.ms new file mode 100644 index 000000000..20981ab08 --- /dev/null +++ b/00_Alternate_Languages/89_Tic-Tac-Toe/MiniScript/tictactoe2.ms @@ -0,0 +1,155 @@ +solutions = [[0,1,2],[3,4,5],[6,7,8]] +solutions += [[0,3,6],[1,4,7],[2,5,8]] +solutions += [[0,4,8],[2,4,6]] + +TicTacToe = {} +TicTacToe.grid = (" " * 9).split("") +TicTacToe.markers = {true: "X",false:"O"} +TicTacToe.AI = "X" +TicTacToe.human = "O" +TicTacToe.next = "X" +TicTacToe.lastMove = -1 + +TicTacToe.show = function + print " " + self.grid[0:3].join(" ! ") + print "---+---+---" + print " " + self.grid[3:6].join(" ! ") + print "---+---+---" + print " " + self.grid[6:].join(" ! ") + print + print +end function + +TicTacToe.set = function(player, pos) + if self.grid[pos] != " " then + return false + end if + self.grid[pos] = player + self.lastMove = pos + return true +end function + +TicTacToe.setMarkers = function(mark) + self.human = self.markers[mark == "X"] + self.AI = self.markers[mark == "O"] +end function + +TicTacToe.getWinner = function + for mark in self.markers.values + for solution in solutions + cnt = 0 + for i in solution + cnt += (self.grid[i] == mark) + end for + if cnt == 3 then return mark + end for + end for + return null +end function + +TicTacToe.potentialWins = function + potential = {"X": [], "O": []} + for mark in self.markers.values + for solution in solutions + cnt = 0 + emptyCells = [] + for i in solution + cnt += (self.grid[i] == mark) + if self.grid[i] == " " then emptyCells.push(i) + end for + if cnt == 2 and emptyCells.len == 1 then potential[mark].push(emptyCells[0]) + end for + end for + return potential +end function + +TicTacToe.moveAvailable = function + return self.grid.indexOf(" ") != null +end function + +TicTacToe.selectAI = function + if self.grid[4] == " " then return 4 + + potential = self.potentialWins + + AIWins = potential[self.AI] + if AIWins.len >0 then return AIWins[0] + + HumanWins = potential[self.human] + + if HumanWins.len > 0 then return HumanWins[0] + + if [1,3,5,7].indexOf(self.lastMove) != null then + for corner in [8,6,2,0] + if self.grid[corner] == " " then + self.grid[corner] = self.AI + potential = self.potentialWins + self.grid[corner] = " " + AIWins = potential[self.AI] + if AIWins.len > 0 then return corner + end if + end for + else + for side in [1,3,5,7] + if self.grid[side] == " " then + self.grid[side] = self.AI + potential = self.potentialWins + self.grid[side] = " " + AIWins = potential[self.AI] + if AIWins.len > 0 then return side + end if + end for + end if + for ix in range(0,8) + if self.grid[ix] == " " then return ix + end for + + return null +end function + +print " " * 15 + "Creative Computing Morristown, New Jersey" +print; print; print +print "The board is numbered." +print; print; print +print " 1 2 3" +print " 4 5 6" +print " 7 8 9" +print +ans = input("Do you want to 'X' or 'O'? ") +if ans.upper != "X" then ans = "O" +TicTacToe.setMarkers(ans.upper) +winner = null +print +while TicTacToe.moveAvailable and winner == null + + if TicTacToe.next == TicTacToe.AI then + move = TicTacToe.selectAI + TicTacToe.set(TicTacToe.AI, move) + TicTacToe.next = TicTacToe.human + print "The computer moves to..." + else + move = input("Where do you move? ").val + if move < 1 or move > 9 then + print "Thanks for the game." + exit + else if not TicTacToe.set(TicTacToe.human, move-1) then + print "That square is occupied." + print + continue + else + TicTacToe.next = TicTacToe.AI + end if + end if + + TicTacToe.show + winner = TicTacToe.getWinner +end while + +if winner == null then + print "It's a draw. Thank you." +else if winner == TicTacToe.AI then + print "I win, turkey!!" +else + print "You beat me! Good game!" +end if +