-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #912 from JoeStrout/miniscript-tweaks
Miniscript tweaks
- Loading branch information
Showing
21 changed files
with
2,027 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
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 | ||
|
||
while Machine.playing | ||
Machine.makeBet | ||
// Main program | ||
profit = 0 | ||
while true | ||
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] | ||
Machine.results | ||
Machine.playAgain | ||
ringBells 10; print spun[0], " " | ||
ringBells 5; print spun[1], " " | ||
ringBells 5; print spun[2] | ||
|
||
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
00_Alternate_Languages/83_Stock_Market/MiniScript/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
Oops, something went wrong.