Skip to content

Commit 8b40cc8

Browse files
Merge pull request #912 from JoeStrout/miniscript-tweaks
Miniscript tweaks
2 parents cdced29 + cfa084b commit 8b40cc8

File tree

21 files changed

+2027
-144
lines changed

21 files changed

+2027
-144
lines changed

00_Alternate_Languages/44_Hangman/MiniScript/hangman.ms

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ doOneGame = function
6363
for i in range(1,12); ps[i][1] = "X"; end for
6464
for i in range(1, 7); ps[1][i] = "X"; end for; ps[2][7] = "X"
6565
secretWord = words.pull.upper
66-
print "(Secret word: " + secretWord + ")"
66+
//print "(Secret word: " + secretWord + ")"
6767
visibleWord = ["-"] * secretWord.len
6868
wrongGuesses = 0
6969
while true

00_Alternate_Languages/69_Pizza/MiniScript/pizza.ms

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ while true
7878
while true
7979
inp = input(" Driver to " + name + ": Where does " + buyer + " live? ")
8080
inp = inp.replace(",", " ").replace(" ", " ")
81-
inp = inp.split + [0,0]
81+
inp = inp.split + ["0","0"]
8282
guess = [inp[0].val, inp[1].val]
8383
if 1 <= guess[0] <= 4 and 1 <= guess[1] <= 4 then break
8484
end while
Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
2-
3-
Conversion to [MiniScript](https://miniscript.org).
4-
5-
Ways to play:
6-
7-
1. Command-Line MiniScript:
8-
Download for your system from https://miniscript.org/cmdline/, install, and then run the program with a command such as:
9-
10-
miniscript slots.ms
11-
12-
2. Mini Micro:
13-
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:
14-
15-
load "slots"
16-
run
1+
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
2+
3+
Conversion to [MiniScript](https://miniscript.org).
4+
5+
Ways to play:
6+
7+
1. Command-Line MiniScript:
8+
Download for your system from https://miniscript.org/cmdline/, install, and then run the program with a command such as:
9+
```
10+
miniscript slots.ms
11+
```
12+
13+
2. Mini Micro:
14+
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:
15+
```
16+
load "slots"
17+
run
18+
```
Lines changed: 89 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,108 @@
1-
center = function(s,n)
2-
h = floor((n - s.len)/2)
3-
s = " " * h + s + " " * n
4-
return s[:n]
5-
end function
1+
print " "*30 + "Slots"
2+
print " "*15 + "Creative Computing Morristown New Jersey"
3+
print; print; print
64

7-
Machine = {"symbols": ["Bar", "Bell", "Orange", "Lemon", "Plum ", "Cherry"]}
8-
Machine.money = 0
9-
Machine.bet = 0
10-
Machine.playing = true
11-
Machine.reels = [0,0,0]
12-
Machine.results = null
5+
// PRODUCED BY FRED MIRABELLE AND BOB HARPER ON JAN 29, 1973
6+
// IT SIMULATES THE SLOT MACHINE.
7+
// (Ported to MiniScript by Joe Strout on Oct 04, 2023)
138

14-
Machine.reelsSpin = function(n, msg, row)
15-
env = [1,.95,.9,.85,.25,.2,.15,.1,.05,0]
16-
bell = new Sound
17-
bell.init .1, 800, env, Sound.sineWave
18-
for i in range(1,2)
19-
s1 = new Sound
20-
s1.init .2, i * 800 + 800, env, Sound.sineWave
21-
bell.mix(s1, 1 / (2 ^ i))
22-
end for
23-
for i in range(1,n)
24-
bell.play
25-
ix = 0
26-
while bell.isPlaying
27-
text.row = row
28-
ix = (ix + 1) % self.symbols.len
29-
print msg + center(self.symbols[ix],8)
30-
end while
31-
end for
32-
end function
9+
print "You are in the H&M casino,in front of one of our"
10+
print "one-arm bandits. Bet from $1 to $100."
11+
print "To pull the arm, punch the return key after making your bet."
3312

34-
Machine.makeBet = function()
35-
while true
36-
bet = floor(input("Your bet? ").val)
37-
if bet > 100 then
38-
print "House limits are $100"
39-
else if bet < 1 then
40-
print "Minimum bet is $1"
41-
else
42-
break
43-
end if
44-
end while
45-
Machine.bet = bet
46-
end function
13+
symbols = ["BAR", "BELL", "ORANGE", "LEMON", "PLUM", "CHERRY"]
4714

48-
Machine.pullHandle = function
49-
if text.row < 3 then
50-
print; print
51-
text.row = text.row + 2
15+
16+
winTriple = function(symbol, bet)
17+
if symbol == "BAR" then
18+
print "***JACKPOT***"
19+
globals.profit += 101 * bet
20+
else
21+
print "**TOP DOLLAR**"
22+
globals.profit += 11 * bet
5223
end if
53-
row = text.row
54-
msg = ""
55-
for i in range(0,2)
56-
self.reelsSpin(5 + 5 * (i==0), msg, row)
57-
wait .1
58-
symIx = floor(rnd * self.symbols.len)
59-
msg += center(self.symbols[symIx],9)
60-
self.reels[i] = symIx
61-
text.row = row
62-
print msg
63-
end for
24+
print "You won!"
6425
end function
6526

66-
Machine.winnings = function
67-
bet = Machine.bet
68-
barIdx = self.symbols.indexOf("Bar")
69-
numBars = 0
70-
multiples = 0
71-
for i in range(0,2)
72-
numBars += (self.reels[i] == barIdx)
73-
multiples += (self.reels[i] == self.reels[(i + 1) % 3])
74-
end for
75-
76-
if numBars == 3 then return {"won": bet * 101, "msg": "***Jackpot***"}
77-
if numBars == 2 then return {"won": bet * 6, "msg": "*Double Bar*"}
78-
if multiples == 3 then return {"won": bet * 11, "msg": "**Top Dollar**"}
79-
if multiples == 1 then return {"won": bet * 3, "msg": "Double!!"}
80-
return {"won": -bet, "msg": "You lost."}
27+
winDouble = function(symbol, bet)
28+
if symbol == "BAR" then
29+
print "*DOUBLE BAR*"
30+
globals.profit += 6 * bet
31+
else
32+
print "Double!"
33+
globals.profit += 3 * bet
34+
end if
35+
print "You won!"
8136
end function
8237

83-
Machine.results = function
84-
result = Machine.winnings
85-
self.money += result.won
86-
print result.msg
87-
if result.won > 0 then
88-
print "You Won!!"
89-
end if
90-
print "Your standings are $" + self.money
91-
return
92-
end function
38+
lose = function(bet)
39+
print "You lost."
40+
globals.profit -= bet
41+
end function
9342

94-
Machine.playAgain = function
95-
ans = input("Again? ") + " "
96-
self.playing = (ans[0].lower == "y")
97-
if self.playing then return
98-
print
99-
if self.money < 0 then
100-
print "Pay up! Please leave your money on the terminal."
101-
else if self.money == 0 then
102-
print "Hey, you broke even."
43+
calcWinLoss = function(spun, bet)
44+
if spun[0] == spun[1] then
45+
if spun[0] == spun[2] then
46+
winTriple spun[0], bet
47+
else
48+
winDouble spun[0], bet
49+
end if
50+
else if spun[0] == spun[2] then
51+
winDouble spun[0], bet
52+
else if spun[1] == spun[2] then
53+
winDouble spun[1], bet
10354
else
104-
print "Collect your winnings from the H&M cashier."
55+
lose bet
10556
end if
10657
end function
10758

108-
clear
109-
print " " * 30 + "Slots"
110-
print " " * 15 + "Creative Computing Morristown, New Jersey"
111-
print;print;print
112-
print "You are in the H&M Casino, in front of one of our"
113-
print "one-arm bandits. Bet from $1 to $100."
114-
print "to pull the arm, punch the return key after making your bet."
59+
ringBells = function(qty=5)
60+
// I believe all the obnoxious beeping was to slow down the game
61+
// and build suspense as each "wheel" appears. Our version:
62+
wait 0.1
63+
for i in range(1, qty)
64+
print char(7), ""
65+
wait 0.05
66+
end for
67+
end function
11568

116-
print
117-
while Machine.playing
118-
Machine.makeBet
69+
// Main program
70+
profit = 0
71+
while true
11972
print
120-
Machine.pullHandle
73+
74+
// Get bet
75+
while true
76+
bet = input("Your bet? ").val
77+
if 1 <= bet <= 100 then break
78+
if bet < 1 then print "Minimum bet is $1" else print "House limits are $100"
79+
end while
80+
81+
// Spin 3 wheels (randomly picking a symbol for each one)
82+
spun = []
83+
spun.push symbols[rnd * symbols.len]
84+
spun.push symbols[rnd * symbols.len]
85+
spun.push symbols[rnd * symbols.len]
12186
print
122-
Machine.results
123-
Machine.playAgain
87+
ringBells 10; print spun[0], " "
88+
ringBells 5; print spun[1], " "
89+
ringBells 5; print spun[2]
12490
print
91+
92+
// Calculate and display win/loss
93+
wait 0.5
94+
calcWinLoss spun, bet
95+
96+
// Show new state, and maybe play again
97+
print "Your standings are $ " + profit
98+
yn = input("Again? ").lower + " "
99+
if yn[0] != "y" then break
125100
end while
101+
102+
if profit == 0 then
103+
print "Hey, you broke even."
104+
else if profit > 0 then
105+
print "Collect your winnings from the H&M cashier."
106+
else
107+
print "Pay up! Please leave your money on the terminal."
108+
end if

00_Alternate_Languages/81_Splat/MiniScript/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ Ways to play:
66

77
1. Command-Line MiniScript:
88
Download for your system from https://miniscript.org/cmdline/, install, and then run the program with a command such as:
9-
9+
```
1010
miniscript splat.ms
11+
```
1112

1213
2. Mini Micro:
1314
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:
14-
15+
```
1516
load "splat"
1617
run
18+
```

00_Alternate_Languages/81_Splat/MiniScript/splat.ms

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ splatMsg = ["Requiescat in pace.", "May the Angel of Heaven lead you into Paradi
99
"Pushing up daisies.", "Easy come, easy go."]
1010

1111
history = []
12-
clear
12+
//clear // (works on Mini Micro only)
1313
print " " * 33 + "Splat"
1414
print " " * 15 + "Creative Computing Morristown, New Jersey"
1515
print;print;print

00_Alternate_Languages/82_Stars/MiniScript/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ Ways to play:
66

77
1. Command-Line MiniScript:
88
Download for your system from https://miniscript.org/cmdline/, install, and then run the program with a command such as:
9-
9+
```
1010
miniscript stars.ms
11+
```
1112

1213
2. Mini Micro:
1314
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:
14-
15+
```
1516
load "stars"
16-
run
17+
run
18+
```
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
2+
3+
Conversion to [MiniScript](https://miniscript.org).
4+
5+
Ways to play:
6+
7+
1. Command-Line MiniScript:
8+
Download for your system from https://miniscript.org/cmdline/, install, and then run the program with a command such as:
9+
```
10+
miniscript stockmarket.ms
11+
```
12+
13+
2. Mini Micro:
14+
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:
15+
```
16+
load "stockmarket"
17+
run
18+
```

0 commit comments

Comments
 (0)