Skip to content

Commit

Permalink
Merge pull request #912 from JoeStrout/miniscript-tweaks
Browse files Browse the repository at this point in the history
Miniscript tweaks
  • Loading branch information
coding-horror authored Jan 11, 2024
2 parents cdced29 + cfa084b commit 8b40cc8
Show file tree
Hide file tree
Showing 21 changed files with 2,027 additions and 144 deletions.
2 changes: 1 addition & 1 deletion 00_Alternate_Languages/44_Hangman/MiniScript/hangman.ms
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ doOneGame = function
for i in range(1,12); ps[i][1] = "X"; end for
for i in range(1, 7); ps[1][i] = "X"; end for; ps[2][7] = "X"
secretWord = words.pull.upper
print "(Secret word: " + secretWord + ")"
//print "(Secret word: " + secretWord + ")"
visibleWord = ["-"] * secretWord.len
wrongGuesses = 0
while true
Expand Down
2 changes: 1 addition & 1 deletion 00_Alternate_Languages/69_Pizza/MiniScript/pizza.ms
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ while true
while true
inp = input(" Driver to " + name + ": Where does " + buyer + " live? ")
inp = inp.replace(",", " ").replace(" ", " ")
inp = inp.split + [0,0]
inp = inp.split + ["0","0"]
guess = [inp[0].val, inp[1].val]
if 1 <= guess[0] <= 4 and 1 <= guess[1] <= 4 then break
end while
Expand Down
34 changes: 18 additions & 16 deletions 00_Alternate_Languages/80_Slots/MiniScript/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +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 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
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
```
195 changes: 89 additions & 106 deletions 00_Alternate_Languages/80_Slots/MiniScript/slots.ms
Original file line number Diff line number Diff line change
@@ -1,125 +1,108 @@
center = function(s,n)
h = floor((n - s.len)/2)
s = " " * h + s + " " * n
return s[:n]
end function
print " "*30 + "Slots"
print " "*15 + "Creative Computing Morristown New Jersey"
print; print; print

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
// PRODUCED BY FRED MIRABELLE AND BOB HARPER ON JAN 29, 1973
// IT SIMULATES THE SLOT MACHINE.
// (Ported to MiniScript by Joe Strout on Oct 04, 2023)

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
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."

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
symbols = ["BAR", "BELL", "ORANGE", "LEMON", "PLUM", "CHERRY"]

Machine.pullHandle = function
if text.row < 3 then
print; print
text.row = text.row + 2

winTriple = function(symbol, bet)
if symbol == "BAR" then
print "***JACKPOT***"
globals.profit += 101 * bet
else
print "**TOP DOLLAR**"
globals.profit += 11 * bet
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
print "You won!"
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."}
winDouble = function(symbol, bet)
if symbol == "BAR" then
print "*DOUBLE BAR*"
globals.profit += 6 * bet
else
print "Double!"
globals.profit += 3 * bet
end if
print "You won!"
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
lose = function(bet)
print "You lost."
globals.profit -= bet
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."
calcWinLoss = function(spun, bet)
if spun[0] == spun[1] then
if spun[0] == spun[2] then
winTriple spun[0], bet
else
winDouble spun[0], bet
end if
else if spun[0] == spun[2] then
winDouble spun[0], bet
else if spun[1] == spun[2] then
winDouble spun[1], bet
else
print "Collect your winnings from the H&M cashier."
lose bet
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."
ringBells = function(qty=5)
// I believe all the obnoxious beeping was to slow down the game
// and build suspense as each "wheel" appears. Our version:
wait 0.1
for i in range(1, qty)
print char(7), ""
wait 0.05
end for
end function

print
while Machine.playing
Machine.makeBet
// Main program
profit = 0
while true
print
Machine.pullHandle

// Get bet
while true
bet = input("Your bet? ").val
if 1 <= bet <= 100 then break
if bet < 1 then print "Minimum bet is $1" else print "House limits are $100"
end while

// Spin 3 wheels (randomly picking a symbol for each one)
spun = []
spun.push symbols[rnd * symbols.len]
spun.push symbols[rnd * symbols.len]
spun.push symbols[rnd * symbols.len]
print
Machine.results
Machine.playAgain
ringBells 10; print spun[0], " "
ringBells 5; print spun[1], " "
ringBells 5; print spun[2]
print

// Calculate and display win/loss
wait 0.5
calcWinLoss spun, bet

// Show new state, and maybe play again
print "Your standings are $ " + profit
yn = input("Again? ").lower + " "
if yn[0] != "y" then break
end while

if profit == 0 then
print "Hey, you broke even."
else if profit > 0 then
print "Collect your winnings from the H&M cashier."
else
print "Pay up! Please leave your money on the terminal."
end if
6 changes: 4 additions & 2 deletions 00_Alternate_Languages/81_Splat/MiniScript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ 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
```
2 changes: 1 addition & 1 deletion 00_Alternate_Languages/81_Splat/MiniScript/splat.ms
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ splatMsg = ["Requiescat in pace.", "May the Angel of Heaven lead you into Paradi
"Pushing up daisies.", "Easy come, easy go."]

history = []
clear
//clear // (works on Mini Micro only)
print " " * 33 + "Splat"
print " " * 15 + "Creative Computing Morristown, New Jersey"
print;print;print
Expand Down
8 changes: 5 additions & 3 deletions 00_Alternate_Languages/82_Stars/MiniScript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ 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
run
```
18 changes: 18 additions & 0 deletions 00_Alternate_Languages/83_Stock_Market/MiniScript/README.md
Original file line number Diff line number Diff line change
@@ -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 stockmarket.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 "stockmarket"
run
```
Loading

0 comments on commit 8b40cc8

Please sign in to comment.