Merge remote-tracking branch 'upstream/main'

This commit is contained in:
amjadkofahi
2023-09-20 18:31:03 +03:00
300 changed files with 18232 additions and 140 deletions
-1
View File
@@ -34,7 +34,6 @@ venv/
.DS_Store
.vs/
**/target/
Cargo.lock
**/*.rs.bk
/target
todo.md
@@ -0,0 +1,19 @@
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 aceyducey.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 "aceyducey"
run
```
@@ -0,0 +1,59 @@
print " "*26 + "Acey Ducey Card Game"
print " "*15 + "Creative Computing Morristown, New Jersey"
print
print
print "Acey-ducey is played in the following manner."
print "The dealer (computer) deals two cards face up."
print "You have an option to bet or not bet depending"
print "on whether or not you feel the card will have"
print "a value between the first two."
print "If you do not want to bet, input a 0."
cards = range(2,10) + ["Jack", "Queen", "King", "Ace"]
while true
money = 100
while true
print "You now have " + money + " dollars."
print
print "Here are your next two cards:"
while true
A = floor(rnd * cards.len)
B = floor(rnd * cards.len)
if B > A then break
end while
print cards[A]
print cards[B]
bet = input("What is your bet? ").val
while bet > money
print "Sorry, my friend, but you bet too much."
print "You have only " + money + " dollars to bet."
bet = input("What is your bet? ").val
end while
if bet == 0 then
print "Chicken!!"
continue
end if
C = floor(rnd * cards.len)
print cards[C]
if C <= A or C >= B then
print "Sorry, you lose."
money -= bet
if money <= 0 then break
else
print "You win!!!"
money += bet
end if
end while
print
print
print "Sorry, friend, but you blew your wad."
print; print
again = input("Try again (yes or no)? ").lower
if again and again[0] == "n" then break
end while
print "O.K., hope you had fun!"
@@ -0,0 +1,89 @@
import std/[random,strutils]
var
bet, cardA, cardB, cardC, stash: int
retry: bool = true
randomize() # Seed the random number generator
proc printGreeting() =
echo spaces(26),"ACEY DUCEY CARD GAME"
echo spaces(15),"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
echo """
ACEY-DUCEY IS PLAYED IN THE FOLLOWING MANNER
THE DEALER (COMPUTER) DEALS TWO CARDS FACE UP
YOU HAVE AN OPTION TO BET OR NOT BET DEPENDING
ON WHETHER OR NOT YOU FEEL THE CARD WILL HAVE
A VALUE BETWEEN THE FIRST TWO.
IF YOU DO NOT WANT TO BET, INPUT A 0
"""
proc printBalance() =
echo "YOU NOW HAVE ", stash," DOLLARS."
echo ""
proc printCard(aCard: int) =
case aCard:
of 11: echo "=== JACK ==="
of 12: echo "=== QUEEN ==="
of 13: echo "=== KING ==="
of 14: echo "=== ACE ==="
else: echo "=== ", aCard, " ==="
proc drawDealerCards() =
echo "HERE ARE YOUR NEXT TWO CARDS: "
cardA = rand 2..14
cardB = cardA # Copy cardA, so we can test cardB to be different
while cardB == cardA:
cardB = rand 2..14
if cardA > cardB: # Make sure cardA is the smaller card
swap cardA, cardB
echo ""
printCard cardA
echo ""
printCard cardB
echo ""
proc drawPlayerCard() =
cardC = rand 2..14
printCard cardC
echo ""
proc getBet(): int =
result = stash + 1 #ensure we enter the loop
while (result < 0) or (result > stash):
echo "WHAT IS YOUR BET: "
result = readLine(stdin).parseInt()
if result > stash:
echo "SORRY, MY FRIEND, BUT YOU BET TOO MUCH."
echo "YOU HAVE ONLY ", stash, " DOLLARS TO BET."
if result == 0:
echo "CHICKEN!!"
proc tryAgain(): bool =
echo "TRY AGAIN (YES OR NO)"
var answer = readLine(stdin).normalize()
result = (answer == "y") or (answer == "yes")
printGreeting()
while retry:
stash = 100
while stash > 0:
printBalance()
drawDealerCards()
bet = getBet()
echo ""
drawPlayerCard()
if (cardC >= cardA) and (cardC <= cardB):
echo "YOU WIN!!!"
stash += bet
else:
if bet > 0:
echo "SORRY, YOU LOSE"
stash -= bet
echo "SORRY, FRIEND, BUT YOU BLEW YOUR WAD."
echo ""
retry = tryAgain()
echo "O.K., HOPE YOU HAD FUN!"
@@ -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:
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 amazing.ms
```
Note that because this program imports "listUtil", you will need to have a the standard MiniScript libraries somewhere in your import path.
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 "amazing"
run
```
@@ -0,0 +1,108 @@
import "listUtil"
print " "*28 + "Amazing Program"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print; print
while true
inp = input("What and your width and length? ")
inp = inp.replace(",", " ")
fields = inp.split
h = fields[0].val; v = fields[-1].val
if h > 1 and v > 1 then break
print "Meaningless dimensions. Try again."
end while
// order: keeps track of the order in which each cell was
// visited as we built the maze. 0 means not explored yet. Indexed in [column][row] order.
// (This is W in the original BASIC program.)
order = list.init2d(h,v, 0)
// walls: keeps track of the walls below and to the right of each cell:
// 0: walls below and to the right
// 1: wall to the right
// 2: wall below
// 3: neither wall
// (This is V in the original BASIC program.)
// Note that a wall to the right can be removed from a
// valid entry by adding 2; a wall below can be removed
// by adding 1.
walls = list.init2d(h,v, 0)
print
print
print
print
// pick an exit at the top of the maze,
// and print the maze top
x = floor(rnd * h)
for i in range(0, h-1)
if i == x then print ". ","" else print ".--",""
end for
print "."
// walk from our starting position (by the exit) around
// the maze, clearing a wall on each step
c = 1 // current step number
order[x][0] = c; c += 1
r = x; s = 0 // [r][s] is our current position in the maze
while true
// collect the set of directions we can move in
dirs = []
if r > 0 and order[r-1][s] == 0 then dirs.push "left"
if s > 0 and order[r][s-1] == 0 then dirs.push "up"
if r+1 < h and order[r+1][s] == 0 then dirs.push "right"
if s+1 < v and order[r][s+1] == 0 then dirs.push "down"
if not dirs then
//print "Uh-oh, I'm stuck at " + r + "," + s
// couldn't find any directions for this cell;
// find the next already-explored cell
while true
r += 1
if r >= h then
r = 0
s += 1
if s >= v then s = 0
end if
if order[r][s] != 0 then break
end while
continue
end if
// pick a random available direction; move there,
// clearing the wall in between and updating order
d = dirs.any
if d == "left" then
walls[r-1][s] += 2
r = r-1
else if d == "up" then
walls[r][s-1] += 1
s = s-1
else if d == "right" then
walls[r][s] += 2
r = r+1
else if d == "down" then
walls[r][s] += 1
s = s+1
end if
//print "At step " + c + ", at " + r + "," + s
order[r][s] = c
c += 1
if c > h*v then break
end while
// pick an exit at the bottom of the maze
x = floor(rnd * h)
walls[x][v-1] += 1
// print the (rest of the) maze
for j in range(0, v-1)
print "I", ""
for i in range(0, h-1)
if walls[i][j] < 2 then print " I", "" else print " ", ""
end for
print
for i in range(0, h-1)
if walls[i][j] % 2 == 0 then print ":--", "" else print ": ", ""
end for
print "."
end for
@@ -0,0 +1,19 @@
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 animal.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 "animal"
run
```
@@ -0,0 +1,90 @@
print " "*32 + "Animal"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
print "Play 'Guess the Animal'"
print
print "Think of an animal and the computer will try to guess it."
print
// Ask a yes/no question, and return "Y" or "N".
getYesNo = function(prompt)
while true
inp = input(prompt + "? ").upper
if inp and (inp[0] == "Y" or inp[0] == "N") then return inp[0]
print "Please answer Yes or No."
end while
end function
// Our data is stored as a list of little maps.
// Answers have only an "answer" key.
// Questions have a "question" key, plus "ifYes" and "ifNo"
// keys which map to the index of the next question or answer.
data = [
{"question":"Does it swim", "ifYes":1, "ifNo":2},
{"answer":"fish"},
{"answer":"bird"}]
// List all known animals.
listKnown = function
print; print "Animals I already know are:"
for item in data
if item.hasIndex("answer") then print (item.answer + " "*17)[:17], ""
end for
print; print
end function
// Ask the question at curIndex, and handle the user's response.
doQuestion = function
q = data[curIndex]
if getYesNo(q.question) == "Y" then
globals.curIndex = q.ifYes
else
globals.curIndex = q.ifNo
end if
end function
// Check the answer at curIndex. If incorrect, get a new question
// to put at that point in our data.
checkAnswer = function
node = data[curIndex]
inp = getYesNo("Is it a " + node.answer)
if inp == "Y" then
print "Why not try another animal?"
else
actual = input("The animal you were thinking of was a? ").lower
print "Please type in a question that would distinguish a"
print actual + " from a " + node.answer
q = {}
q.question = input
q.question = q.question[0].upper + q.question[1:] - "?"
data[curIndex] = q
k = data.len
data.push node // old answer at index k
data.push {"answer":actual} // new answer at index k+1
if getYesNo("For a " + actual + " the answer would be") == "Y" then
data[curIndex].ifYes = k+1
data[curIndex].ifNo = k
else
data[curIndex].ifNo = k+1
data[curIndex].ifYes = k
end if
end if
end function
// Main loop. (Press Control-C to break.)
while true
while true
inp = input("Are you thinking of an animal? ").upper
if inp == "LIST" then listKnown
if inp and inp[0] == "Y" then break
end while
curIndex = 0
while true
if data[curIndex].hasIndex("question") then
doQuestion
else
checkAnswer
break
end if
end while
end while
@@ -0,0 +1,19 @@
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 awari.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 "awari"
run
```
@@ -0,0 +1,146 @@
print " "*34 + "Awari"
print " "*15 + "Creative Computing Morristown, New Jersey"
// Keep a list of the opening moves (up to 8) of previously lost or drawn games.
// These will be used to penalize repeating the same moves again.
badGames = []
printQty = function(qty)
print (" " + qty)[-2:], " "
end function
printBoard = function
print; print " ", ""
for i in range(12, 7); printQty board[i]; end for
print; printQty board[13]
print " " * 6, ""; printQty board[6]
print; print " ", ""
for i in range(0, 5); printQty board[i]; end for
print; print
end function
// Redistribute the stones starting at position.
// If the last one ends by itself, opposite some nonzero
// stones on the other side, then capture them into homePos.
// Return true if the last stone ended at homePos, false otherwise.
moveStones = function(board, position, homePos)
p = board[position]; board[position] = 0
while p
position = (position + 1) % 14
board[position] += 1
p -= 1
end while
if board[position] == 1 and position != 6 and position != 13 and board[12-position] then
board[homePos] += board[12-position] + 1
board[position] = 0
board[12-position] = 0
end if
globals.gameOver = board[0:6].sum == 0 or board[7:13].sum == 0
return position == homePos
end function
// Get the player move. Note that the player inputs their move as a number
// from 1-6, but we return it as an actual board position index 0-6.
getPlayerMove = function(prompt="Your move")
while true
pos = input(prompt + "? ").val
if 0 < pos < 7 and board[pos-1] then return pos - 1
print "Illegal move."
end while
end function
getComputerMove = function
// Copy the board for safekeeping
boardCopy = board[:]
bestScore = -99; bestMove = 0
for j in range(7, 12)
if board[j] == 0 then continue // can't move from an empty spot
// suppose we move at position j...
moveStones board, j, 13
// consider each possible response the player could make
bestPlayerScore = 0
for i in range(0, 5)
if board[i] == 0 then continue
landPos = board[i] + i // figure the landing position
score = floor(landPos / 14); landPos %= 14
if board[landPos] == 0 and landPos != 6 and landPos != 13 then
score += board[12 - landPos] // points for capturing stones
end if
if score > bestPlayerScore then bestPlayerScore = score
end for
// figure our own score as our points, minus player points, minus best player score
ourScore = board[13] - board[6] - bestPlayerScore
if gameMoves.len < 8 then
// subtract 2 points if current series of moves is in our bad-games list
proposed = gameMoves + [j]
for badGame in badGames
if badGame[:proposed.len] == proposed then ourScore -= 2
end for
end if
if ourScore > bestScore then
bestScore = ourScore
bestMove = j
end if
// restore the board
globals.board = boardCopy[:]
end for
print char(42+bestMove) // (labels computer spots as 1-6 from right to left)
return bestMove
end function
// The game is over when either side has 0 stones left.
isGameOver = function
return board[0:6].sum == 0 or board[7:13].sum == 0
end function
// Play one game to completion.
playOneGame = function
// The board is represented as a list of 13 numbers.
// Position 6 is the player's home; 13 is the computer's home.
globals.board = [3]*14; board[13] = 0; board[6] = 0
// Also keep a list of the moves in the current game
globals.gameMoves = []
print; print
while true
// Player's turn
printBoard
pos = getPlayerMove
gameMoves.push pos
if moveStones(board, pos, 6) then
if gameOver then break
printBoard
pos = getPlayerMove("Again")
gameMoves.push pos
moveStones board, pos, 6
end if
if gameOver then break
// Computer's turn
printBoard; print "My move is ", ""
pos = getComputerMove
gameMoves.push pos
if moveStones(board, pos, 13) then
if gameOver then break
printBoard; print "...followed by ", ""
pos = getComputerMove
gameMoves.push pos
moveStones board, pos, 13
end if
if gameOver then break
end while
printBoard
print; print "GAME OVER"
delta = board[6] - board[13]
if delta < 0 then
print "I win by " + (-delta) + " points"
return
end if
if delta == 0 then print "Drawn game" else print "You win by " + delta + " points"
if gameMoves.len > 8 then gameMoves = gameMoves[:8]
if badGames.indexOf(gameMoves) == null then badGames.push gameMoves
end function
// Main loop
while true
playOneGame
print; print
end while
@@ -0,0 +1,19 @@
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 bagels.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 "bagels"
run
```
@@ -0,0 +1,83 @@
print " "*33 + "BAGELS"
print " "*15 + "Creative Computing Morristown, New Jersey"; print; print
// *** BAGELS Number Guessing Game
// *** Original source unknown but suspected to be
// *** Lawrence Hall of Science, U.C. Berkely
print; print; print
inp = input("Would you like the rules (yes or no)? ")
if not inp or inp[0].lower != "n" then
print; print "I am thinking of a three-digit number. Try to guess"
print "my number and I will give you clues as follows:"
print " PICO - one digit correct but in the wrong position"
print " FERMI - one digit correct and in the right position"
print " BAGELS - no digits correct"
end if
pickNumber = function
// pick three unique random digits
while true
actual = [floor(10*rnd), floor(10*rnd), floor(10*rnd)]
if actual[0] != actual[1] and actual[0] != actual[2] and actual[1] != actual[2] then break
end while
//print "DEBUG: actual=" + actual
print; print "O.K. I have a number in mind."
return actual
end function
getGuess = function(guessNum)
isNotDigit = function(c); return c < "0" or c > "9"; end function
while true
inp = input("Guess #" + guessNum + "? ")
if inp.len != 3 then
print "Try guessing a three-digit number."
else if inp[0] == inp[1] or inp[0] == inp[2] or inp[1] == inp[2] then
print "Oh, I forgot to tell you that the number I have in mind"
print "has no two digits the same."
else if isNotDigit(inp[0]) or isNotDigit(inp[1]) or isNotDigit(inp[2]) then
print "What?"
else
return [inp[0].val, inp[1].val, inp[2].val]
end if
end while
end function
doOneGame = function
actual = pickNumber
for guessNum in range(1, 20)
guess = getGuess(guessNum)
picos = 0; fermis = 0
for i in [0,1,2]
if guess[i] == actual[i] then
fermis += 1
else if actual.indexOf(guess[i]) != null then
picos += 1
end if
end for
if fermis == 3 then
print "YOU GOT IT!!!"
globals.score += 1
return
else if picos or fermis then
print "PICO " * picos + "FERMI " * fermis
else
print "BAGELS"
end if
end for
print "Oh well."
print "That's twenty guesses. My number was " + actual.join("")
end function
// main loop
score = 0
while true
doOneGame
print
inp = input("Play again (yes or no)? ")
if not inp or inp[0].upper != "Y" then break
end while
if score then
print; print "A " + score + " point BAGELS buff!!"
end if
print "Hope you had fun. Bye."
@@ -0,0 +1,97 @@
import std/[random,strutils]
# BAGLES NUMBER GUESSING GAME
# ORIGINAL SOURCE UNKNOWN BUT SUSPECTED TO BE
# LAWRENCE HALL OF SCIENCE, U.C. BERKELY
var
a, b: array[1..3, int]
wincount: int = 0
prompt: string
stillplaying: bool = true
randomize() # Seed the random number generator
# Seed 3 unique random numbers; indicate if they're all unique
proc genSeed(): bool =
for i in 1..3:
a[i] = rand(0..9)
if (a[1] == a[2]) or (a[2] == a[3]) or (a[3] == a[1]):
return false
return true
# Primary game logic
proc playGame() =
var youwin, unique: bool = false
# We want 3 unique random numbers: loop until we get them!
while unique == false:
unique = genSeed()
echo "O.K. I HAVE A NUMBER IN MIND."
for i in 1..20:
var c, d: int = 0
echo "GUESS #", i
prompt = readLine(stdin).normalize()
if (prompt.len() != 3):
echo "TRY GUESSING A THREE-DIGIT NUMBER."
continue
for z in 1..3:
b[z] = prompt.substr(z-1, z-1).parseInt() # Convert string digits to array ints
if (b[1] == b[2]) or (b[2] == b[3]) or (b[3] == b[1]):
echo "OH, I FORGOT TO TELL YOU THAT THE NUMBER I HAVE IN MIND"
echo "HAS NO TWO DIGITS THE SAME."
# Figure out the PICOs
if (a[1] == b[2]): c += 1
if (a[1] == b[3]): c += 1
if (a[2] == b[1]): c += 1
if (a[2] == b[3]): c += 1
if (a[3] == b[1]): c += 1
if (a[3] == b[2]): c += 1
# Determine FERMIs
for j in 1..3:
if (a[j] == b[j]): d += 1
# Reveal clues
if (d != 3):
if (c != 0):
for j in 1..c:
echo "PICO"
if (d != 0):
for j in 1..d:
echo "FERMI"
if (c == 0) and (d == 0):
echo "BAGELS"
# If we have 3 FERMIs, we win!
else:
echo "YOU GOT IT!!!"
echo ""
wincount += 1
youwin = true
break
# Only invoke if we've tried 20 guesses without winning
if not youwin:
echo "OH WELL."
echo "THAT'S TWENTY GUESSES. MY NUMBER WAS ", a[1], a[2], a[3]
# main program
echo spaces(33), "BAGELS"
echo spaces(15), "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
echo "\n\n"
echo "WOULD YOU LIKE THE RULES (YES OR NO)"
prompt = readLine(stdin).normalize()
if prompt.substr(0, 0) == "y":
echo "I AM THINKING OF A THREE-DIGIT NUMBER. TRY TO GUESS"
echo "MY NUMBER AND I WILL GIVE YOU CLUES AS FOLLOWS:"
echo " PICO - ONE DIGIT CORRECT BUT IN THE WRONG POSITION"
echo " FERMI - ONE DIGIT CORRECT AND IN THE RIGHT POSITION"
echo " BAGELS - NO DIGITS CORRECT"
echo ""
while(stillplaying == true):
playGame()
echo "PLAY AGAIN (YES OR NO)"
prompt = readLine(stdin).normalize()
if prompt.substr(0, 0) != "y":
stillplaying = false
if wincount > 0:
echo ""
echo "A ", wincount, " POINT BAGELS BUFF!!"
echo ""
echo "HOPE YOU HAD FUN. BYE."
@@ -0,0 +1,19 @@
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 banner.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 "banner"
run
```
@@ -0,0 +1,89 @@
blockWidth = input("Horizontal? ").val
if blockWidth <= 1 then blockWidth = 3
blockHeight = input("Vertical? ").val
if blockHeight <= 1 then blockHeight = 5
inp = input("Centered? ").upper
centered = inp and inp[0] > "P"
printChar = input("Character (type 'all' if you want character being printed)? ")
statement = input("Statement: ").upper
//input("Set page") // <-- opportunity to set your pin-feed printer before proceeding!
// Define the character data. For each character, we have 7 numbers
// which are the 9-bit binary representation of each row, plus one.
data = {}
data[" "] = [0,0,0,0,0,0,0]
data["!"] = [1,1,1,384,1,1,1]
data["?"] = [5,3,2,354,18,11,5]
data["."] = [1,1,129,449,129,1,1]
data["*"] = [69,41,17,512,17,41,69]
data["="] = [41,41,41,41,41,41,41]
data["0"] = [57,69,131,258,131,69,57]
data["1"] = [0,0,261,259,512,257,257]
data["2"] = [261,387,322,290,274,267,261]
data["3"] = [66,130,258,274,266,150,100]
data["4"] = [33,49,41,37,35,512,33]
data["5"] = [160,274,274,274,274,274,226]
data["6"] = [194,291,293,297,305,289,193]
data["7"] = [258,130,66,34,18,10,8]
data["8"] = [69,171,274,274,274,171,69]
data["9"] = [263,138,74,42,26,10,7]
data["A"] = [505,37,35,34,35,37,505]
data["B"] = [512,274,274,274,274,274,239]
data["C"] = [125,131,258,258,258,131,69]
data["D"] = [512,258,258,258,258,131,125]
data["E"] = [512,274,274,274,274,258,258]
data["F"] = [512,18,18,18,18,2,2]
data["G"] = [125,131,258,258,290,163,101]
data["H"] = [512,17,17,17,17,17,512]
data["I"] = [258,258,258,512,258,258,258]
data["J"] = [65,129,257,257,257,129,128]
data["K"] = [512,17,17,41,69,131,258]
data["L"] = [512,257,257,257,257,257,257]
data["M"] = [512,7,13,25,13,7,512]
data["N"] = [512,7,9,17,33,193,512]
data["O"] = [125,131,258,258,258,131,125]
data["P"] = [512,18,18,18,18,18,15]
data["Q"] = [125,131,258,258,322,131,381]
data["R"] = [512,18,18,50,82,146,271]
data["S"] = [69,139,274,274,274,163,69]
data["T"] = [2,2,2,512,2,2,2]
data["U"] = [128,129,257,257,257,129,128]
data["V"] = [64,65,129,257,129,65,64]
data["W"] = [256,257,129,65,129,257,256]
data["X"] = [388,69,41,17,41,69,388]
data["Y"] = [8,9,17,481,17,9,8]
data["Z"] = [386,322,290,274,266,262,260]
for c in statement
if not data.hasIndex(c) then continue
// Print character c in giant sideways banner-style!
for datum in data[c]
if datum then datum -= 1 // remove spurious +1
if printChar.upper != "ALL" then c = printChar
for lineRepeat in range(blockWidth-1)
if centered then print " " * (34 - 4.5*blockHeight), ""
for bitPos in range(9,0)
if bitAnd(datum, 2^bitPos) then charToPrint=c else charToPrint=" "
print charToPrint * blockHeight, ""
end for // next bitPos
print
wait 0.01 // put in a small pause so it's not too fast to see!
end for // next lineRepeat (repeating line according to entered Y value)
end for // next datum (row of this character)
// Add a little space after each character
for i in range(1, 2 * blockWidth)
print
wait 0.01
end for
end for // next character in the message
@@ -0,0 +1,19 @@
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 basketball.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 "basketball"
run
```
@@ -0,0 +1,299 @@
print " "*31 + "Basketball"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
print "This is Dartmouth College basketball. You will be Dartmouth"
print " captain and playmaker. Call shots as follows: 1. Long"
print " (30 ft.) jump shot; 2. Short (15 ft.) jump shot; 3. Lay"
print " up; 4. Set shot."
print "Both teams will use the same defense. Call defense as"
print "follows: 6. Press; 6.5 Man-to-Man; 7. Zone; 7.5 None."
print "To change defense, just type 0 as your next shot."
inputDefense = function(prompt)
while true
globals.defense = input(prompt).val
if defense >= 6 then break
end while
end function
// Do the center jump; return US or THEM who gets the ball.
centerJump = function
print "Center Jump"
if rnd < 0.6 then
print opponent + " controls the tap."
return THEM
else
print "Dartmouth controls the tap."
return US
end if
end function
inputShot = function
while true
globals.shotType = input("Your shot (0-4): ")
if shotType == "0" then
inputDefense "Your new defensive alignment is? "
continue
end if
globals.shotType = shotType.val
if 1 <= shotType <= 4 then return
end while
end function
endFirstHalf = function
print " ***** End of first half *****"; print
print "Score: Dartmouth: " + score[US] + " " + opponent + ": " + score[THEM]
print; print
globals.inControl = centerJump
end function
checkGameOver = function
print
if score[0] != score[1] then
print " ***** END OF GAME *****"
print "Final score: Dartmouth: " + score[US] + " " + opponent + ": " + score[THEM]
print
return true
else
print " ***** End of Second Half *****"
print "Score at end of regulation time:"
print " Dartmouth: " + score[US] + " " + opponent + ": " + score[THEM]
print
print "Begin two minute overtime period"
return false
end if
end function
scoreBasket = function(who = null)
if who == null then who = inControl
score[who] += 2
printScore
end function
printScore = function
print "Score: " + score[1] + " to " + score[0]
print "Time: " + timer
end function
// Logic for a Dartmouth jump shot. Return true to continue as Dartmouth,
// false to pass the ball to the opponent.
dartmouthJumpShot = function
if rnd <= 0.341 * defense / 8 then
print "Shot is good."
scoreBasket
return false
end if
if rnd < 0.682 * defense / 8 then
print "Shot is off target."
if defense/6 * rnd > 0.45 then
print "Rebound to " + opponent
return false
end if
print "Dartmouth controls the rebound."
if rnd <= 0.4 then
globals.shotType = 3 + (rnd > 0.5)
return true
end if
if defense == 6 and rnd < 0.6 then
print "Pass stolen by " + opponent + ", easy layup."
scoreBasket THEM
return true
end if
print "Ball passed back to you."
return true
end if
if rnd < 0.782 * defense/8 then
print "Shot is blocked. Ball controlled by ", ""
if rnd > 0.5 then
print opponent + "."
return false
else
print "Dartmouth."
return true
end if
end if
if rnd > 0.843 * defense/8 then
print "Charging foul. Dartmouth loses ball."
else
print "Shooter is fouled. Two shots."
doFoulShots US
end if
return false
end function
// Logic for an opponent jump shot. Return true to continue as opponent,
// false to pass the ball to Dartmouth.
opponentJumpShot = function
if rnd <= 0.35 * defense / 8 then
print "Shot is good."
scoreBasket
return false
end if
if 8 / defense * rnd <= 0.75 then
print "Shot is off rim."
return opponentMissed
end if
if 8 / defense * rnd <= 0.9 then
print "Player fouled. Two shots."
doFoulShots THEM
return false
end if
print "Offensive foul. Dartmouth's ball."
return false
end function
// Do a Dartmouth set shot or lay-up. Return true to continue as Dartmouth,
// false to pass the ball to the opponent.
dartmouthSetOrLay = function
if 7 / defense * rnd <= 0.4 then
print "Shot is good. Two points."
scoreBasket
else if 7 / defense * rnd <= 0.7 then
print "Shot is off the rim."
if rnd < 0.667 then
print opponent + " controls the rebound."
return false
end if
print "Dartmouth controls the rebound."
if rnd < 0.4 then return true
print "Ball passed back to you."
return true
else if 7 / defense * rnd < 0.875 then
print "Shooter fouled. Two shots."
doFoulShots US
else if 7 / defense * rnd < 0.925 then
print "Shot blocked. " + opponent + "'s ball."
else
print "Charging foul. Dartmouth loses the ball."
end if
return false
end function
// Do an opponent set shot or lay-up. Return true to continue as opponent,
// false to pass the ball to Dartmouth.
opponentSetOrLay = function
if 7 / defense * rnd <= 0.413 then
print "Shot is missed."
return opponentMissed
else
print "Shot is good."
scoreBasket
return false
end if
end function
// Handle opponent missing a shot -- return true to continue as opponent,
// false to pass the ball to Dartmouth.
opponentMissed = function
if defense / 6 * rnd <= 0.5 then
print "Dartmouth controls the rebound."
return false
else
print opponent + " controls the rebound."
if defense == 6 and rnd <= 0.75 then
print "Ball stolen. Easy lay up for Dartmouth."
scoreBasket US
return true
end if
if rnd <= 0.5 then
print "Pass back to " + opponent + " guard."
return true
end if
globals.shotType = 4 - (rnd > 0.5)
return true
end if
end function
playOneSide = function
print
while true
globals.timer += 1
if timer == 50 then return endFirstHalf
if time == 92 then
print " *** Two minutes left in the game ***"; print
end if
if shotType == 1 or shotType == 2 then
print "Jump Shot"
if inControl == US then
if dartmouthJumpShot then continue else break
else
if opponentJumpShot then continue else break
end if
else // (if shot type >= 3)
if shotType > 3 then print "Set shot." else print "Lay up."
if inControl == US then
if dartmouthSetOrLay then continue else break
else
if opponentSetOrLay then continue else break
end if
end if
end while
globals.inControl = 1 - globals.inControl
end function
doFoulShots = function(who)
if rnd > 0.49 then
if rnd > 0.75 then
print "Both shots missed."
else
print "Shooter makes one shot and misses one."
score[who] += 1
end if
else
print "Shooter makes both shots."
score[who] += 2
end if
printScore
end function
opponentPlay = function
print
while true
globals.timer += 1
if timer == 50 then return endFirstHalf
if time == 92 then
print " *** Two minutes left in the game ***"; print
end if
if shotType == 1 or shotType == 2 then
print "Jump Shot"
if opponentJumpShot then continue else break
else // (if shot type >= 3)
if shotType > 3 then print "Set shot." else print "Lay up."
if opponentSetOrLay then continue else break
end if
end while
globals.inControl = US
end function
// Constants
THEM = 0
US = 1
// Main program
inputDefense "Your starting defense will be? "
print
opponent = input("Choose your opponent? ")
score = [0,0] // score for each team (US and THEM)
gameOver = false
inControl = centerJump
timer = 0
while not gameOver
print
if inControl == US then
inputShot
playOneSide
else
shotType = ceil(10 / 4 * rnd + 1)
playOneSide
end if
if timer >= 100 then
if checkGameOver then break
timer = 93
dartmouthHasBall = centerJump
end if
end while
@@ -0,0 +1,19 @@
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 batnum.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 "batnum"
run
```
@@ -0,0 +1,109 @@
print " "*33 + "Batnum"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
print "This program is a 'Battle of Numbers' game, where the"
print "computer is your opponent."
print
print "The game starts with an assumed pile of objects. You"
print "and your opponent alternately remove objects from the pile."
print "Winning is defined in advance as taking the last object or"
print "not. You can also specify some other beginning conditions."
print "Don't use zero, however, in playing the game."
print "Enter a negative number for new pile size to stop playing."
print
options = {}
getOptions = function
while true
options.pileSize = input("Enter pile size? ").val
if options.pileSize != 0 and options.pileSize == floor(options.pileSize) then break
end while
if options.pileSize < 0 then return
while true
winOption = input("Enter win option - 1 to take last, 2 to avoid last: ")
if winOption == "1" or winOption == "2" then break
end while
options.takeLast = (winOption == "1")
while true
minMax = input("Enter min and max? ").replace(",", " ").split
if minMax.len < 2 then continue
options.minTake = minMax[0].val
options.maxTake = minMax[-1].val
if options.minTake >= 1 and options.minTake < options.maxTake then break
end while
while true
startOpt = input("Enter start option - 1 computer first, 2 you first: ")
if startOpt == "1" or startOpt == "2" then break
end while
options.computerFirst = (startOpt == "1")
end function
computerTurn = function
// Random computer play (not in original program):
take = options.minTake + floor(rnd * (options.maxTake - options.minTake))
// Proper (smart) computer play
q = pile
if not options.takeLast then q -= 1
take = q % (options.minTake + options.maxTake)
if take < options.minTake then take = options.minTake
if take > options.maxTake then take = options.maxTake
if take >= pile then
if options.takeLast then
print "Computer takes " + pile + " and wins."
else
print "Computer takes " + pile + " and loses."
end if
globals.gameOver = true
else
globals.pile -= take
print "Computer takes " + take + " and leaves " + pile
end if
end function
playerTurn = function
while true
print; take = input("Your move? ").val
if take == 0 then
print "I told you not to use zero! Computer wins by forfeit."
globals.gameOver = true
return
end if
if options.minTake <= take <= options.maxTake and take <= pile then break
print "Illegal move, reenter it"
end while
if take >= pile then
if options.takeLast then
print "Congratulations, you win."
else
print "Tough luck, you lose."
end if
globals.gameOver = true
else
globals.pile -= take
//print "You take " + take + ", leaving " + pile // (not in original program)
end if
end function
while true
getOptions
if options.pileSize < 0 then break
pile = options.pileSize
gameOver = false
print; print
if options.computerFirst then computerTurn
while not gameOver
playerTurn
if gameOver then break
computerTurn
end while
for i in range(1,10); print; end for
end while
print "OK, bye!"
@@ -0,0 +1,21 @@
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
Conversion to [MiniScript](https://miniscript.org).
NOTE: One feature has been added to the original game. At the "??" prompt, instead of entering coordinates, you can enter "?" (a question mark) to reprint the fleet disposition code.
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 battle.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 "battle"
run
```
@@ -0,0 +1,157 @@
print " "*33 + "Battle"
print " "*15 + "Creative Computing Morristown, New Jersey"
// -- BATTLE WRITTEN BY RAY WESTERGARD 10/70
// COPYRIGHT 1971 BY THE REGENTS OF THE UNIV. OF CALIF.
// PRODUCED AT THE LAWRENCE HALL OF SCIENCE, BERKELEY
// Converted to MiniScript by Joe Strout, July 2023.
import "listUtil"
setup = function
// prepare the shield with the bad guys' ships
globals.field = list.init2d(6,6, 0) // matrix of enemy ships -- 0th row/column unused
for shipType in [1,2,3]
for ship in [1,2]
while not addShip(shipType, ship)
// keep trying until we successfully add it!
end while
end for
end for
// prepare another matrix to keep track of where we have hit
globals.hits = list.init2d(6,6, 0)
// and some some info per ship (ID) and ship type
globals.shipHitsLeft = [null, 2, 2, 3, 3, 4, 4] // hits left till each ship is sunk
globals.sunkPerType = [0] * 3 // counts how many of each type were sunk
// finally, keep track of hits and splashes
globals.splashCount = 0
globals.hitCount = 0
end function
// Try to add the given ship to field.
// Return true on success, false on failure.
addShip = function(shipType, shipNum)
size = 5 - shipType
x = floor(rnd * 6)
y = floor(rnd * 6)
direction = floor(rnd * 4)
if direction == 0 then
dx = 1; dy = 0
else if direction == 1 then
dx = 1; dy = 1
else if direction == 2 then
dx = 0; dy = 1
else
dx = -1; dy = 1
end if
// First make sure our placement doesn't go out of bounds
if not (0 <= x + dx * size <= 5) then return false
if not (0 <= y + dy * size <= 5) then return false
// Then, make sure it's not blocked by another ship
for i in range(0, size-1)
px = x + dx * i // (point under consideration)
py = y + dy * i
// make sure where we want to place the ship is still empty
if field[px][py] then return false
// if placing a ship diagonally, don't allow it to cross
// another ship on the other diagonal
if i > 0 and dx and dy then
adjacent1 = field[px-dx][py]
adjacent2 = field[px][py-dy]
if adjacent1 and adjacent1 == adjacent2 then return false
end if
end for
// Looks like it's all clear, so fill it in!
id = 9 - 2 * shipType - shipNum;
for i in range(0, size-1)
field[x + dx * i][y + dy * i] = id
end for
return true
end function
// Print the "encoded" fleet disposition. This is just the regular field,
// but rotated and flipped.
printField = function
print
print "The following code of the bad guys' fleet disposition"
print "has been captured but not decoded:"
print
for i in range(0,5)
for j in range(0,5)
print field[5-j][i], " "
end for
print
end for
end function
doOneTurn = function
while true
xy = input("??").replace(",", " ")
if xy == "?" then; printField; continue; end if // (not in original game)
x = xy[0].val; y = xy[-1].val
if xy.len < 2 or x != floor(x) or x < 1 or x > 6 or y != floor(y) or y < 1 or y > 6 then
print "Invalid input. Try again."
continue
end if
break
end while
row = x - 1 // (minus one since our matrix is 0-based instead of 1-based)
col = y - 1
shipId = field[row][col]
if shipId == 0 then
// fall through to 'end if' below
else if shipHitsLeft[shipId] == 0 then
print "There used to be a ship at that point, but you sank it."
else if hits[row][col] then
print "You already put a hole in ship number " + shipId + " at that point."
else
hits[row][col] = shipId
print "A direct hit on ship number " + shipId
globals.hitCount += 1
shipHitsLeft[shipId] -= 1
if shipHitsLeft[shipId] == 0 then
shipType = floor((shipId-1) / 2) // get ship type, 0-2
sunkPerType[shipType] += 1
print "And you sunk it. Hurray for the good guys."
print "So far, the bad guys have lost"
print sunkPerType[0] + " destroyer(s), " + sunkPerType[1] +
" cruiser(s), and " + sunkPerType[2] + " aircraft carrier(s)."
print "Your current splash/hit ratio is " + (splashCount / hitCount)
end if
return
end if
print "Splash! Try again."
globals.splashCount += 1
end function
playOneGame = function
setup
printField
print
print "De-code it and use it if you can"
print "but keep the de-coding method a secret."
print
print "START GAME"
while true
doOneTurn
if sunkPerType.sum == 6 then break
end while
print
print "You have totally wiped out the bad guys' fleet"
print "with a final splash/hit ratio of " + (splashCount / hitCount)
if splashCount == 0 then
print "Congratulations -- a direct hit every time."
end if
end function
// Main loop
while true
playOneGame
print
print "****************************"
print
end while
@@ -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:
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 blackjack.ms
```
But note that the current release (1.2.1) of command-line MiniScript does not properly flush the output buffer when line breaks are suppressed, as this program does when prompting for your next action after a Hit. So, method 2 (below) is recommended for now.
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 "blackjack"
run
```
@@ -0,0 +1,285 @@
import "listUtil"
print " "*31 + "Black Jack"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
fna = function(q); return q - 11*(q >= 22); end function
hands = [[]]*15 // hands(i,j) is the jth card in hand i (P)
handValue = [0]*15 // total value of each hand (Q)
deck = [] // the deck being dealt from (C)
playerMoney = [0]*8 // total $ for each player (T)
roundWinnings = [0]*7 // total $ won/lost this hand for each player (S)
betPerHand = [0]*15 // bet for each hand (B)
cardNames = " A 2 3 4 5 6 7 8 9 10 J Q K".split
reshuffle = function
print "Reshuffling"
globals.deck = range(1,13)*4
deck.shuffle
end function
// Function to draw a card from the deck (reshuffling if needed)
getCard = function
if not deck then reshuffle
return deck.pop
end function
// Function to get a name for the given card, preceded by "a" or "an"
a = function(cardNum)
article = "a" + "n" * (cardNum == 1 or cardNum == 8)
return article + " " + cardNames[cardNum]
end function
// Function to evaluate the given hand. Total is usually put into
// handValue(handNum). Totals have the following meaning:
// 2-10...Hard 2-10
// 11-21...Soft 11-21
// 22-32...Hard 11-21
// 33+ or -1...Busted
evalHand = function(handNum)
result = 0
for card in hands[handNum]
result = addCardToTotal(result, card)
end for
return result
end function
// Function to add a card into a total hand value.
addCardToTotal = function(total, card)
if total < 0 then return total // (already busted)
x1 = card; if x1 > 10 then x1 = 10
q1 = total + x1
if total < 11 then
if card == 1 then return total + 11 // (ace)
return q1 + 11 * (q1 >= 11)
end if
total = q1 + (total <= 21 and q1 > 21)
if total >= 33 then total = -1
return total
end function
// Print one of those totals as it should appear to the user.
displayTotal = function(total)
return total - 11 * (total >= 22)
end function
// Get a yes/no response from the user
getYesNo = function(prompt)
while true
inp = input(prompt).upper
if inp and (inp[0] == "Y" or inp[0] == "N") then return inp[0]
end while
end function
// Get a number, within a given range, from the user
getNumber = function(prompt, minVal=0, maxVal=500)
while true
result = input(prompt).val
if result == floor(result) and minVal <= result <= maxVal then return result
print "Please enter a number from " + minVal + " to " + maxVal
end while
end function
// Get one of a list of one-letter (uppercase) options.
getOption = function(prompt, options)
while true
result = input(prompt).upper
if result and options.indexOf(result[0]) != null then return result[0]
print "Type " + options[:-1].join(", ") + " or " + options[-1] + " please"
end while
end function
getBets = function
print "Bets:"
for i in range(0, numPlayers-1)
betPerHand[i] = getNumber("# " + (i+1) + "? ", 1, 500)
end for
end function
playOneRound = function
globals.roundWinnings = [0] * numPlayers
if deck.len < (numPlayers+1) * 2 then reshuffle
getBets
print "PLAYER ", ""
for i in range(0, numPlayers-1)
print i+1, " "
hands[i] = []
end for
print "DEALER"
hands[numPlayers] = []
for row in [1,2]
print " ", ""
for i in range(0, numPlayers)
hands[i].push getCard
if row == 1 or i < numPlayers then
print " " + (cardNames[hands[i][-1]] + " ")[:2], " "
end if
end for
print
end for
dealerCard0 = hands[numPlayers][0]
dealerCard1 = hands[numPlayers][1]
// Test for insurance
if dealerCard0 == 1 and getYesNo("Any insurance? ") == "Y" then
print "Insurance Bets"
for i in range(0, numPlayers-1)
insurance = getNumber("# " + (i+1) + "? ", 0, betPerHand[i]/2)
roundWinnings[i] = insurance * (3 * (dealerCard1 >= 10) - 1)
end for
end if
// Test for dealer blackjack
if (dealerCard0==1 and dealerCard1 > 9) or
(dealerCard0 > 9 and dealerCard1==1) then
print; print "Dealer has " + a(dealerCard1) + " in the hole for Blackjack"
for i in range(0, numPlayers)
handValue[i] = evalHand(i)
end for
else
// no dealer blackjack
if dealerCard0 == 1 or dealerCard0 >= 10 then
print; print "No dealer Blackjack."
end if
// now play the hands
for i in range(0, numPlayers-1)
playHand i
end for
handValue[numPlayers] = evalHand(numPlayers) // (evaluate dealer hand)
// Test for playing the dealer's hand... we only do so if
// there are any player hands with cards left.
anyLeft = false
for i in range(0, numPlayers-1)
if hands[i] or hands[i+8] then anyLeft = true
end for
if not anyLeft then
print "Dealer had " + a(hands[numPlayers][1]) + " concealed."
else
// Play dealer's hand.
dispTotal = displayTotal(handValue[numPlayers])
print "Dealer has " + a(hands[numPlayers][1]) + " concealed" +
" for a total of " + dispTotal + "."
while handValue[numPlayers] > 0 and dispTotal <= 16
card = getCard
if hands[numPlayers].len == 2 then print "Draws ", ""
print cardNames[card], " "
hands[numPlayers].push card
handValue[numPlayers] = evalHand(numPlayers)
dispTotal = displayTotal(handValue[numPlayers])
end while
if hands[numPlayers].len > 2 then
if handValue[numPlayers] < 0 then print " ---Busted" else print " ---Total is " + dispTotal
end if
print
end if
end if
tallyResults
end function
playHand = function(handNum, prompt=null, allowSplit=true)
if not prompt then prompt = "Player " + (handNum % 8 + 1)
while hands[handNum]
options = ["H", "S", "D"] + ["/"] * allowSplit
choice = getOption(prompt + "? ", options)
if choice == "S" then // player wants to stand
handValue[handNum] = evalHand(handNum)
if handValue[handNum] == 21 and hands[handNum].len == 2 then
print "Blackjack"
roundWinnings[handNum] += 1.5 * betPerHand[handNum]
betPerHand[handNum] = 0
discardHand handNum
else
print "Total is " + displayTotal(handValue[handNum])
end if
break
else if choice == "D" or choice == "H" then // hit or double down
handValue[handNum] = evalHand(handNum)
if choice == "D" then betPerHand[handNum] *= 2
card = getCard
print "Received " + a(card), " "
hands[handNum].push card
handValue[handNum] = evalHand(handNum)
if handValue[handNum] < 0 then
print "...Busted"
discardHand handNum
roundWinnings[handNum] = -betPerHand[handNum]
betPerHand[handNum] = 0
end if
prompt = "Hit"
if choice == "D" then; print; break; end if
else if choice == "/" then // split
card1 = hands[handNum][0]; if card1 > 10 then card1 = 10
card2 = hands[handNum][1]; if card2 > 10 then card2 = 10
if card1 != card2 then
print "Splitting not allowed."
continue
end if
hand2 = handNum + 8
hands[hand2] = [hands[handNum].pop]
betPerHand[hand2] = betPerHand[handNum]
card = getCard
print "First hand receives " + a(card)
hands[handNum].push card
card = getCard
print "Second hand receives " + a(card)
hands[hand2].push card
if card1 != 1 then
// Now play the two hands
playHand handNum, "Hand 1", false
playHand hand2, "Hand 2", false
end if
break
end if
allowSplit = false
end while
end function
discardHand = function(handNum)
hands[handNum] = []
handValue[handNum] = 0
end function
tallyResults = function
dealerTotal = displayTotal(evalHand(numPlayers))
for i in range(0, numPlayers-1)
playerHandATotal = displayTotal(evalHand(i))
playerHandBTotal = displayTotal(evalHand(i+8))
// calculate roundWinnings[i], which is the $ won/lost for player i
roundWinnings[i] = roundWinnings[i] + betPerHand[i]*sign(playerHandATotal - dealerTotal) + betPerHand[i+8]*sign(playerHandBTotal - dealerTotal)
betPerHand[i+8] = 0
s = "Player " + (i+1) + " "
s += ["loses", "pushes", "wins"][sign(roundWinnings[i])+1]
if roundWinnings[i] != 0 then s += " " + abs(roundWinnings[i])
playerMoney[i] += roundWinnings[i]
playerMoney[numPlayers] -= roundWinnings[i]
s = (s + " "*25)[:25] + "Total = " + playerMoney[i]
print s
discardHand i
discardHand i+8
end for
print "Dealer's total = " + playerMoney[numPlayers]
print
end function
// Main program starts here
if getYesNo("Do you want instructions? ") == "Y" then
print "This is the game of 21. As many as 7 players may play the"
print "game. On each deal, bets will be asked for, and the"
print "players' bets should be typed in. The cards will then be"
print "dealt, and each player in turn plays his hand. The"
print "first response should be either 'D', indicating that the"
print "player is doubling down, 'S', indicating that he is"
print "standing, 'H', indicating he wants another card, or '/',"
print "indicating that he wants to split his cards. After the"
print "initial response, all further responses should be 'S' or"
print "'H', unless the cards were split, in which case doubling"
print "down is again permitted. In order to collect for"
print "blackjack, the initial response should be 'S'."
print
end if
numPlayers = getNumber("Number of players? ", 1, 7)
print
// main loop!
while true
playOneRound
end while
@@ -0,0 +1,19 @@
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 bombardment.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 "bombardment"
run
```
@@ -0,0 +1,101 @@
print " "*33 + "Bombardment"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
print "You are on a battlefield with 4 platoons and you"
print "have 25 outposts available where they may be placed."
print "You can only place one platoon at any one outpost."
print "The computer does the same with its four platoons."
print
print "The object of the game is to fire missiles at the"
print "outposts of the computer. It will do the same to you."
print "The one who destroys all four of the enemy's platoons"
print "first is the winner."
print
print "Good luck... and tell us where you want the bodies sent!"
print
input "(Press Return.)" // (so user can read the above)
print
print "Tear off matrix and use it to check off the numbers."
for i in range(1,5); print; end for
memory = [] // records computer's guesses
for row in range(1,5)
for i in range(row*5-4, row*5)
print (" " + i)[-6:], ""
end for
print
end for
print
// Define a helper function to pick a random position (1-25)
// that is not already in the given list.
pickOutpost = function(excludingThese)
while true
pick = floor(rnd * 25) + 1
if excludingThese.indexOf(pick) == null then return pick
end while
end function
// Choose the computer's four positions.
computerOutposts = []
for i in range(1,4)
computerOutposts.push pickOutpost(computerOutposts)
end for
playerOutposts = []
while playerOutposts.len != 4
inp = input("What are your four positions? ")
inp = inp.replace(", ", " ").replace(",", " ")
inp = inp.split
for pos in inp
pos = pos.val
playerOutposts.push pos
if pos < 1 or pos > 25 then playerOutposts=[]
end for
end while
// Main loop.
while true
// player's attack
pos = input("Where do you wish to fire your missile? ").val
if computerOutposts.indexOf(pos) == null then
print "Ha, ha you missed. My turn now:"
else
print "You got one of my outposts!"
computerOutposts.remove computerOutposts.indexOf(pos)
left = computerOutposts.len
if left == 3 then
print "One down, three to go."
else if left == 2 then
print "Two down, two to go."
else if left == 3 then
print "Three down, one to go."
else
print "You got me, I'm going fast. ButI'll get you when"
print "My transisto&s recup%ra*e!"
break
end if
end if
// computer's attack
pos = pickOutpost(memory)
memory.push pos
if playerOutposts.indexOf(pos) == null then
print "I missed you, you dirty rat. I picked " + pos + ". Your turn:"
else
playerOutposts.remove playerOutposts.indexOf(pos)
left = playerOutposts.len
if left == 0 then
print "You're dead. Your last outpost was at " + pos + ". Ha, ha, ha."
print "Better luck next time."
break
end if
print "I got you. It won't be long now. Post " + pos + " was hit."
if left == 3 then
print "You have only three outposts left."
else if left == 2 then
print "You have only two outposts left."
else if left == 1 then
print "You have only one outpost left."
end if
end if
end while
@@ -0,0 +1,19 @@
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 bombsaway.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 "bombsaway"
run
```
@@ -0,0 +1,112 @@
getNum = function(prompt, maxVal=5)
while true
num = floor(input(prompt + "? ").val)
if num > 0 and num <= maxVal then return num
print "Try again..."
end while
end function
showReturn = function
print "You made it through tremendous flak!!"
end function
showShotDown = function
print "* * * * boom * * * *"
print "You have been shot down....."
print "Dearly beloved, we are gathered here today to pay our"
print "last tribute..."
end function
showSuccess = function
print "Direct hit!!!! " + floor(100*rnd) + " killed."
print "Mission successful."
end function
// Function to calculate the mission result for all nations except Japan.
doNonJapanResult = function
print
d = input("How many missions have you flown? ").val
while d >= 160
print "Missions, not miles..."
print "150 missions is high even for old-timers."
d = input("Now then, how many missions have you flown? ").val
end while
print
if d >= 100 then print "That's pushing the odds!"
if d < 25 then print "Fresh out of training, eh?"
print
if d >= 160 * rnd then
showSuccess
else
print "Missed target by " + floor(2+30*rnd) + " miles!"
print "Now you're really in for it !!"; print
r = getNum("Does the enemy have guns(1), missiles(2), or both(3)")
print
if r != 2 then
s = input("What's the percent hit rate of enemy gunners (10 to 50)? ").val
if s<10 then
print "You lie, but you'll pay..."
showShotDown
return
end if
end if
print
print
if r > 1 then t = 35 else t = 0
if s + t > 100 * rnd then
showShotDown
else
showReturn
end if
end if
end function
s = 0 // hit rate of enemy gunners
r = 0 // whether enemy has guns(1), missiles(2), or both(3)
// Main Loop
while true
print "You are a pilot in a World War II bomber."
a = getNum("What side -- Italy(1), Allies(2), Japan(3), Germany(4)", 4)
if a == 1 then // Italy
b = getNum("Your target -- Albania(1), Greece(2), North Africa(3)")
print
print ["Should be easy -- you're flying a nazi-made plane.",
"Be careful!!!", "You're going for the oil, eh?"][b-1]
doNonJapanResult
else if a == 2 then // Allies
g = getNum("Aircraft -- Liberator(1), B-29(2), B-17(3), Lancaster(4)", 4)
print ["You've got 2 tons of bombs flying for Ploesti.",
"You're dumping the A-bomb on Hiroshima.",
"You're chasing the Aismark in the North Sea.",
"You're busting a German heavy water plant in the Ruhr."][g-1]
doNonJapanResult
else if a == 3 then // Japan (different logic than all others)
print "You're flying a kamikaze mission over the USS Lexington."
isFirst = input("Your first kamikaze mission(y or n)? ").lower
if isFirst and isFirst[0] == "n" then
s = 0
showReturn
else
print
if rnd > 0.65 then showSuccess else showShotDown
end if
else // Germany
m = getNum("A nazi, eh? Oh well. Are you going for Russia(1)," +
char(13) + "England(2), or France(3)")
print ["You're nearing Stalingrad.",
"Nearing London. Be careful, they've got radar.",
"Nearing Versailles. Duck soup. They're nearly defenseless."][m-1]
doNonJapanResult
end if
print; print; print; another = input("Another mission (y or n)? ").lower
if not another or another[0] != "y" then
print "Chicken !!!" ; print ; break
end if
end while
@@ -0,0 +1,19 @@
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 bounce.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 "bounce"
run
```
@@ -0,0 +1,55 @@
print " "*33 + "Bounce"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
t = [0]*21
print "This simulation lets you specify the initial velocity"
print "of a ball thrown straight up, and the coefficient of"
print "elasticity of the ball. Please use a decimal fraction"
print "coefficiency (less than 1)."
print
print "You also specify the time increment to be used in"
print "'strobing' the ball's flight (try .1 initially)."
print
addToLine = function(line, tabPos, textToAdd)
return line + " " * (floor(tabPos) - line.len) + textToAdd
end function
while true
s2 = input("Time increment (sec)? ").val
print
v = input("Velocity (fps)? ").val
print
c = input("Coefficient? ").val
print
print "feet"
print
s1 = floor(70/(v/(16*s2)))
for i in range(1, s1)
t[i]=v*c^(i-1)/16
end for
for h in range(floor(-16*(v/32)^2+v^2/32+.5), 0, -0.5)
line = ""
if floor(h)==h then line = str(h)
l=0
for i in range(1, s1)
for time in range(0, t[i], s2)
l=l+s2
if abs(h-(.5*(-32)*time^2+v*c^(i-1)*time))<=.25 then
line = addToLine(line, l/s2, "0")
end if
end for
time = t[i+1]/2
if -16*time^2+v*c^(i-1)*time < h then break
end for
print line
end for
print " " + "." * floor((l+1)/s2+1)
line = " 0"
for i in range(1, l+.9995)
line = addToLine(line, i/s2, i)
end for
print line
print " " * floor((l+1)/(2*s2)-2) + "seconds"
print
end while
@@ -0,0 +1,19 @@
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 bowling.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 "bowling"
run
```
@@ -0,0 +1,138 @@
import "listUtil"
print " "*34 + "Bowl"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
pinDown = [0]*10 // state of each pin: 1=down, 0=standing
player = 1
frame = 1
ball = 1
scores = list.init3d(10, 4, 3, 0) // index by [frame][player][ball], all 0-based
printInstructions = function
print "The game of bowling takes mind and skill. During the game"
print "the computer will keep score. You may compete with"
print "other players [up to four]. You will be playing ten frames."
print "On the pin diagram 'O' means the pin is down...'+' means the"
print "pin is standing. After the game the computer will show your"
print "scores."
end function
printPinDiagram = function
print "Player: " + (player+1) + " Frame: " + (frame+1) + " Ball: " + (ball+1)
print
k = 0
for row in range (0, 3)
line = " " * row
for j in range(1, 4-row)
line += "+O"[pinDown[k]] + " "
k += 1
end for
print line
end for
end function
printAnalysis = function(previousDown=0)
pinsLeft = 10 - pinDown.sum
if pinDown.sum == previousDown then print "Gutter!!"
if ball == 0 and pinsLeft == 0 then
print "Strike!!!!!" + char(7)*4
globals.status = 3
else if ball == 1 and pinsLeft == 0 then
print "Spare!!!!"
globals.status = 2
else if ball == 1 and pinsLeft > 0 then
print "Error!!!" // (i.e., didn't clear all the pins in 2 balls)
globals.status = 1
end if
end function
rollOneBall = function
print "Type roll to get the ball going."
input // (response ignored)
for i in range(1, 20)
// Generate a random number from 0-99, then take this mod 15.
// This gives us a slightly higher chance of hitting a non-existent
// pin than one of the actual 10.
x = floor(rnd*100)
if x % 15 < 10 then pinDown[x % 15] = 1
end for
printPinDiagram
end function
doOneFrame = function
globals.pinDown = [0]*10
globals.ball = 0
rollOneBall
printAnalysis
hitOnBall0 = pinDown.sum
scores[frame][player][ball] = hitOnBall0
globals.ball = 1
if hitOnBall0 < 10 then
print "Roll your 2nd ball"
print
rollOneBall
printAnalysis hitOnBall0
end if
// Note: scoring in this program is not like real bowling.
// It just stores the number of pins down at the end of each ball,
// and a status code (1, 2, or 3).
scores[frame][player][ball] = pinDown.sum
scores[frame][player][2] = status
end function
pad = function(n, width=3)
return (" "*width + n)[-width:]
end function
printFinalScores = function
print "FRAMES"
for i in range(1,10)
print pad(i), ""
end for
print
for player in range(0, numPlayers-1)
for i in range(0, 2)
for frame in range(0, 9)
print pad(scores[frame][player][i]), ""
end for
print
end for
print
end for
end function
playOneGame = function
for f in range(0, 9)
globals.frame = f
for p in range(0, numPlayers-1)
globals.player = p
doOneFrame
end for
end for
print
printFinalScores
end function
// Main program
print "Welcome to the alley"
print "Bring your friends"
print "Okay let's first get acquainted"
print
ans = input("The instructions (Y/N)? ").upper
if not ans or ans[0] != "N" then printInstructions
while true
numPlayers = input("First of all...How many are playing? ").val
if 0 < numPlayers < 5 then break
print "Please enter a number from 1 to 4."
end while
print
print "Very good..."
while true
playOneGame
print
ans = input("Do you want another game? ").upper
if not ans or ans[0] != "Y" then break
end while
@@ -0,0 +1,19 @@
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 boxing.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 "boxing"
run
```
@@ -0,0 +1,174 @@
print " "*33 + "Boxing"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
print "Boxing Olympic Style (3 Rounds -- 2 out of 3 Wins)"
playerWins = 0
opponentWins = 0
print
opponentName = input("What is your opponent's name? ")
playerName = input("Input your man's name? ")
print "Different punches are: (1) full swing; (2) hook; (3) uppercut; (4) jab."
playerBest = input("What is your man's best? ").val
playerWeakness = input("What is his vulnerability? " ).val
while true
opponentBest = floor(4 * rnd + 1)
opponentWeakness = floor(4 * rnd + 1)
if opponentBest != opponentWeakness then break
end while
print opponentName + "'s advantage is " + opponentBest + " and vulnerability is secret."
print
playerConnects = function
print "He connects!"
if playerPoints > 35 then
print opponentName + " is knocked cold and " + playerName + " is the winner and champ!"
globals.done = true
return
end if
globals.playerPoints += 15
end function
doPlayerPunch = function
p = input(playerName + "'s punch? ").val
if p == playerBest then globals.playerPoints += 2
if p == 1 then // Full Swing
print playerName + " swings and ", ""
if opponentWeakness == 4 then // (probably a bug in original code)
playerConnects
else
x3 = floor(30 * rnd+1)
if x3 < 10 then
playerConnects
else
print "he misses "
if playerPoints != 1 then
print
print
end if
end if
end if
else if p == 2 then // Hook
print playerName + " gives the hook... ", ""
if opponentWeakness == 2 then
globals.playerPoints += 7
else
h1 = floor(2 * rnd + 1)
if h1 == 1 then
print "But it's blocked!!!!!!!!!!!!!"
else
print "Connects..."
globals.playerPoints += 7
end if
end if
else if p == 3 then // Uppercut
print playerName + " tries an uppercut ", ""
if opponentWeakness == 3 or floor(100 * rnd + 1) < 51 then
print "and he connects!"
globals.playerPoints += 4
else
print "and it's blocked (lucky block!)"
end if
else // Jab
print playerName + " jabs at " + opponentName + "'s head ", ""
if opponentWeakness != 4 and floor(8 * rnd + 1) >= 4 then
print "It's blocked."
else
globals.playerPoints += 3
end if
end if
end function
playerKnockedOut = function
print playerName + " is knocked cold and " + opponentName + " is the winner and champ!"
globals.done = true
end function
doOpponentPunch = function
j7 = floor(4 * rnd + 1)
if j7 == playerBest then globals.opponentPoints += 2
if j7 == 1 then // Full swing
print opponentName + " takes a full swing and ", ""
if playerWeakness == 1 or floor(60 * rnd + 1) < 30 then
print "POW!!!!! He hits him right in the face!"
if opponentPoints > 35 then
playerKnockedOut
else
globals.opponentPoints += 15
end if
else
print "it's blocked!"
end if
end if
if j7 == 2 then // Hook
print opponentName + " gets " + playerName + " in the jaw (ouch!)"
globals.playerPoints += 7
print "....and again!"
globals.playerPoints += 5
if opponentPoints > 35 then
playerKnockedOut
return
end if
print
// continue below as if an Uppercut (probably a bug in the original code)
end if
if j7 == 2 or j7 == 3 then // Uppercut, or Hook
print playerName + " is attacked by an uppercut (oh,oh)..."
if playerWeakness == 3 or floor(200*rnd+1) <= 75 then
print "and " + opponentName + " connects..."
globals.opponentPoints += 8
else
print " blocks and hits " + opponentName + " with a hook."
globals.playerPoints += 5
end if
end if
if j7 == 4 then // Jab
print opponentName + " jabs and ", ""
if playerWeakness == 4 or floor(7 * rnd + 1) > 4 then
print "blood spills !!!"
globals.opponentPoints += 5
else
print "It's blocked!"
end if
end if
end function
playOneRound = function
globals.playerPoints = 0
globals.opponentPoints = 0
print "Round " + round + " begins..."
for r1 in range(1, 7)
i = floor(10 * rnd + 1)
if i <= 5 then
doPlayerPunch
else
doOpponentPunch
end if
if done then return
end for // next R1 (sub-round)
if playerPoints > opponentPoints then
print; print playerName + " wins round " + round
globals.playerWins += 1
else
print; print opponentName + " wins round " + round
globals.opponentWins += 1
end if
end function
done = false
for round in range(1,3)
playOneRound
if done then break
if opponentWins >= 2 then
print opponentName + " wins (nice going, " + opponentName + ")."
break
else if playerWins >= 2 then
print playerName + " amazingly wins!!"
break
end if
end for // next round
print
print
print "and now goodbye from the Olympic arena."
print
@@ -0,0 +1,19 @@
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 bug.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 "bug"
run
```
@@ -0,0 +1,192 @@
print " "*34 + "Bug"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
print "The game Bug"
print "I hope you enjoy this game."
print
ans = input("Do you want instructions? ").lower
if not ans or ans[0] != "n" then
print "The object of bug is to finish your bug before i finish"
print "mine. Each number stands for a part of the bug body."
print "I will roll the die for you, tell you what i rolled for you"
print "what the number stands for, and if you can get the part."
print "If you can get the part I will give it to you."
print "The same will happen on my turn."
print "If there is a change in either bug I will give you the"
print "option of seeing the pictures of the bugs."
print "Ihe numbers stand for parts as follows:"
print "Number Part Number of part needed"
print "1 body 1"
print "2 neck 1"
print "3 head 1"
print "4 feelers 2"
print "5 tail 1"
print "6 legs 6"
print
input "(Press Return.)" // (wait before starting the game)
print
end if
// define a class to represent a bug (with all its body parts)
Bug = {}
Bug.body = false
Bug.neck = false
Bug.head = false
Bug.feelers = 0
Bug.tail = false
Bug.legs = 0
Bug.feelerLetter = "F"
Bug.pronoun = "I"
// add a method to determine if the bug is complete
Bug.complete = function
return self.tail and self.feelers >= 2 and self.legs >= 6
end function
// add a method to draw the bug using print
Bug.draw = function
if self.feelers then
for row in range(1,4)
print " "*10 + (self.feelerLetter + " ") * self.feelers
end for
end if
if self.head then
print " HHHHHHH"
print " H H"
print " H O O H"
print " H H"
print " H V H"
print " HHHHHHH"
end if
if self.neck then
print " N N"
print " N N"
end if
if self.body then
print " BBBBBBBBBBBB"
print " B B"
print " B B"
if self.tail then print "TTTTTB B"
print " BBBBBBBBBBBB"
end if
if self.legs then
for row in [1,2]
print " "*5 + "L " * self.legs
end for
end if
end function
// add a method to add a part, if possible; return true if bug changed
Bug.addPart = function(partNum)
if partNum == 1 then
print "1=Body"
if self.body then
print self.pronoun + " do not need a body."
else
print self.pronoun + " now have a body."
self.body = true
return true
end if
else if partNum == 2 then
print "2=neck"
if self.neck then
print self.pronoun + " do not need a neck."
else if not self.body then
print self.pronoun + " do not have a body."
else
print self.pronoun + " now have a neck."
self.neck = true
return true
end if
else if partNum == 3 then
print "3=head"
if self.head then
print self.pronoun + " have a head."
else if not self.neck then
print self.pronoun + " do not have a neck."
else
print self.pronoun + " needed a head."
self.head = true
return true
end if
else if partNum == 4 then
print "4=feelers"
if self.feelers >= 2 then
print self.pronoun + " have two feelers already."
else if not self.head then
print self.pronoun + " do not have a head."
else
if self.pronoun == "You" then
print "I now give you a feeler."
else
print "I get a feeler."
end if
self.feelers += 1
return true
end if
else if partNum == 5 then
print "5=tail"
if self.tail then
print self.pronoun + " already have a tail."
else if not self.body then
print self.pronoun + " do not have a body."
else
if self.pronoun == "You" then
print "I now give you a tail."
else
print "I now have a tail."
end if
self.tail = true
return true
end if
else if partNum == 6 then
print "6=legs"
if self.legs >= 6 then
print self.pronoun + " have 6 feet."
else if not self.body then
print self.pronoun + " do not have a body."
else
self.legs += 1
print self.pronoun + " now have " + self.legs + " leg" + "s"*(self.legs>1) + "."
return true
end if
end if
return 0
end function
// ...then, instantiate a bug for You (human player) and Me (computer)
you = new Bug
you.feelerLetter = "A" // (don't ask me why)
you.pronoun = "You"
me = new Bug
// Main loop
while not you.complete and not me.complete
anyChange = false
die = floor(6 * rnd + 1)
print; print "You rolled a " + die
if you.addPart(die) then anyChange = true
wait 2
die = floor(6 * rnd + 1)
print; print "I rolled a " + die
if me.addPart(die) then anyChange = true
if you.complete then print "Your bug is finished."
if me.complete then print "My bug is finished."
if anyChange then
ans = input("Do you want the pictures? ").lower
if not ans or ans[0] != "n" then
print "*****Your Bug*****"
print; print
you.draw
wait 2
print
print "*****My Bug*****"
print; print
me.draw
wait 2
end if
end if
end while
print "I hope you enjoyed the game, play it again soon!!"
@@ -0,0 +1,19 @@
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 bull.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 "bull"
run
```
@@ -0,0 +1,188 @@
print " "*34 + "Bull"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
getYesNo = function(prompt)
while true
ans = input(prompt + "? ").lower
if ans and (ans[0] == "y" or ans[0] == "n") then return ans[0]
print "Incorrect answer - - please type 'yes' or 'no'."
end while
end function
if getYesNo("Do you want instructions") == "y" then
print "Hello, all you bloodlovers and aficionados."
print "Here is your big chance to kill a bull."
print
print "On each pass of the bull, you may try"
print "0 - Veronica (dangerous inside move of the cape)"
print "1 - Less dangerous outside move of the cape"
print "2 - Ordinary swirl of the cape."
print
print "Instead of the above, you may try to kill the bull"
print "on any turn: 4 (over the horns), 5 (in the chest)."
print "But if I were you,"
print "I wouldn't try it before the seventh pass."
print
print "The crowd will determine what award you deserve"
print "(posthumously if necessary)."
print "The braver you are, the better the award you receive."
print
print "The better the job the picadores and toreadores do,"
print "the better your chances are."
print; input "(Press return.)"
end if
print; print
bravery = 1
outcome = 1
qualities = [null, "superb", "good", "fair", "poor", "awful"]
// Select a bull (level 1-5, lower numbers are tougher)
bullLevel = floor(rnd*5+1)
print "You have drawn a " + qualities[bullLevel] + " bull."
if bullLevel > 4 then print "You're lucky."
if bullLevel < 2 then print "Good luck. You'll need it."
print
// Simulate one of the preliminary types of bullfighters
// (picodores or toreadores). Return their effect, 0.1 - 0.5.
simPreliminary = function(fighterType)
effect = 0.1
temp = 3 / bullLevel * rnd
if temp < 0.87 then effect = 0.2
if temp < 0.63 then effect = 0.3
if temp < 0.5 then effect = 0.4
if temp < 0.37 then effect = 0.5
t = floor(10 * effect + 0.2) // (get quality in range 1 - 5)
print "The " + fighterType + " did a " + qualities[t] + " job."
if t == 5 then
if fighterType == "picadores" then
print floor(rnd*2+1) + " of the horses of the picadores killed."
end if
print floor(rnd*2+1) + " of the " + fighterType + " killed."
else if t == 4 then
if rnd > 0.5 then
print "One of the " + fighterType + " killed."
else
print "No " + fighterType + " were killed."
end if
end if
print
return effect
end function
picaEffect = simPreliminary("picadores")
toreEffect = simPreliminary("toreadores")
getGored = function
while not done
if rnd > 0.5 then
print "You are dead."
globals.bravery = 1.5
globals.done = true
else
print "You are still alive."; print
if getYesNo("Do you run from the ring") == "y" then
print "Coward"
globals.bravery = 0
globals.done = true
else
print "You are brave. Stupid, but brave."
if rnd > 0.5 then
globals.bravery = 2
break
else
print "You are gored again!"
end if
end if
end if
end while
end function
pass = 0
courage = 1 // cumulative effect of cape choices
bravery = 1 // set mainly by outcomes after getting gored
victory = false // true if we kill the bull
done = false
while not done
pass += 1
print
print "Pass number " + pass
if pass < 3 then
print "The bull is charging at you! You are the matador--"
tryKill = (getYesNo("do you want to kill the bull") == "y")
else
tryKill = (getYesNo("Here comes the bull. Try for a kill") == "y")
end if
if tryKill then
print; print "It is the moment of truth."; print
h = input("How do you try to kill the bull? " ).val
if h != 4 and h != 5 then
print "You panicked. The bull gored you."
getGored
break
end if
k = (6-bullLevel) * 10 * rnd / ((picaEffect + toreEffect) * 5 * pass)
if h == 4 then
victory = (k <= 0.8)
else
victory = (k <= 0.2)
end if
if victory then
print "You killed the bull!"
else
print "The bull has gored you!"
getGored
end if
done = true
else
if pass < 3 then
capeMove = input("What move do you make with the cape? ").val
else
capeMove = input("Cape move? ").val
end if
while capeMove < 0 or capeMove > 2 or capeMove != floor(capeMove)
print "Don't panic, you idiot! Put down a correct number"
capeMove = input.val
end while
m = [3, 2, 0.5][capeMove]
courage += m
f = (6-bullLevel+m/10)*rnd / ((picaEffect+toreEffect+pass/10)*5)
if f >= 0.51 then
print "The bull has gored you!"
getGored
end if
end if
end while
// Final outcome
if bravery == 0 then
print "The crowd boos for ten minutes. If you ever dare to show"
print "your face in a ring again, they swear they will kill you--"
print "unless the bull does first."
else
fnd = (4.5+courage/6-(picaEffect+toreEffect)*2.5+4*bravery+2*(victory+1)-pass^2/120-bullLevel)
fnc = function; return fnd * rnd; end function
if bravery == 2 then
print "The crowd cheers wildly!"
else if victory then
print "The crowd cheers!"; print
end if
print "The crowd awards you"
if fnc < 2.4 then
print "nothing at all."
else if fnc < 4.9 then
print "one ear of the bull."
else if fnc < 7.4 then
print "Both ears of the bull!"
print "Ole!"
else
print "Ole! You are 'Muy Hombre!"" Ole! Ole!"
end if
end if
print
print "Adios"; print; print; print
@@ -0,0 +1,22 @@
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 bullseye.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 bullseye.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 "bullseye"
run
```
@@ -0,0 +1,59 @@
print " "*32 + "Bullseye"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
print "In this game, up to 20 players throw darts at a target"
print "with 10, 20, 30, and 40 point zones. the objective is"
print "to get 200 points."; print
print "throw description probable score"
print " 1 fast overarm bullseye or complete miss"
print " 2 controlled overarm 10, 20 or 30 points"
print " 3 underarm anything";print
names = []
n = input("How many players? ").val; print
for i in range(0, n-1)
names.push input("Name of player #" + (i+1) + "? ")
end for
scores = [0] * n
round = 0
while true
round += 1; print; print "round " + round; print "---------"
for i in range(0, n-1)
while true
print; t = input(names[i] + "'s throw? ").val
if 1 <= t <= 3 then break
print "Input 1, 2, or 3!"
end while
if t == 1 then
p1=.65; p2=.55; p3=.5; p4=.5
else if t == 2 then
p1=.99; p2=.77; p3=.43; p4=.01
else
p1=.95; p2=.75; p3=.45; p4=.05
end if
u = rnd
if u>=p1 then
print "Bullseye!! 40 points!"; b=40
else if u>=p2 then
print "30-point zone!"; b=30
else if u>=p3 then
print "20-point zone"; b=20
else if u>=p4 then
print "Whew! 10 points."; b=10
else
print "Missed the target! too bad."; b=0
end if
scores[i] += b; print "Total score = " + scores[i]
end for
winners = []
for i in range(0, n-1)
if scores[i] >= 200 then winners.push i
end for
if winners then break
end while
print; print "We have a winner!!"; print
for i in winners; print names[i] + " scored " + scores[i] + " points."; end for
print; print "Thanks for the game."
@@ -0,0 +1,22 @@
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 bunny.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 bunny.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 "bunny"
run
```
@@ -0,0 +1,43 @@
print " "*33 + "Bunny"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
data = []
data += [1,2,-1,0,2,45,50,-1,0,5,43,52,-1,0,7,41,52,-1]
data += [1,9,37,50,-1,2,11,36,50,-1,3,13,34,49,-1,4,14,32,48,-1]
data += [5,15,31,47,-1,6,16,30,45,-1,7,17,29,44,-1,8,19,28,43,-1]
data += [9,20,27,41,-1,10,21,26,40,-1,11,22,25,38,-1,12,22,24,36,-1]
data += [13,34,-1,14,33,-1,15,31,-1,17,29,-1,18,27,-1]
data += [19,26,-1,16,28,-1,13,30,-1,11,31,-1,10,32,-1]
data += [8,33,-1,7,34,-1,6,13,16,34,-1,5,12,16,35,-1]
data += [4,12,16,35,-1,3,12,15,35,-1,2,35,-1,1,35,-1]
data += [2,34,-1,3,34,-1,4,33,-1,6,33,-1,10,32,34,34,-1]
data += [14,17,19,25,28,31,35,35,-1,15,19,23,30,36,36,-1]
data += [14,18,21,21,24,30,37,37,-1,13,18,23,29,33,38,-1]
data += [12,29,31,33,-1,11,13,17,17,19,19,22,22,24,31,-1]
data += [10,11,17,18,22,22,24,24,29,29,-1]
data += [22,23,26,29,-1,27,29,-1,28,29,-1,4096]
string.pad = function(w)
return self + " " * (w - self.len)
end function
for i in range(5); print; end for
line = ""
while true
x = data.pull
if x > 128 then break
if x >= 0 then
line = line.pad(x)
y = data.pull
for i in range(x, y)
line += "BUNNY"[i % 5]
end for
else
print line
line = ""
wait 0.1 // optional delay to make printing more visible
end if
end while
@@ -0,0 +1,22 @@
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 bunny.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 bunny.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 "bunny"
run
```
@@ -0,0 +1,38 @@
print " "*26 + "Buzzword Generator"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
print "This program prints highly acceptable phrases in"
print "'educator-speak' that you can work into reports"
print "and speeches. Whenever a question mark is printed,"
print "type a 'y' for another phrase or 'n' to quit."
words1 = ["ability","basal","behavioral","child-centered",
"differentiated","discovery","flexible","heterogeneous",
"homogeneous","manipulative","modular","tavistock",
"individualized"]
words2 = ["learning", "evaluative","objective",
"cognitive","enrichment","scheduling","humanistic",
"integrated","non-graded","training","vertical age",
"motivational","creative"]
words3 = ["grouping","modification",
"accountability","process","core curriculum","algorithm",
"performance","reinforcement","open classroom","resource",
"structure","facility","environment"]
list.any = function
return self[self.len * rnd]
end function
print; print; print "Here's the first phrase:"
while true
print [words1.any, words2.any, words3.any].join
print
yn = input("?").lower
if yn != "y" then break
end while
print "Come back when you need help with another report!"
@@ -0,0 +1,34 @@
import std/[random,strutils]
randomize()
const
words1 = ["ABILITY","BASAL","BEHAVIORAL","CHILD-CENTERED","DIFFERENTIATED","DISCOVERY","FLEXIBLE",
"HETEROGENEOUS","HOMOGENEOUS","MANIPULATIVE","MODULAR","TAVISTOCK","INDIVIDUALIZED"]
words2 = ["LEARNING","EVALUATIVE","OBJECTIVE","COGNITIVE","ENRICHMENT","SCHEDULING","HUMANISTIC",
"INTEGRATED","NON-GRADED","TRAINING","VERTICAL AGE","MOTIVATIONAL","CREATIVE"]
words3 = ["GROUPING","MODIFICATION","ACCOUNTABILITY","PROCESS","CORE CURRICULUM","ALGORITHM", "PERFORMANCE",
"REINFORCEMENT","OPEN CLASSROOM","RESOURCE","STRUCTURE","FACILITY","ENVIRONMENT"]
var
stillplaying: bool = true
prompt: string
echo spaces(26), "BUZZWORD GENERATOR"
echo spaces(15), "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
echo "\n"
echo "THIS PROGRAM PRINTS HIGHLY ACCEPTABLE PHRASES IN"
echo "'EDUCATOR-SPEAK' THAT YOU CAN WORK INTO REPORTS"
echo "AND SPEECHES. AFTER EACH PHRASE, HIT 'ENTER' FOR"
echo "ANOTHER PHRASE, OR TYPE 'N' TO QUIT."
echo "\n"
echo "HERE'S THE FIRST PHRASE..."
while stillplaying:
echo ""
echo words1[rand(0..12)], " ", words2[rand(0..12)], " ", words3[rand(0..12)]
prompt = readLine(stdin).normalize()
if prompt.substr(0, 0) == "n":
stillplaying = false
echo "COME BACK WHEN YOU NEED HELP WITH ANOTHER REPORT!"
@@ -0,0 +1,19 @@
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 calendar.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 "calendar"
run
```
@@ -0,0 +1,89 @@
import "stringUtil"
print " "*32 + "Calendar"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
startingDOW = 0
leapYear = false
// Note: while the original program required changes to the code to configure
// it for the current year, in this port we choose to ask the user.
// Here's the function to do that.
getParameters = function
days = "sunday monday tuesday wednesday thursday friday saturday".split
globals.startingDOW = 999
while startingDOW == 999
ans = input("What is the first day of the week of the year? ").lower
if not ans then continue
for i in days.indexes
if days[i].startsWith(ans) then
globals.startingDOW = -i
break
end if
end for
end while
while true
ans = input("Is it a leap year? ").lower
if ans and (ans[0] == "y" or ans[0] == "n") then break
end while
globals.leapYear = (ans[0] == "y")
while true
ans = input("Pause after each month? ").lower
if ans and (ans[0] == "y" or ans[0] == "n") then break
end while
globals.pause = (ans[0] == "y")
end function
getParameters
monthNames = [
" JANUARY ",
" FEBRUARY",
" MARCH ",
" APRIL ",
" MAY ",
" JUNE ",
" JULY ",
" AUGUST ",
"SEPTEMBER",
" OCTOBER ",
" NOVEMBER",
" DECEMBER",
]
monthDays = [31, 28 + leapYear, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
// Function to print one month calendar.
// month: numeric month number, 0-based (0-11)
printMonth = function(month)
daysSoFar = monthDays[:month].sum
daysLeft = monthDays[month:].sum
print "** " + str(daysSoFar).pad(4) + "*"*18 + " " + monthNames[month] +
" " + "*"*18 + " " + str(daysLeft).pad(4) + "**"
print
print " S M T W T F S"
print
print "*" * 61
// calculate the day of the week, from 0=Sunday to 6=Saturday
dow = (daysSoFar - startingDOW) % 7
print " " * 5 + " " * (8*dow), ""
for i in range(1, monthDays[month])
print str(i).pad(8), ""
dow += 1
if dow == 7 then
dow = 0
print
if i == monthDays[month] then break
print; print " " * 5, ""
end if
end for
print
end function
// Main loop.
for month in range(0, 11)
printMonth month
print
if month < 11 and pause then input
end for
@@ -0,0 +1,22 @@
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 change.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 change.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 "change"
run
```
@@ -0,0 +1,57 @@
print " "*33 + "Change"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
print "I, your friendly microcomputer, will determine"
print "the correct change for items costing up to $100."
print; print
while true
itemCost = input("Cost of item? ").val
if itemCost == 0 then break
payment = input("Amount of payment? ").val
change = payment - itemCost
if change < 0 then
print "Sorry, you have short-changed me $" + (itemCost - payment)
continue
else if change == 0 then
print "Correct amount, thank you."
continue
end if
print "Your change, $" + change
dollars = floor(change/10)
if dollars then print dollars + " ten dollar bill(s)"
change -= dollars * 10
fivers = floor(change/5)
if fivers then print fivers + " five dollar bill(s)"
change -= fivers * 5
ones = floor(change)
if ones then print ones + " one dollar bill(s)"
change -= ones
change *= 100 // (now working in cents)
halfs = floor(change / 50)
if halfs then print halfs + " one half dollar(s)"
change -= halfs * 50
quarters = floor(change / 25)
if quarters then print quarters + " quarter(s)"
change -= quarters * 25
dimes = floor(change / 10)
if dimes then print dimes + " dime(s)"
change -= dimes * 10
nickels = floor(change / 5)
if nickels then print nickels + " nickel(s)"
change -= nickels * 5
pennies = round(change)
if pennies then print pennies + " penny(s)"
print "Thank you, come again."
print; print
end while
@@ -0,0 +1,19 @@
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 checkers.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 "checkers"
run
```
@@ -0,0 +1,243 @@
print " "*32 + "Checkers"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
print "This is the game of Checkers. The computer is X,"
print "and you are O. The computer will move first."
print "Squares are referred to by a coordinate system."
print "(0,0) is the lower left corner"
print "(0,7) is the upper left corner"
print "(7,0) is the lower right corner"
print "(7,7) is the upper right corner"
print "The computer will type '+TO' when you have another"
print "jump. Type two negative numbers if you cannot jump."
print; print; print
input "(Press Return.)"; print // (give player a chance to read)
// The board. Pieces are represented by numeric values:
// - 0 = empty square
// - -1,-2 = computer (X) (-1 for regular piece, -2 for king)
// - 1,2 = human (O) (1 for regular piece, 2 for king)
// Board is indexed by [x][y], so we have to initialize it sideways:
board = [
[ 1, 0, 1, 0, 0, 0, -1, 0],
[ 0, 1, 0, 0, 0, -1, 0, -1],
[ 1, 0, 1, 0, 0, 0, -1, 0],
[ 0, 1, 0, 0, 0, -1, 0, -1],
[ 1, 0, 1, 0, 0, 0, -1, 0],
[ 0, 1, 0, 0, 0, -1, 0, -1],
[ 1, 0, 1, 0, 0, 0, -1, 0],
[ 0, 1, 0, 0, 0, -1, 0, -1]]
// Function to print the board
printBoard = function
for y in range(7, 0)
for x in range(0, 7)
// We print by indexing with the board entry (-2 to 2) into a list
// of possible representations. Remember that in MiniScript, a
// negative index counts from the end.
print [". ", "O ", "O*", "X*", "X "][board[x][y]], " "
end for
print; print
end for
end function
// Function to get x,y coordinates from the player.
// This is written to allow the two numbers to be
// separated by any combination of ',' and ' '.
// Returns input as [x,y].
inputPosition = function(prompt, requiredPieceSign, allowCancel=false)
while true
ans = input(prompt + "? ").replace(",", " ").split
if ans.len < 2 then
print "Enter two coordinates, for example: 4 0"
continue
end if
x = val(ans[0])
y = val(ans[-1])
if x < 0 and y < 0 and allowCancel then
return [x, y]
else if x < 0 or x > 7 or y < 0 or y > 7 then
print "Coordinates must be in the range 0-7"
else if x%2 != y%2 then
print "Invalid coordinates (both must be odd, or both even)"
else if sign(board[x][y]) != requiredPieceSign then
print "Invalid coordinates"
else
return [x, y]
end if
end while
end function
// Evaluate a potential (computer) move.
evalMove = function(fromX, fromY, toX, toY)
score = 0
// +2 if it promotes this piece
if toY == 0 and board[fromX][fromY] == -1 then score += 2
// +5 if it jumps an opponent's piece
if abs(fromY-toY) == 2 then score += 5
// -2 if the piece is moving away from the top boundary
if fromY == 7 then score -= 2
// +1 for putting the piece against a vertical boundary
if toX == 0 or toX == 7 then score += 1
// check neighboring pieces of the target position
for c in [-1, 1]
if toX+c < 0 or toX+c > 7 or toY-1 < 0 then continue
// +1 for each adjacent friendly piece
if board[toX+c][toY-1] < 0 then score += 1
// -1 for each opponent piece that could now jump this one
if toX-c >= 0 and toX-c <= 7 and toY+1 <= 7 and board[toX+c][toY-1] > 0 and (
board[toX-c][toY+1] == 0 or (toX-c == fromX and toY+1 == fromY)) then score -= 2
end for
return score
end function
// Consider a possible (computer) move, including whether it's even valid.
// Return it or the previous best, whichever is better.
consider = function(fromX, fromY, toX, toY, previousBest)
// make sure it's within the bounds of the board
if toX < 0 or toX > 7 or toY < 0 or toY > 7 then return previousBest
// if it's an opponent's piece, consider jumping it instead
dx = toX - fromX
if board[toX][toY] > 0 and abs(dx) == 1 then
dy = toY - fromY
return consider(fromX, fromY, fromX + dx*2, fromY + dy*2, previousBest)
end if
// if it's a jump, make sure it's over an opponent piece
if abs(dx) == 2 then
midX = (fromX + toX)/2; midY = (fromY + toY)/2
if board[midX][midY] < 1 then return previousBest
end if
// make sure the destination is empty
if board[toX][toY] then return previousBest
// all checks passed; score it, and return whichever is better
rating = evalMove(fromX, fromY, toX, toY)
if not previousBest or rating > previousBest.rating then
newBest = {}
newBest.fromX = fromX; newBest.fromY = fromY
newBest.toX = toX; newBest.toY = toY
newBest.rating = rating
return newBest
else
return previousBest
end if
end function
// Do the computer's turn
doComputerTurn = function
// For each square on the board containing one of my pieces, consider
// possible moves and keep the best one so far. Start with a step
// size of 1 (ordinary move), but if we jump, then keep jumping.
stepSize = 1
while true
bestMove = null
for x in range(0, 7)
for y in range(0, 7)
if board[x][y] >= 0 then continue // not my piece
move = {}
move.fromPos = [x,y]
// Consider forward moves; if it's a king, also consider backward moves
for dx in [-stepSize, stepSize]
move.toPos = [dx, -stepSize]
bestMove = consider(x, y, x+dx, y-stepSize, bestMove)
if board[x][y] == -2 then bestMove = consider(x, y, x+dx, y+stepSize, bestMove)
end for
end for
end for
if not bestMove then
// No valid move -- if step size is still 1, this means we
// couldn't find ANY move on our turn, and we have lost.
// Otherwise, we're done.
if stepSize == 1 then
globals.gameOver = true
globals.winner = 1
end if
break
end if
// Do the move, and stop if we did not jump.
if stepSize == 1 then
print "From " + bestMove.fromX + " " + bestMove.fromY, ""
end if
print " to " + bestMove.toX + " " + bestMove.toY, ""
movePiece bestMove.fromX, bestMove.fromY, bestMove.toX, bestMove.toY
if abs(bestMove.toX - bestMove.fromX) == 1 then break
stepSize = 2
end while
print
end function
// Move one piece (including captures and crowning
movePiece = function(fromX, fromY, toX, toY)
piece = board[fromX][fromY]
board[toX][toY] = piece
board[fromX][fromY] = 0
// capture piece jumped over
if abs(toX - fromX) == 2 then
board[(fromX+toX)/2][(fromY+toY)/2] = 0
end if
// crown (make into a king) a piece that reaches the back row
if (toY == 7 and piece > 0) or (toY == 0 and piece < 0) then
board[toX][toY] = 2 * sign(piece)
end if
end function
// Handle the player's move.
doPlayerTurn = function
fromPos = inputPosition("From", 1, true)
fromX = fromPos[0]; fromY = fromPos[1]
if fromX < 0 then
// Player concedes the game.
globals.gameOver = true
globals.winner = -1
return
end if
while true
toPos = inputPosition("To", 0)
toX = toPos[0]; toY = toPos[1]
dist = abs(toX - fromX)
if dist <= 2 and abs(toY - fromY) == dist then break
end while
while true
// Make the move, and continue as long as we have a jump
movePiece fromX, fromY, toX, toY
if dist != 2 then break
// Prompt for another move, allowing a cancel (negative input).
fromX = toX; fromY = toX
toPos = inputPosition("+To", 0, true)
if toPos[0] < 0 or toPos[1] < 0 then break
toX = toPos[0]; toY = toPos[1]
end while
// If piece has reached the end of the board, crown this piece
if toY == 7 then board[toX][toY] = 2
end function
// Main loop.
gameOver = false
while not gameOver
doComputerTurn
if gameOver then break
printBoard
doPlayerTurn
if gameOver then break
printBoard
end while
print
if winner > 0 then print "You win." else print "I win."
@@ -0,0 +1,22 @@
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 chemist.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 chemist.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 "chemist"
run
```
@@ -0,0 +1,30 @@
print " "*33 + "Chemist"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
print "The fictitious chemical kryptocyanic acid can only be"
print "diluted by the ratio of 7 parts water to 3 parts acid."
print "If any other ratio is attempted, the acid becomes unstable"
print "and soon explodes. Given the amount of acid, you must"
print "decide how much water to add for dilution. If you miss"
print "you face the consequences."
deaths = 0
while deaths < 9
acid = floor(rnd * 50)
water = 7 * acid/3
response = input(acid +" liters of kryptocyanic acid. How much water? ").val
diff = abs(water - response)
if diff > water/20 then
print " SIZZLE! You have just been desalinated into a blob"
print " of quivering protoplasm!"
deaths += 1
if deaths < 9 then
print " However, you may try again with another life."
end if
else
print " Good job! You may breathe now, but don't inhale the fumes!"
print
end if
end while
print " Your 9 lives are used, but you will be long remembered for"
print " your contributions to the field of comic book chemistry."
@@ -0,0 +1,24 @@
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
Conversion to [MiniScript](https://miniscript.org).
NOTE: I have added `wait` statements before and while printing the lightning bolt, without which it appears too quickly to be properly dramatic.
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 chief.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 chief.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 "chief"
run
```
@@ -0,0 +1,50 @@
print " "*30 + "Chief"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
print "I am chief Numbers Freek, the great Indian math god."
yn = input("Are you ready to take the test you called me out for? ").lower
if not yn or yn[0] != "y" then
print "Shut up, pale face with wise tongue."
end if
print " Take a number and add 3. Divide this number by 5 and"
print "multiply by 8. Divide by 5 and add the same. Subtract 1."
b = input(" What do you have? ").val
c = (b+1-5)*5/8*5-3
yn = input("I bet your number was " + c + ". Am I right? ").lower
if yn and yn[0] == "y" then
print "Bye!!!"
else
k = input("What was your original number? ").val
f=k+3
g=f/5
h=g*8
i=h/5+5
j=i-1
print "So you think you're so smart, eh?"
print "Now watch."
print k + " plus 3 equals " + f +". This divided by 5 equals " + g + ";"
print "this times 8 equals " + h + ". If we divide by 5 and add 5,"
print "we get " + i + ", which, minus 1, equals " + j + "."
yn = input("Now do you believe me? ").lower
if yn and yn[0] == "y" then
print "Bye!!!"
else
print "You have made me mad!!!"
print "There must be a great lightning bolt!"
print; print; wait 2
for x in range(30, 22)
print " "*x + "x x"; wait 0.1
end for
print " "*21 + "x xxx"; wait 0.1
print " "*20 + "x x"; wait 0.1
print " "*19 + "xx x"; wait 0.1
for y in range(20, 13)
print " "*y + "x x"; wait 0.1
end for
print " "*12 + "xx"; wait 0.1
print " "*11 + "x"; wait 0.1
print " "*10 + "*"; wait 0.1
print; print"#########################"; print
print "I hope you believe me now, for your sake!!"
end if
end if
@@ -0,0 +1,19 @@
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 chomp.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 "chomp"
run
```
@@ -0,0 +1,102 @@
print " "*33 + "Chomp"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
// *** THE GAME OF CHOMP *** COPYRIGHT PCC 1973 ***
initBoard = function(rows, columns)
globals.rows = rows
globals.columns = columns
globals.board = [[null]] // indexed as [row][column], 1-based
for i in range(1, rows)
board.push ["."] + ["*"] * columns
end for
board[1][1] = "P"
end function
printBoard = function
print
print " "*7 + "1 2 3 4 5 6 7 8 9"
for i in range(1, rows)
print i + " "*6 + board[i][1:].join
end for
print
end function
introduction = function
print
print "This is the game of chomp (Scientific American, Jan 1973)"
r = input("Do you want the rules (1=yes, 0=no!)? ").val
if r == 0 then return
print "Chomp is for 1 or more players (humans only)."
print
print "Here's how a board looks (this one is 5 by 7):"
initBoard 5, 7
printBoard
print
print "The board is a big cookie - R rows high and C columns"
print "wide. You input R and C at the start. In the upper left"
print "corner of the cookie is a poison square (P). The one who"
print "chomps the poison square loses. To take a chomp, type the"
print "row and column of one of the squares on the cookie."
print "All of the squares below and to the right of that square"
print "(including that square, too) disappear -- chomp!!"
print "No fair chomping squares that have already been chomped,"
print "or that are outside the original dimensions of the cookie."
print
end function
setup = function
print
globals.numPlayers = input("How many players? ").val
rows = input("How many rows? ").val
while rows > 9
rows = input("Too many rows (9 is maximum). Now, how many rows? ").val
end while
columns = input("How many columns? ").val
while rows > 9
columns = input("Too many columns (9 is maximum). Now, how many columns? ").val
end while
print
initBoard rows, columns
end function
doOneTurn = function(player)
printBoard
print "Player " + player
while true
inp = input("Coordinates of chomp (row,column)? ")
inp = inp.replace(",", " ").split
if inp.len < 2 then continue
r = inp[0].val
c = inp[-1].val
if 1 <= r <= rows and 1 <= c <= columns and board[r][c] != " " then break
print "No fair. You're trying to chomp on empty space!"
end while
if board[r][c] == "P" then
print "You lose, player " + player
globals.gameOver = true
else
end if
for row in range(r, rows)
for col in range(c, columns)
board[row][col] = " "
end for
end for
end function
// Main program
introduction
while true
setup
gameOver = false
player = 0
while not gameOver
player += 1
if player > numPlayers then player = 1
doOneTurn player
end while
print
r = input("Again (1=yes, 0=no!)? ").val
if r != 1 then break
end while
@@ -0,0 +1,19 @@
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 civilwar.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 "civilwar"
run
```
@@ -0,0 +1,437 @@
print " "*26 + "Civil War"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
// ORIGINAL GAME DESIGN: CRAM, GOODIE, HIBBARD LEXINGTON H.S.
// MODIFICATIONS: G. PAUL, R. HESS (TIES), 1973
// Conversion to MiniScript: J. Strout, 2023
sides = ["Confederate", "Union"]
getYesNo = function(prompt)
while true
yn = input(prompt + "? ").lower
if yn and yn[0] == "y" then return "YES"
if yn and yn[0] == "n" then return "NO"
print "Yes or no -- "
end while
end function
instructions = function
print; print; print; print
print "This is a civil war simulation."
print "To play type a response when the computer asks."
print "Remember that all factors are interrelated and that your"
print "responses could change history. Facts and figures used are"
print "based on the actual occurrence. Most battles tend to result"
print "as they did in the civil war, but it all depends on you!!"
print
print "The object of the game is to win as many battles as ";
print "possible."
print
print "Your choices for defensive strategy are:"
print " (1) artillery attack"
print " (2) fortification against frontal attack"
print " (3) fortification against flanking maneuvers"
print " (4) falling back"
print " Your choices for offensive strategy are:"
print " (1) artillery attack"
print " (2) frontal attack"
print " (3) flanking maneuvers"
print " (4) encirclement"
print "You may surrender by typing a '5' for your strategy."
end function
historicalBattles = []
addBattle = function(name, men0, men1, cas0, cas1, offDef, desc)
battle = {}
battle.name = name
battle.men = [men0, men1]
battle.casualties = [cas0, cas1]
battle.offDef = offDef // 1=Confederate Defense, 2=both Offense, 3=Confederate Offense
battle.description = desc
historicalBattles.push battle
end function
loadData = function
// Historical data
addBattle "Bull Run",18000,18500,1967,2708,1, [
"July 21, 1861. Gen. Beauregard, commanding the South, met",
"Union forces with Gen. Mcdowell in a premature battle at",
"Bull Run. Gen. Jackson helped push back the Union attack."]
addBattle "Shiloh",40000.,44894.,10699,13047,3, [
"April 6-7, 1862. The Confederate surprise attack at",
"Shiloh failed due to poor organization."]
addBattle "Seven Days",95000.,115000.,20614,15849,3, [
"June 25-july 1, 1862. General Lee (CSA) upheld the",
"offensive throughout the battle and forced Gen. McClellan",
"and the Union forces away from Richmond."]
addBattle "Second Bull Run",54000.,63000.,10000,14000,2, [
"Aug 29-30, 1862. The combined Confederate forces under Lee",
"and Jackson drove the Union forces back into washington."]
addBattle "Antietam",40000.,50000.,10000,12000,3, [
"Sept 17, 1862. The South failed to incorporate Maryland",
"into the Confederacy."]
addBattle "Fredericksburg",75000.,120000.,5377,12653,1, [
"Dec 13, 1862. The Confederacy under Lee successfully",
"repulsed an attack by the Union under Gen. Burnside."]
addBattle "Murfreesboro",38000.,45000.,11000,12000,1, [
"Dec 31, 1862. The South under Gen. Bragg won a close battle."]
addBattle "Chancellorsville",32000,90000.,13000,17197,2, [
"May 1-6, 1863. The South had a costly victory and lost",
"one of their outstanding generals, 'Stonewall' Jackson."]
addBattle "Vicksburg",50000.,70000.,12000,19000,1, [
"July 4, 1863. Vicksburg was a costly defeat for the South",
"because it gave the Union access to the Mississippi."]
addBattle "Gettysburg",72500.,85000.,20000,23000,3, [
"July 1-3, 1863. A Southern mistake by Gen. Lee at Gettysburg",
"cost them one of the most crucial battles of the war."]
addBattle "Chickamauga",66000.,60000.,18000,16000,2, [
"Sept. 15, 1863. Confusion in a forest near Chickamauga led",
"to a costly Southern victory."]
addBattle "Chattanooga",37000.,60000.,36700.,5800,2, [
"Nov. 25, 1863. After the South had sieged Gen. Rosencrans'",
"army for three months, Gen. Grant broke the siege."]
addBattle "Spotsylvania",62000.,110000.,17723,18000,2, [
"May 5, 1864. Grant's plan to keep Lee isolated began to",
"fail here, and continued at Cold Harbor and Petersburg."]
addBattle "Atlanta",65000.,100000.,8500,3700,1, [
"August, 1864. Sherman and three veteran armies converged",
"on Atlanta and dealt the death blow to the Confederacy."]
end function
setup = function
print; print; print
if getYesNo("Are there two generals present") == "YES" then
globals.numPlayers = 2
else
globals.numPlayers = 1
print; print "You are the Confederacy. Good luck!"
print
end if
print "Select a battle by typing a number from 1 to 14 on"
print "request. Type any other number to end the simulation."
print "But '0' brings back exact previous battle situation"
print "allowing you to replay it."
print
print "Note: a negative food$ entry causes the program to "
print "use the entries from the previous battle."
print
yn = getYesNo("After requesting a battle, do you wish battle descriptions")
globals.battleDesc = (yn == "YES")
end function
// Game variables -- the 2-element arrays below represent the stats for
// player 0 (Confederacy) and 1 (Union)
D = [0,0] // money
F = [0,0] // food budget
H = [0,0] // salary budget
B = [0,0] // ammo budget
men = [0,0] // men at start of battle? (M1, M2)
menAdded = [0,0] // men added (M3, M4)
menAvail = [0,0] // men available (M5, M6)
P = [0,0] // casualties?
T = [0,0] // total losses?
resources = [0,0] // total resources (money) available to each side (R1, R2)
spending = [0,0] // total expenditures for each side (Q1, Q2)
morale = [0,0] // troop morale (O)
strategy = [0,0] // strategy choice (Y1, Y2)
inflation = [0,0] // inflation (I1, I2)
R = 0 // previous battle
losses = 0 // Confederate losses
wins = 0 // Confederate wins
unresolved = 0 // battles where neither side clearly won
printInColumns = function(a, b, c)
print (a + " "*20)[:20] + (b + " "*16)[:16] + c
end function
pickBattle = function
print; print; print
globals.replay = false
while true
num = input("Which battle do you wish to simulate? ").val
if num == 0 and R > 0 then
num = R
globals.replay = true
end if
if 0 < num <= historicalBattles.len then break
end while
globals.bat = historicalBattles[num - 1]
if not replay then
men[0] = bat.men[0]
men[1] = bat.men[1]
// inflation calc
inflation[0] = 10 + (losses - wins) * 2
inflation[1] = 10 + (wins - losses) * 2
// money available
D[0] = 100 * floor((men[0]*(100-inflation[0])/2000) * (1+(resources[0]-spending[0])/(resources[0]+1))+0.5)
D[1] = 100 * floor(men[1]*(100-inflation[1])/2000 + 0.5)
if numPlayers == 2 then
D[1] = 100 * floor((men[1]*(100-inflation[1])/2000) * (1+(resources[1]-spending[1])/(resources[1]+1))+0.5)
end if
// men available
menAvail[0] = floor(men[0]*(1 + (P[0]-T[0])/(menAdded[0]+1)))
menAvail[1] = floor(men[1]*(1 + (P[1]-T[1])/(menAdded[1]+1)))
globals.F1 = 5/6 * men[0] // ?!?
print; print; print; print; print
print "P:" + P + "; T:" + T + "; menAdded:" + menAdded
print "men[0]:" + men[0] + " ...F1:" + F1
print "This is the battle of " + bat.name
if battleDesc then
for line in bat.description
print line
end for
end if
else
print bat.name + " Instant Replay"
end if
print
printInColumns " ", "CONFEDERACY", " UNION"
printInColumns "MEN", " "+menAvail[0], " "+menAvail[1]
printInColumns "MONEY", "$ "+D[0], "$ "+D[1]
printInColumns "INFLATION", " "+(inflation[0]+15)+" %", " " +inflation[1]+" %"
// (Note: printout lies and shows confederate inflation 15% higher than actual)
print
end function
getBudget = function(player)
print sides[player] + " General---How much do you wish to spend for"
getNum = function(prompt, allowNegative)
while true
n = input(prompt)
if not n then continue
if n[-1] == "k" then n = n[:-1] + "000" // (allow entries like "60k")
if n.val >= 0 or allowNegative then return n.val
print "Negative values are not allowed."
end while
end function
while true
f = getNum(" - Food......? ", true)
if f < 0 then
if resources[player] == 0 then
print "No previous entries."
print "How much do you wish to spend for"
continue
end if
break // keep all previous entries
end if
F[player] = f
H[player] = getNum(" - Salaries..? ", false)
B[player] = getNum(" - Ammunition? ", false)
if F[player] + H[player] + B[player] <= D[player] then break
print "Think again! You have only $" + D[player]
end while
end function
calcMorale = function(player)
m = ((2*F[player]^2 + H[player]^2) / F1^2 + 1)
print (" "*11 + sides[player])[-11:], " "
if m >= 10 then
print "morale is high"
else if m >= 5 then
print "morale is fair"
else
print "morale is poor"
end if
morale[player] = m
end function
getStrategy = function(player)
if numPlayers == 1 then prompt = "Your strategy" else prompt = sides[player] + " strategy"
while true
strat = input(prompt + "? ").val
if 0 < strat < 6 then break
print "Strategy " + strat + " not allowed."
end while
strategy[player] = strat
if strat == 5 then
print "The " + ["Confederacy", "Union"][player] + " has surrendered."
globals.gameOver = true
end if
end function
calcComputerStrategy = function
// Union strategy is computer chosen
print "Union strategy is ", ""
s0 = 0
r = 100 * rnd
for i in range(0, 3)
s0 += unionStrats[i]
if r < s0 then
strategy[1] = i+1
break
end if
end for
print strategy[1]
end function
learnStrategy = function
// Learn present strategy, start forgetting old ones.
// - Present strategy of south gains 3*s, others lose s
// probability points, unless a strategy falls below 5%.
s = 3; s0 = 0
for i in range(0,3)
if unionStrats[i] < 5 then continue
unionStrats[i] -= s
s0 += s
end for
unionStrats[strategy[1]-1] += s0
end function
doBattle = function
U = 0; U2 = 0
// simulated losses -- North
C6 = (2 * bat.casualties[1]/5) * (1+1/(2*(abs(strategy[1]-strategy[0])+1)))
C6 = C6 * (1.28 + (5*men[1]/6) / (B[1]+1))
C6 = floor(C6 * (1+1/morale[1]) + .5)
// - IF LOSS > MEN PRESENT, RESCALE LOSSES
E2 = 100/morale[1] // desertions (Union)
if floor(C6 + E2) >= menAvail[1] then
C6 = floor(13*menAvail[1]/20)
E2 = 7 * C6/13
U2=1 // Union loss
end if
// simulated losses -- South
C5 = (2 * bat.casualties[0]/5) * (1+1/(2*(abs(strategy[1]-strategy[0])+1)))
print "step A:" + C5
C5 = floor(C5 * (1+1/morale[0])*(1.28+F1/(B[0]+1))+.5)
print "step B:" + C5
print "based on morale[0]:"+morale[0]+", F1:"+F1+", B[0]:"+B[0]
E=100/morale[0]
if C5+100/morale[0] >= men[0]*(1+(P1-T1)/(menAdded[0]+1)) then
C5 = floor(13*men[0]/20 * (1+(P1-T1)/(menAdded[0]+1)))
print "step C:" + C5
print "men: " + men; print "menAdded: " + menAdded; print "P1,T1:" + P1 + "," + T1
E=7*C5/13 // desertions (Confed)
U=1 // Confederate loss
end if
print
print; print; printInColumns "", "CONFEDERACY", "UNION"
if numPlayers == 1 then
C6 = floor(17 * bat.casualties[1] * bat.casualties[0] / (C5*20))
E2 = 5 * morale[0]
end if
printInColumns "CASUALTIES", C5, C6
printInColumns "DESERTIONS", floor(E), floor(E2)
print
if numPlayers == 2 then
print "Compared to the actual casualties at " + bat.name
print "Confederate: " + round(100*C5/bat.casualties[0]) + "% of the original"
print "Union: " + round(100*C6/bat.casualties[1]) + "% of the original"
print
// Who won?
print "U:"+U+ " U2:"+U2
if (U == 1 and U2 != 1) or (U == U2 and C5+E > C6+E2) then
print "The Union wins " + bat.name
globals.losses += 1
else if (U2 == 1 and U != 1) or (U == U2 and C5+E < C6+E2) then
print "The confederacy wins " + bat.name
globals.wins += 1
else
print "Battle outcome unresolved"
globals.unresolved += 1
end if
else
print "Your casualties were " + round(100*C5/bat.casualties[0]) + "% of"
print "the actual casualties at " + bat.name
print
if U == 1 or C5+E >= 17*bat.casualties[1]*bat.casualties[0]/(C5*20)+5*morale[0] then
print "You lose " + bat.name
if not replay then globals.losses += 1
else
print "You win " + bat.name
if not replay then globals.wins += 1
end if
end if
if not replay then
// Cumulative battle factors which alter historical
// resources availeble. (If a replay, don't update.)
T[0] += C5 + E
T[1] += C6 + E2
P[0] += bat.casualties[0]
P[1] += bat.casualties[1]
spending[0] += F[0] + H[0] + B[0]
spending[1] += F[1] + H[1] + B[1]
resources[0] += men[0]*(100-inflation[0])/20
resources[1] += men[1]*(100-inflation[1])/20
menAdded[0] += men[0]
menAdded[1] += men[1]
learnStrategy
end if
print "---------------"
end function
// Main Program
loadData
unionStrats = [25, 25, 25, 25]
P1=0; P2=0; T1=0; T2=0 // cumulative stat thingies
print
if getYesNo("Do you want instructions") == "YES" then instructions
setup
gameOver = false
while not gameOver
pickBattle
if gameOver then break
for i in range(0, numPlayers-1)
getBudget i
end for
for i in range(0, numPlayers-1)
calcMorale i
end for
print "Confederate General---", ""
if bat.offDef == 3 then
print "you are on the offensive"
else if bat.offDef == 1 then
print "you are on the defensive"
else
print "both sides are on the offensive "
end if
print
getStrategy 0
if numPlayers == 2 then getStrategy 1 else calcComputerStrategy
if gameOver then break
doBattle
end while
// Finish off
print; print; print; print; print; print
print "The Confederacy has won " + wins + " battles and lost " + losses
if strategy[0] == 5 or (strategy[1] != 5 and losses > wins) then
print "The Union has won the war"
else
print "The Confederacy has won the war"
end if
print "For the " + (wins + losses + unresolved) + " battles fought (excluding reruns)"
print
printInColumns "", "Confederacy", "Union"
printInColumns "Historical Losses", round(P[0]), round(P[1])
printInColumns "Simulated Losses", round(T[0]), round(T[1])
print
printInColumns " % of Original", round(100*T[0]/P[0]), round(100*T[1]/P[1])
if numPlayers == 1 then
print
print "Union intelligence suggsets that the South used "
print "strategies 1, 2, 3, 4 in the following percentages"
print unionStrats.join
end if
@@ -0,0 +1,19 @@
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 combat.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 "combat"
run
```
@@ -0,0 +1,165 @@
print " "*33 + "Combat"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
printInColumns2 = function(a, b, lineBreak=true)
print (a+" "*16)[:16] + (b+" "*16)[:16], ""
if lineBreak then print
end function
printInColumns3 = function(a, b, c, lineBreak=true)
print (a+" "*16)[:16] + (b+" "*16)[:16] + (c+" "*16)[:16], ""
if lineBreak then print
end function
// computer forces:
d = 30000 // army
e = 20000 // navy
f = 22000 // air force
print "I am at war with you."; print "We have 72000 soldiers apiece."
while true
print; print "Distribute your forces."
printInColumns3 "", "ME", "YOU"
printInColumns2 "army", d, false
a = input("?").val
printInColumns2 "navy", e, false
b = input("?").val
printInColumns2 "a. f.", f, false
c = input("?").val
if a+b+c <= 72000 then break
end while
print "You attack first. Type (1) for army; (2) for navy;"
print "and (3) for air force."
y = input.val
while true
x = input("How many men? ").val
if x < 0 then continue
if y <= 1 or y > 3 then
// Army attack
if x > a then continue
if x < a/3 then
print "You lost "+x+" men from your army."
a=floor(a-x)
else if x < 2*a/3 then
print "You lost " + floor(x/3) + " men, but I lost " + floor(2*d/3)
a=floor(a-x/3)
d=0 // (message above lied!)
else
print "You sunk one of my patrol boats, but I wiped out two"
print "of your air force bases and 3 army bases."
a=floor(a/3)
c=floor(c/3)
e=floor(2*e/3)
end if
else if y == 2 then
// Naval attack
if x > b then continue
if x < e/3 then
print "Your attack was stopped!"
b = floor(b-x)
else if x < 2*e/3 then
print "You destroyed " + floor(2*e/3) + "of my army."
e=floor(e/3)
else
print "You sunk one of my patrol boats, but I wiped out two"
print "of your air force bases and 3 army bases."
a=floor(a/3)
c=floor(c/3)
e=floor(2*e/3)
end if
else
// Air force attack
if x > c then continue
if x < c/3 then
print "Your attack was wiped out."
c = floor(c-x)
else if x < 2*c/3 then
print "We had a dogfight. You won - and finished your mission."
d=floor(2*d/3)
e=floor(e/3)
f=floor(f/3)
else
print "You wiped out one of my army patrols, but I destroyed"
print "two navy bases and bombed three army bases."
a=floor(a/4)
b=floor(b/3)
d=floor(2*d/3)
end if
end if
break
end while
result = null // 1 you win, -1 you lose, 0 tie (treaty)
print
printInColumns3 "", "YOU", "ME"
printInColumns3 "army", a, d
printInColumns3 "navy", b, e
printInColumns3 "a. f.", c, f
print "What is your next move?"
print "army=1 navy=2 air force=3"
g = input.val
while true
t = input("How many men? ").val
if t < 0 then continue
if g <= 1 or g > 3 then
// Army attack
if t > a then continue
if t < d/2 then
print "I wiped out your attack!"
a = a-t
else
print "You destroyed my army!"
d=0
end if
else if g == 2 then
// Naval attack
if t > b then continue
if t < e/2 then
print "I sunk two of your battleships, and my air force"
print "wiped out your ungaurded capitol." // (sic)
a = a/4
b = b/2
else
print "Your navy shot down three of my xiii planes,"
print "and sunk three battleships."
f = 2*f/3
e = (e/2)
end if
else
// Air Force attack
if t > c then continue
if t > f/2 then
print "My navy and air force in a combined attack left"
print "your country in shambles."
a = a/3
b = b/3
c = c/3
else
print "One of your planes crashed into my house. I am dead."
print "My country fell apart."
result = 1
end if
end if
break
end while
if result == null then
print
print "From the results of both of your attacks,"
result = 0
if a+b+c > 3/2*(d+e+f) then result = 1
if a+b+c < 2/3*(d+e+f) then result = -1
end if
if result == 0 then
print "the treaty of paris concluded that we take our"
print "respective countries and live in peace."
else if result == 1 then
print "You won, oh! shucks!!!!"
else
print "You lost-I conquered your country. It serves you"
print "right for playing this stupid game!!!"
end if
@@ -0,0 +1,19 @@
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 craps.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 "craps"
run
```
@@ -0,0 +1,87 @@
// Craps
// Ported from BASIC to MiniScript by Joe Strout (2023)
print " "*33 + "CRAPS"
print " "*15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
print; print; print
print "2,3,12 are losers; 4,5,6,8,9,10 are points; 7,11 are natural winners."
winnings = 0
rollDice = function
wait 0.5 // (a small delay makes the game more dramatic)
return ceil(rnd*6) + ceil(rnd*6)
end function
doOneBet = function
while true
wager = input("Input the amount of your wager: ").val
if wager > 0 then break
end while
print "I will now throw the dice."
result = 0 // 1 if we win, 2 if win double, -1 if we lose
roll = rollDice
if roll == 7 or roll == 11 then
print roll + "- natural....a winner!!!!"
print roll + " pays even money, you win " + wager + " dollars"
result = 1
else if roll == 2 then
print "2- snake eyes....you lose."
print "You lose " + wager + " dollars."
result = -1
else if roll == 3 or roll == 12 then
print roll + " - craps...you lose."
print "You lose " + wager + " dollars."
result = -1
else
point = roll
print point + " is the point. I will roll again"
while true
roll = rollDice
if roll == 7 then
print "7 - craps. You lose."
print "You lose $" + wager
result = -1
break
else if roll == point then
print roll + "- a winner.........CONGRATS!!!!!!!!"
print roll + " at 2 to 1 odds pays you...let me see..." +
(2*wager) + " dollars"
result = 2
break
else
print roll + " - no point. I will roll again"
end if
end while
end if
globals.winnings += wager * result
end function
// Main loop.
while true
doOneBet
while true
// Why you have to enter 5 to continue is anyone's guess,
// but that's what the original program did.
again = input(" If you want to play again print 5 if not print 2: ")
if again == "5" or again == "2" then break
end while
if winnings < 0 then
print "You are now under $" + (-winnings)
else if winnings > 0 then
print "You are now ahead $" + winnings
else
print "You are now even at 0"
end if
if again != "5" then break
end while
if winnings < 0 then
print "Too bad, you are in the hole. Come again."
else if winnings > 0 then
print "Congratulations---You came out a winner. Come again!"
else
print "Congrtulations---You came out even, not bad for an amateur"
end if
@@ -0,0 +1,68 @@
import std/[random,strutils]
var
wager, winnings, rollResult: int
stillplaying: bool = true
randomize() # Seed the random number generator
proc tryAgain(): bool =
echo "WANT TO PLAY AGAIN? (YES OR NO)"
var answer = readLine(stdin).normalize()
result = (answer == "y") or (answer == "yes")
proc takePoint(point: int) =
var flag = true
while flag:
var pointRoll: int = (rand 1..6) + (rand 1..6) # roll dice, then add the sum
if pointRoll == 7:
echo pointRoll, "- CRAPS. YOU LOSE."
echo "YOU LOSE ", wager, " DOLLARS."
winnings -= wager
flag = false
if pointRoll == point:
echo point, "- A WINNER.........CONGRATS!!!!!!!!"
echo "AT 2 TO 1 ODDS PAYS YOU...LET ME SEE... ", 2*wager, " DOLLARS"
winnings += (2*wager)
flag = false
if flag:
echo pointRoll, " - NO POINT. I WILL ROLL AGAIN"
echo spaces(33), "CRAPS"
echo spaces(15), "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
echo "\n"
echo "2,3,12 ARE LOSERS; 4,5,6,8,9,10 ARE POINTS; 7,11 ARE NATURAL WINNERS."
winnings = 0
# play the game
while stillplaying:
echo ""
echo "INPUT THE AMOUNT OF YOUR WAGER."
wager = readline(stdin).parseInt()
echo "I WILL NOW THROW THE DICE"
rollResult = (rand 1..6) + (rand 1..6) # roll dice, then add the sum
case rollResult:
of 7, 11:
echo rollResult, "- NATURAL....A WINNER!!!!"
echo rollResult, " PAYS EVEN MONEY, YOU WIN ", wager, " DOLLARS"
winnings += wager
of 2:
echo rollResult, "- SNAKE EYES....YOU LOSE."
echo "YOU LOSE ", wager, " DOLLARS."
winnings -= wager
of 3, 12:
echo rollResult, "- CRAPS...YOU LOSE."
echo "YOU LOSE ", wager, " DOLLARS."
winnings -= wager
else:
echo rollResult, " IS THE POINT. I WILL ROLL AGAIN"
takePoint(rollResult)
if winnings < 0: echo "YOU ARE NOW UNDER $", winnings
if winnings > 0: echo "YOU ARE NOW AHEAD $", winnings
if winnings == 0: echo "YOU ARE NOW EVEN AT 0"
stillplaying = tryAgain()
# done playing
if winnings < 0: echo "TOO BAD, YOU ARE IN THE HOLE. COME AGAIN."
if winnings > 0: echo "CONGRATULATIONS---YOU CAME OUT A WINNER. COME AGAIN!"
if winnings == 0: echo "CONGRATULATIONS---YOU CAME OUT EVEN, NOT BAD FOR AN AMATEUR"
@@ -0,0 +1,19 @@
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 cube.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 "cube"
run
```
@@ -0,0 +1,100 @@
print " "*34 + "Bullseye"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
if input("Do you want to see the instructions? (yes--1,no--0) ").val then
print "This is a game in which you will be playing against the"
print "random decision of the computer. The field of play is a"
print "cube of size 3. Any of the locations can be designated"
print "by inputing three numbers such as 2,3,1. At the start,"
print "you are automatically at location 1,1,1. The object of"
print "the game is to get to location 3,3,3. One minor detail:"
print "the computer will pick, at random, locations at which"
print "it will plant land mines. If you hit one of these locations"
print "you lose. One other detail: you may move only one space "
print "in one direction each move. For example: from 1,1,2 you"
print "may move to 2,1,2 or 1,1,3. You may not change"
print "two of the numbers on the same move. If you make an illegal"
print "move, you lose and the computer takes the money you may"
print "have bet on that round."
print
print
print "All yes or no questions will be answered by a 1 for yes"
print "or a 0 (zero) for no."
print
print "When stating the amount of a wager, print only the number"
print "of dollars (example: 250). You are automatically started with"
print "500 dollars in your account."
print
print "Good luck!"
end if
money = 500
while money >= 0
mineLocs = []
// Note: unlike the original BASIC program, which doesn't actually pick random
// numbers unless you manually set X to a positive value before running the
// program, we do pick five random mine locations here.
// But like that program, we make no attempt to avoid 1,1,1 or 3,3,3, or to
// ensure that we have picked five DIFFERENT locations.
for i in range(1,5)
mineLocs.push [floor(3 * rnd + 1), floor(3 * rnd + 1), floor(3 * rnd + 1)]
end for
wager = 0
if input("Want to make a wager? ").val then
wager = input("How much? ").val
while money < wager
wager = input("Tried to fool me; bet again? ").val
end while
end if
position = [1,1,1]
print
inp = input("It's your move: ")
won = 0
while true
inp = inp.replace(",", " ").replace(" ", " ").split
newPos = []
if inp.len == 3 then newPos = [inp[0].val, inp[1].val, inp[2].val]
legal = newPos.len == 3
totalChange = 0
for i in newPos.indexes
// The original game allowed you to walk outside the 1-3 range,
// thus safely avoiding all the mines. To disallow this exploit,
// uncomment the following line.
//if newPos[i] < 1 or newPos[i] > 3 then legal = false
totalChange += abs(newPos[i] - position[i])
end for
if totalChange > 1 then legal = false
if not legal then
print; print "Illegal move. You lose."
won = -wager
break
end if
if newPos == [3,3,3] then
print "Congratulations!"
won = wager
break
else if mineLocs.indexOf(newPos) != null then
print "******BANG******"
print "You lose!"
print
print
won = -wager
break
end if
position = newPos
inp = input("Next move: ")
end while
if won != 0 then
globals.money += won
if money <= 0 then print "You bust."
end if
if wager then
print " You now have " + money + " dollars."
end if
if not input("Do you want to try again? ").val then break
end while
print "Tough luck!"
print
print "Goodbye."
@@ -0,0 +1,19 @@
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 depthcharge.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 "depthcharge.ms"
run
```
@@ -0,0 +1,116 @@
// Depth Charge
// Originally by Dana Noftle (1978)
// Translated from BASIC to MiniScript by Ryushinaka and Joe Strout (2023)
askYesNo = function(prompt)
while true
answer = input(prompt).lower[:1]
if answer == "y" or answer == "n" then return answer
end while
end function
showWelcome = function
print
print " "*34 + "Depth Charge"
print " "*15 + "Creative Computing Morristown, New Jersey"
print
end function
setup = function
while true
globals.size = input("Dimension of search area? ").val
if size > 0 then break
end while
globals.numCharges = ceil(log(size,2))
if numCharges == 0 then globals.numCharges = 1 // ensure we have at least 1 shot
print "You are the captain of the destroyer USS Computer."
print "An enemy sub has been causing you trouble. Your"
print "mission is to destroy it. You have " + numCharges + " shots."
print "Specify depth charge explosion point with a"
print "trio of numbers -- the first two are the"
print "surface coordinates; the third is the depth."
end function
showShotResult = function(shot,location)
result = "Sonar reports shot was "
if shot[1] > location[1] then
result = result + "north"
else if shot[1] < location[1] then
result = result + "south"
end if
if shot[0] > location[0] then
result = result + "east"
else if shot[0] < location[0] then
result = result + "west"
end if
if shot[1] != location[1] or shot[0] != location[0] then
result = result + " and "
end if
if shot[2] > location[2] then
result = result + "too low."
else if shot[2] < location[2] then
result = result + "too high."
else
result = result + "depth OK."
end if
print result
end function
getShot = function
shotPos = [0,0,0]
while true
rawGuess = input("Enter coordinates: ").split(" ")
if rawGuess.len == 3 then
shotPos[0] = rawGuess[0].val
shotPos[1] = rawGuess[1].val
shotPos[2] = rawGuess[2].val
return shotPos
else
print "Please enter coordinates separated by spaces"
print "Example: 3 2 1"
end if
end while
end function
playGame = function
print "Good luck!"
print
subPos = [floor(rnd*size), floor(rnd*size), floor(rnd*size)]
// For debugging, you can give away the answer:
//print "(Sub is hidden at: " + subPos.join(" ") + ")"
for c in range(1, numCharges)
print "Trial " + c
shot = getShot
if shot[0] == subPos[0] and shot[1] == subPos[1] and shot[2] == subPos[2] then
print "B O O M ! ! You found it in " + c + " tries!"
return
else
showShotResult(shot,subPos)
end if
end for
print "You have been torpedoed! Abandon ship!"
print "The submarine was at " + subPos.join(" ") + "."
end function
showWelcome
setup
while true
playGame
if askYesNo("Another game (Y or N): ") == "n" then
print "OK. Hope you enjoyed yourself."
break
end if
end while
@@ -0,0 +1,19 @@
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 diamond.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 "diamond"
run
```
@@ -0,0 +1,23 @@
// Diamond
//
// Ported from BASIC to MiniScript by Joe Strout
print " "*33 + "DIAMOND"
print " "*15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
print; print; print
print "For a pretty diamond pattern,"
maxw = input("type in an odd number between 5 and 21: ").val
s = "CC" + "!" * maxw
columns = floor(68/maxw)
for row in range(1, columns)
for w in range(1, maxw, 2) + range(maxw-2, 1, -2)
print " "*(maxw-w)/2, ""
for column in range(1, columns)
print s[:w], ""
if column < columns then print " "*(maxw-w), ""
end for
print
wait 0.01
end for
end for
@@ -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:
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 dice.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 "dice"
run
```
3. "Try-It!" page on the web:
Go to https://miniscript.org/tryit/, clear the default program from the source code editor, paste in the contents of dice.ms, and click the "Run Script" button.
@@ -0,0 +1,53 @@
// Dice
//
// Danny Freidus
// Ported from BASIC to MiniScript by Joe Strout
print " "*34 + "DICE"
print " "*15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
print; print; print
print "This program simulates the rolling of a"
print "pair of dice."
print "You enter the number of times you want the computer to"
print "'roll' the dice. Watch out, very large numbers take"
print "a long time. In particular, numbers over 5000."
// Function to do one run of the simulation.
runOnce = function
// Clear the array we'll use to hold the counts
counts = [0] * 13
// Loop the desired number of times
x = input("How many rolls? ").val
for s in range(1, x)
// roll two dice and find the sum
die1 = ceil(6 * rnd)
die2 = ceil(6 * rnd)
sum = die1 + die2
// update the count for that sum
counts[sum] += 1
end for
print
// print a table showing how many times each sum was rolled
print "Total Spots Number of Times"
for v in range(2, 12)
// (the [-6:] trick below right-aligns the number)
print (" " + v)[-6:] + " "*10 + counts[v]
end for
print; print
end function
// Get a yes/no (or at least y/n) response from the user.
askYesNo = function(prompt)
while true
answer = input(prompt).lower[:1]
if answer == "y" or answer == "n" then return answer
end while
end function
// main loop
while true
print
runOnce
if askYesNo("Try again? ") == "n" then break
end while
@@ -0,0 +1,37 @@
import std/[random,strutils]
var
a,b,r,x: int
f: array[2..12, int]
z: string
retry: bool = true
randomize() # Seed the random number generator
echo spaces(34), "DICE"
echo spaces(15), "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
echo "\n"
echo "THIS PROGRAM SIMULATES THE ROLLING OF A PAIR OF DICE."
echo "YOU ENTER THE NUMBER OF TIMES YOU WANT THE COMPUTER TO"
echo "'ROLL' THE DICE. WATCH OUT, VERY LARGE NUMBERS TAKE"
echo "A LONG TIME. IN PARTICULAR, NUMBERS OVER 5000."
while(retry):
echo "\n"
echo "HOW MANY ROLLS"
x = readLine(stdin).parseInt()
for v in 2..12:
f[v] = 0 # Initialize array to 0
for s in 1..x:
a = rand(1..6) # Die 1
b = rand(1..6) # Die 2
r = a + b # Sum of dice
f[r] += 1 # Increment array count of dice sum result
echo ""
echo "TOTAL SPOTS: ", "NUMBER OF TIMES"
for v in 2..12:
echo v, ": ", f[v] # Print out counts for each possible result
echo "\n"
echo "TRY AGAIN?"
z = readLine(stdin).normalize()
retry = (z=="yes") or (z=="y")
@@ -0,0 +1,19 @@
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 digits.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 "digits"
run
```
@@ -0,0 +1,99 @@
import "listUtil"
print " "*33 + "Digits"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
printInColumns = function(a, b, c, d)
print (a+" "*16)[:16] + (b+" "*16)[:16] + (c+" "*16)[:16] + (d+" "*16)[:16]
end function
print "This is a game of guessing."
print "For instructions, type '1', else type '0'"
if input != "0" then
print
print "Please take a piece of paper and write down"
print "the digits '0', '1', or '2' thirty times at random."
print "Arrange them in three lines of ten digits each."
print "I will ask for then ten at a time."
print "I will always guess them first and then look at your"
print "next number to see if i was right. By pure luck,"
print "I ought to be right ten times. But i hope to do better"
print "than that *****"
print; print
end if
a = 0; b = 1; c = 3
while true
m = list.init2d(27, 3, 1)
k = list.init2d(3, 3, 9)
l = list.init2d(9, 3, 3)
l[0][0] = 2; l[4][1] = 2; l[8][2] = 2
z=26; z1=8; z2=2
qtyRight = 0
guess = 0
for t in range(1,3)
while true
print
print "Ten numbers, please";
n = input.replace(",", " ").replace(" ", "").split
if n.len != 10 then continue
valid = true
for i in n.indexes
n[i] = n[i].val
if n[i] < 0 or n[i] > 2 then
print "Only use the digits '0', '1', or '2'."
print "Let's try again."
valid = false
break
end if
end for
if valid then break
end while
print; printInColumns "My guess","Your no.","Result","No. right"; print
for u in range(0, 9)
yourNum = n[u]; s=0
for j in range(0,2)
s1 = a*k[z2][j] + b*l[z1][j] + c*m[z][j]
if s > s1 then continue
if s < s1 or rnd >= 0.5 then
s = s1; guess = j
end if
end for
if guess == yourNum then
outcome = " right"
qtyRight += 1
else
outcome = " wrong"
end if
printInColumns " "+guess, " " + yourNum, outcome, qtyRight
m[z][yourNum] += 1
l[z1][yourNum] += 1
k[z2][yourNum] += 1
z -= floor(z/9)*9
z = 3*z + yourNum
z1 = z - floor(z/9)*9
z2 = yourNum
end for
end for
print
if qtyRight > 10 then
print "I guessed more than 1/3 of your numbers."
print "I win."
print char(7) * 10
else if qtyRight < 10 then
print "I guessed less than 1/3 of your numbers."
print "You beat me. Congratulations *****"
else
print "I guessed exactly 1/3 of your numbers."
print "It's a tie game."
end if
print "Do you want to try again (1 for yes, 0 for no)";
if input != "1" then break
end while
print; print "Thanks for the game."
@@ -0,0 +1,33 @@
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
Conversion to [MiniScript](https://miniscript.org).
Note that this folder (like the original BASIC programs) contains TWO different programs based on the same idea. evenwins.ms plays deterministically; gameofevenwins.ms learns from its failures over multiple games.
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 evenwins.ms
```
or
```
miniscript gameofevenwins.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 "evenwins"
run
```
or
```
load "gameofevenwins"
run
```
@@ -0,0 +1,140 @@
print " "*31 + "Digits"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print
y1 = 0
m1 = 0
print " This is a two person game called 'Even Wins.'"
print "To play the game, the players need 27 marbles or"
print "other objects on a table."
print
print
print " The 2 players alternate turns, with each player"
print "removing from 1 to 4 marbles on each move. The game"
print "ends when there are no marbles left, and the winner"
print "is the one with an even number of marbles."
print
print
print " The only rules are that (1) you must alternate turns,"
print "(2) you must take between 1 and 4 marbles each turn,"
print "and (3) you cannot skip a turn."
print
print
print
while true
print " Type a '1' if you want to go first, and type"
print "a '0' if you want me to go first."
c = input.val
print
if c != 0 then
t = 27
print
print
print
print "Total=" + t
print
print
print "What is your first move?"
m = 0
else
t = 27
m = 2
print
print "Total= " + t
print
m1 += m
t -= m
end if
while true
if m then
print "I pick up " + m + " marbles."
if t == 0 then break
print
print "Total=" + t
print
print " And what is your next move, my total is " + m1
end if
while true
y = input.val
print
if y < 1 or y > 4 then
print
print "The number of marbles you must take be a positive"
print "integer between 1 and 4."
print
print " What is your next move?"
print
else if y > t then
print " You have tried to take more marbles than there are"
print "left. Try again."
else
break
end if
end while
y1 += y
t -= y
if t == 0 then break
print "Total=" + t
print
print "Your total is " + y1
if t < 0.5 then break
r = t % 6
if y1 % 2 != 0 then
if t >= 4.2 then
if r <= 3.4 then
m = r + 1
m1 += m
t -= m
else if r < 4.7 or r > 3.5 then
m = 4
m1 += m
t -= m
else
m = 1
m1 += m
t -= m
end if
else
m = t
t -= m
print "I pick up " + m + " marbles."
print
print "Total = 0"
m1 += m
break
end if
else
if r < 1.5 or r > 5.3 then
m = 1
m1 += m
t -= m
else
m = r - 1
m1 += m
t -= m
if t < 0.2 then
print "I pick up " + m + " marbles."
print
break
end if
end if
end if
end while
print "That is all of the marbles."
print
print " My total is " + m1 + ", your total is " + y1
print
if m1 % 2 then
print " You won. Do you want to play"
else
print " I won. Do you want to play"
end if
print "again? Type 1 for yes and 0 for no."
a1 = input.val
if a1 == 0 then break
m1 = 0
y1 = 0
end while
print
print "OK. See you later"
@@ -0,0 +1,90 @@
print " "*28 + "Game Of Even Wins"
print " "*15 + "Creative Computing Morristown, New Jersey"
print
print
yesNo = input("Do you want instructions (yes or no)? ").lower
if not yesNo or yesNo[0] != "n" then
print "The game is played as follows:"
print
print "At the beginning of the game, a random number of chips are"
print "placed on the board. The number of chips always starts"
print "as an odd number. On each turn, a player must take one,"
print "two, three, or four chips. The winner is the player who"
print "finishes with a total number of chips that is even."
print "The computer starts out knowing only the rules of the"
print "game. It gradually learns to play well. It should be"
print "difficult to beat the computer after twenty games in a row."
print "Try it!!!!"
print
print "To quit at any time, type a '0' as your move."
print
end if
l = 0
b = 0
r = [[4]*6, [4]*6]
while true
a = 0
b = 0
e = 0
l = 0
p = floor((13 * rnd + 9) / 2) * 2 + 1;
while true
if p == 1 then
print "There is 1 chip on the board."
else
print "There are " + p + " chips on the board."
end if
e1 = e
l1 = l
e = a % 2
l = p % 6
if r[e][l] < p then
m = r[e][l]
if m <= 0 then
m = 1
b = 1
break
end if
p -= m
if m == 1 then
prompt = "Computer takes 1 chip leaving " + p + "... Your move? "
else
prompt = "Computer takes " + m + " chips leaving " + p + "... Your move? "
end if
b += m
while true
m = input(prompt).val
if m == 0 then break
if 1 <= m <= p and m <= 4 then break
prompt = m + " is an illegal move ... Your move? "
end while
if m == 0 then break
if m == p then break // <-- Really? Before we've done the math?
p -= m
a += m
else
if p == 1 then
print "Computer takes 1 chip."
else
print "Computer takes " + p + " chips."
end if
r[e][l] = p
b += p
break
end if
end while
if m == 0 then break
if b % 2 != 0 then
print "Game over ... you win!!!"
if r[e][l] != 1 then
r[e][l] -= 1
else if (r[e1][l1] != 1) then
r[e1][l1] -= 1
end if
else
print "Game over ... I win!!!"
end if
print
end while
@@ -0,0 +1,19 @@
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 flipflop.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 "flipflop"
run
```
@@ -0,0 +1,97 @@
print " "*32 + "FlipFlop"
print " "*15 + "Creative Computing Morristown, New Jersey"
print
// Created by Michael Cass (1978)
// Ported to MiniScript by Joe Strout (2023)
print "The object of this puzzle is to change this:"
print
print "X X X X X X X X X X"
print
print "to this:"
print
print "O O O O O O O O O O"
print
print "By typing the number corresponding to the position of the"
print "letter on some numbers, one position will change, on"
print "others, two will change. To reset line to all X's, type 0"
print "(zero) and to start over in the middle of a game, type "
print "11 (eleven)."
print
startNewGame = function
globals.q = rnd
globals.guesses = 0
print "Here is the starting line of X's."
print
print "1 2 3 4 5 6 7 8 9 10"
print "X X X X X X X X X X"
print
end function
getInput = function
while true
n = input("Input the number: ").val
if n == floor(n) and 0 <= n <= 11 then break
print "Illegal entry--try again."
end while
return n
end function
startNewGame
while true
A = [""] + ["X"] * 10 // (include empty 0th element so we can index 1-based
m = 0 // (previous input)
while true
n = getInput
if n == 11 then
startNewGame
continue
else if n == 0 then
A = ["X"] * 10
continue
end if
if n != m then
// when user enters a different number from previous time
m = n
if A[n] == "O" then A[n] = "X" else A[n] = "O"
while m == n
r = tan(q + n/q - n) - sin(q/n) + 336*sin(8*n)
n = floor(10 * (r - floor(r)))
if A[n] != "O" then
A[n] = "O"
break
end if
A[n] = "X"
end while
else
// when n == m, i.e., user entered the same number twice in a row
while m == n
if A[n] == "O" then A[n] = "X" else A[n] = "O"
r = 0.592 * (1 / tan(q/n + q)) / sin(n*2 + q) - cos(n)
n = floor(10 * (r - floor(r)))
if A[n] != "O" then
A[n] = "O"
break
end if
A[n] = "X"
end while
end if
print "1 2 3 4 5 6 7 8 9 10"
print A[1:].join
guesses += 1
if A[1:] == ["O"]*10 then break
end while
if guesses <= 12 then
print "Very good. You guessed it in only " + guesses + " guesses."
else
print "Try harder next time. It took you " + guesses + " guesses."
end if
yesNo = input("Do you want to try another puzzle? ").lower
if not yesNo or yesNo[0] == "n" then break
print
end while
@@ -0,0 +1,34 @@
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 football.ms
```or
```
miniscript ftball.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 "football"
run
```or
```
load "ftball"
run
```
#### Apology from the Translator
These MiniScript programs were actually ported from the JavaScript ports of the original BASIC programs. I did that because the BASIC code (of both programs) was incomprehensible spaghetti. The JavaScript port, however, was essentially the same — and so are the MiniScript ports. The very structure of these programs makes them near-impossible to untangle.
If I were going to write a football simulation from scratch, I would approach it very differently. But in that case I would have either a detailed specification of how the program should behave, or at least enough understanding of American football to design it myself as I go. Neither is the case here (and we're supposed to be porting the original programs, not making up our own).
So, I'm sorry. Please take these programs as proof that you can write bad code even in the most simple, elegant languages. And I promise to try harder on future translations!
@@ -0,0 +1,402 @@
player_data = [17,8,4,14,19,3,10,1,7,11,15,9,5,20,13,18,16,2,12,6,
20,2,17,5,8,18,12,11,1,4,19,14,10,7,9,15,6,13,16,3]
aa = [0]*21
ba = [0]*21
ca = [0]*41
ha = [0]*3
ta = [0]*3
wa = [0]*3
xa = [0]*3
ya = [0]*3
za = [0]*3
ms = [null, "",""]
da = [0]*3
ps = ["", "PITCHOUT","TRIPLE REVERSE","DRAW","QB SNEAK","END AROUND",
"DOUBLE REVERSE","LEFT SWEEP","RIGHT SWEEP","OFF TACKLE",
"WISHBONE OPTION","FLARE PASS","SCREEN PASS",
"ROLL OUT OPTION","RIGHT CURL","LEFT CURL","WISHBONE OPTION",
"SIDELINE PASS","HALF-BACK OPTION","RAZZLE-DAZZLE","BOMB!!!!"]
globals.p = 0
globals.t = 0
printFieldHeaders = function
print "TEAM 1 [0 10 20 30 40 50 60 70 80 90 100] TEAM 2"
print
end function
printSeparator = function
print "+" * 67
end function
showBall = function
print " " * (da[t] + 5 + p / 2) + ms[t]
printFieldHeaders
end function
showScores = function
print
print "TEAM 1 SCORE IS " + ha[1]
print "TEAM 2 SCORE IS " + ha[2]
print
if ha[t] >= e then
print "TEAM " + t + " WINS*******************"
return true
end if
return false
end function
losePossession = function
print
print "** LOSS OF POSSESSION FROM TEAM " + t + " TO TEAM " + ta[t]
print
printSeparator
print
globals.t = ta[t]
end function
touchdown = function
print
print "TOUCHDOWN BY TEAM " + t + " *********************YEA TEAM"
q = 7
if rnd <= 0.1 then
q = 6
print "EXTRA POINT NO GOOD"
else
print "EXTRA POINT GOOD"
end if
ha[t] += q
end function
askYesNo = function(prompt)
while true
yn = input(prompt + "? ").lower
if not yn then continue
if yn[0] == "y" then return "YES"
if yn[0] == "n" then return "NO"
end while
end function
print " "*32 + "FOOTBALL"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
print "Presenting N.F.U. Football (No FORTRAN Used)"
print; print
if askYesNo("Do you want instructions") == "YES" then
print "This is a football game for two teams in which players must"
print "prepare a tape with a data statement (1770 for team 1,"
print "1780 for team 2) in which each team scrambles nos. 1-20"
print "These numbers are then assigned to twenty given plays."
print "A list of nos. and their plays is provided with"
print "both teams having the same plays. The more similar the"
print "plays the less yardage gained. Scores are given"
print "whenever scores are made. Scores may also be obtained"
print "by inputting 99,99 for play nos. To punt or attempt a"
print "field goal, input 77,77 for play numbers. Questions will be"
print "asked then. On 4th down, you will also be asked whether"
print "you want to punt or attempt a field goal. If the answer to"
print "both questions is no it will be assumed you want to"
print "try and gain yardage. Answer all questions Yes or No."
print "The game is played until players terminate (control-c)."
print "Please prepare a tape and run."
end if
print
e = input("Please input score limit on game: ").val
for i in range(1, 40)
if i <= 20 then
aa[player_data[i - 1]] = i
else
ba[player_data[i - 1]] = i - 20
end if
ca[i] = player_data[i - 1]
end for
l = 0
globals.t = 1
while true
print "TEAM " + t + " PLAY CHART"
print "NO. PLAY"
for i in range(1, 20)
print (ca[i+1] + " "*6)[:6] + ps[i]
end for
l += 20
globals.t = 2
print
print "TEAR OFF HERE----------------------------------------------"
for x in range(1, 11); print; end for
wait 3
if l != 20 then break
end while
playGame = function
da[1] = 0
da[2] = 3
ms[1] = "--->"
ms[2] = "<---"
ha[1] = 0
ha[2] = 0
ta[1] = 2
ta[2] = 1
wa[1] = -1
wa[2] = 1
xa[1] = 100
xa[2] = 0
ya[1] = 1
ya[2] = -1
za[1] = 0
za[2] = 100
globals.p = 0
printFieldHeaders
print "TEAM 1 defend 0 YD goal -- TEAM 2 defends 100 YD goal."
globals.t = floor(2 * rnd + 1)
print
print "The coin is flipped"
routine = 1
while true
if routine <= 1 then
globals.p = xa[t] - ya[t] * 40
printSeparator
print
print "Team " + t + " receives kick-off"
k = floor(26 * rnd + 40)
end if
if routine <= 2 then
globals.p = p - ya[t] * k
end if
if routine <= 3 then
if wa[t] * p >= za[t] + 10 then
print
print "Ball went out of endzone --automatic touchback--"
globals.p = za[t] - wa[t] * 20
if routine <= 4 then routine = 5
else
print "Ball went " + k + " yards. Now on " + p
showBall
end if
end if
if routine <= 4 then
if askYesNo("Team " + t + " do you want to runback") == "YES" then
k = floor(9 * rnd + 1)
r = floor(((xa[t] - ya[t] * p + 25) * rnd - 15) / k)
globals.p = p - wa[t] * r
print
print "Runback team " + t + " " + r + " yards"
g = rnd
if g < 0.25 then
losePossession
routine = 4
continue
else if ya[t] * p >= xa[t] then
touchdown
if showScores then return
globals.t = ta[t]
routine = 1
continue
else if wa[t] * p >= za[t] then
print
print "Safety against team " + t + " **********************OH-OH"
ha[ta[t]] += 2
if showScores then return
globals.p = za[t] - wa[t] * 20
if askYesNo("Team " + t + " do you want to punt instead of a kickoff") == "YES" then
print
print "Team " + t + " will punt"
g = rnd
if g < 0.25 then
losePossession
routine = 4
continue
end if
print
printSeparator
k = floor(25 * rnd + 35)
globals.t = ta[t]
routine = 2
continue
end if
touchdown
if showScores then return
globals.t = ta[t]
routine = 1
continue
else
routine = 5
continue
end if
else // player does not want to runback
if wa[t] * p >= za[t] then globals.p = za[t] - wa[t] * 20
end if
end if
if routine <= 5 then
d = 1
s = p
end if
if routine <= 6 then
print "=" * 67
print "TEAM " + t + " DOWN " + d + " ON " + p
if d == 1 then
if ya[t] * (p + ya[t] * 10) >= xa[t] then
c = 8
else
c = 4
end if
end if
if c != 8 then
print " "*27 + (10 - (ya[t] * p - ya[t] * s)) + " yards to 1st down"
else
print " "*27 + (xa[t] - ya[t] * p) + " yards"
end if
showBall
if d == 4 then routine = 8
end if
if routine <= 7 then
u = floor(3 * rnd - 1)
while true
str = input("Input offensive play, defensive play: ")
str = str.replace(",", " ").replace(" ", " ").split
if t == 1 then
p1 = str[0].val
p2 = str[1].val
else
p2 = str[0].val
p1 = str[1].val
end if
if p1 == 99 then
if showScores then return
continue
end if
if 1 <= p1 <= 20 and 1 <= p2 <= 20 then break
print "Illegal play number, check and"
end while
end if
if d == 4 or p1 == 77 then
if askYesNo("Does team " + t + " want to punt") == "YES" then
print
print "Team " + t + " will punt"
if rnd < 0.25 then
losePossession
routine = 4
continue
end if
print
printSeparator
k = floor(25 * rnd + 35)
globals.t = ta[t]
routine = 2
continue
end if
if askYesNo("Does team " + t + " want to attempt a field goal") == "YES" then
print
print "Team " + t + " will attempt a field goal"
if rnd < 0.025 then
losePossession
routine = 4
continue
else
f = floor(35 * rnd + 20)
print
print "Kick is " + f + " yards long"
globals.p = p - wa[t] * f
if rnd < 0.35 then
print "Ball went wide"
else if ya[t] * p >= xa[t] then
print "FIELD GOLD GOOD FOR TEAM " + t + " *********************YEA"
q = 3
ha[t] = ha[t] + q
if showScores then return
globals.t = ta[t]
routine = 1
continue
end if
print "Field goal unsuccesful team " + t + "-----------------too bad"
print
printSeparator
if ya[t] * p < xa[t] + 10 then
print
print "Ball now on " + p
globals.t = ta[t]
showBall
routine = 4
continue
else
globals.t = ta[t]
routine = 3
continue
end if
end if
else
routine = 7
continue
end if
end if
y = floor(abs(aa[p1] - ba[p2]) / 19 * ((xa[t] - ya[t] * p + 25) * rnd - 15))
print
if t == 1 and aa[p1] < 11 or t == 2 and ba[p2] < 11 then
print "The ball was run"
else if u == 0 then
print "Pass incomplete team " + t
y = 0
else
if rnd <= 0.025 and y > 2 then
print "Pass completed"
else
print "Quarterback scrambled"
end if
end if
globals.p = p - wa[t] * y
print
print "Net yards gained on down " + d + " are " + y
if rnd <= 0.025 then
losePossession
routine = 4
continue
else if ya[t] * p >= xa[t] then
touchdown
if showScores then return
globals.t = ta[t]
routine = 1
continue
else if wa[t] * p >= za[t] then
print
print "SAFETY AGAINST TEAM " + t + " **********************OH-OH"
ha[ta[t]] = ha[ta[t]] + 2
if showScores then return
globals.p = za[t] - wa[t] * 20
if askYesNo("Team " + t + " do you want to punt instead of a kickoff") == "YES" then
print
print "Team " + t + " will punt"
if rnd < 0.25 then
losePossession
routine = 4
continue
end if
print
printSeparator
k = floor(25 * rnd + 35)
globals.t = ta[t]
routine = 2
continue
end if
touchdown
if showScores then return
globals.t = ta[t]
routine = 1
else if ya[t] * p - ya[t] * s >= 10 then
routine = 5
else
d += 1
if d != 5 then
routine = 6
else
print
print "Conversion unsuccessful team " + t
globals.t = ta[t]
print
printSeparator
routine = 5
end if
end if
end while
end function
playGame
@@ -0,0 +1,431 @@
os = ["Dartmouth", ""]
sa = [0, 1]
ls = ["", "Kick","receive"," yard ","run back for ","ball on ",
"yard line"," simple run"," tricky run"," short pass",
" long pass","punt"," quick kick "," place kick"," loss ",
" no gain","gain "," touchdown "," touchback ","safety***",
"junk"]
p = 0
x = 0
x1 = 0
fnf = function(x); return 1 - 2 * p; end function
fng = function(z); return p * (x1 - x) + (1 - p) * (x - x1); end function
show_score = function
print
print "SCORE: " + sa[0] + " TO " + sa[1]
print
print
end function
show_position = function
if x <= 50 then
print ls[5] + os[0] + " " + x + " " + ls[6]
else
print ls[5] + os[1] + " " + (100 - x) + " " + ls[6]
end if
end function
offensive_td = function
print ls[17] + "***"
if rnd <= 0.8 then
sa[p] += 7
print "Kick is good."
else
print "Kick is off to the side"
sa[p] += 6
end if
show_score
print os[p] + " kicks off"
globals.p = 1 - p
end function
// Main program
main = function
print " "*33 + "FTBALL"
print " "*15 + "Creative Computing Morristown, New Jersey"
print
print
print "This is Dartmouth championship football."
print
print "You will quarterback Dartmouth. Call plays as follows:"
print "1= simple run; 2= tricky run; 3= short pass;"
print "4= long pass; 5= punt; 6= quick kick; 7= place kick."
print
os[1] = input("Choose your opponent: ").upper
os[0] = "DARMOUTH"
print
sa[0] = 0
sa[1] = 0
globals.p = floor(rnd * 2)
print os[p] + " won the toss"
if p != 0 then
print os[1] + " Elects to receive."
print
else
print "Do you elect to kick or receive? "
while true
str = input.lower
if str and (str[0] == "k" or str[0] == "r") then break
print "Incorrect answer. Please type 'kick' or 'receive'"
end while
if str[0] == "k" then e = 1 else e = 2
if e == 1 then globals.p = 1
end if
globals.t = 0
start = 1
while true
if start <= 1 then
x = 40 + (1 - p) * 20
end if
if start <= 2 then
y = floor(200 * ((rnd - 0.5))^3 + 55)
print " " + y + " " + ls[3] + " kickoff"
x = x - fnf(1) * y
if abs(x - 50) >= 50 then
print "Touchback for " + os[p] + "."
x = 20 + p * 60
start = 4
else
start = 3
end if
end if
if start <= 3 then
y = floor(50 * (rnd)^2) + (1 - p) * floor(50 * (rnd)^4)
x = x + fnf(1) * y
if abs(x - 50) < 50 then
print " " + y + " " + ls[3] + " runback"
else
print ls[4]
offensive_td
start = 1
continue
end if
end if
if start <= 4 then
// First down
show_position
end if
if start <= 5 then
x1 = x
d = 1
print
print "First down " + os[p] + "***"
print
print
end if
// New play
globals.t += 1
if t == 30 then
if rnd <= 1.3 then
print "Game delayed. Dog on field."
print
end if
end if
if t >= 50 and rnd <= 0.2 then break
if p != 1 then
// Opponent's play
if d <= 1 then
if rnd > 1/3 then z = 1 else z = 3
else if d != 4 then
if 10 + x - x1 < 5 or x < 5 then
if rnd > 1/3 then z = 1 else z = 3
else if x <= 10 then
a = floor(2 * rnd)
z = 2 + a
else if x <= x1 or d < 3 or x < 45 then
a = floor(2 * rnd)
z = 2 + a * 2
else
if (rnd > 1 / 4) then
z = 4
else
z = 6
end if
end if
else
if x <= 30 then
z = 5
else if 10 + x - x1 < 3 or x < 3 then
if rnd > 1/3 then z = 1 else z = 3
else
z = 7
end if
end if
else
while true
z = input("Next play? ").val
if 1 <= z <= 7 then break
print "Illegal play number, retype"
end while
end if
f = 0
print ls[z + 6] + ". "
r = rnd * (0.98 + fnf(1) * 0.02)
r1 = rnd
if z == 1 or z == 2 then // Simple Run or Tricky Run
done = false
if z == 1 then
y = floor(24 * (r - 0.5)^3 + 3)
if rnd >= 0.05 then
routine = 1
done = true
end if
else
y = floor(20 * r - 5)
if rnd > 0.1 then
routine = 1
done = true
end if
end if
if not done then
f = -1
x3 = x
x = x + fnf(1) * y
if abs(x - 50) < 50 then
print "*** Fumble after "
routine = 2
else
print "*** Fumble."
routine = 4
end if
end if
else if z == 3 or z == 4 then // Short Pass or Long Pass
if z == 3 then
y = floor(60 * (r1 - 0.5)^3 + 10)
else
y = floor(160 * ((r1 - 0.5))^3 + 30)
end if
if z == 3 and r < 0.05 or z == 4 and r < 0.1 then
if d != 4 then
print "Intercepted."
f = -1
x = x + fnf(1) * y
if abs(x - 50) >= 50 then
routine = 4
else
routine = 3
end if
else
y = 0
if rnd < 0.3 then
print "Batted down. ", ""
else
print "Incomplete. ", ""
end if
routine = 1
end if
else if z == 4 and r < 0.3 then
print "Passer tackled. ", ""
y = -floor(15 * r1 + 3)
routine = 1
else if z == 3 and r < 0.15 then
print "Passer taclked. ", ""
y = -floor(10 * r1)
routine = 1
else if z == 3 and r < 0.55 or z == 4 and r < 0.75 then
y = 0
if rnd < 0.3 then
print "Batted down. ", ""
else
print "Incomplete. ", ""
end if
routine = 1
else
print "Complete. ", ""
routine = 1
end if
else if z == 5 or z == 6 then // Punt or Quick Kick
y = floor(100 * ((r - 0.5))^3 + 35)
if (d != 4) then y = floor(y * 1.3)
print " " + y + " " + ls[3] + " punt"
if abs(x + y * fnf(1) - 50) < 50 and d >= 4 then
y1 = floor((r1)^2 * 20)
print " " + y1 + " " + ls[3] + " Run back"
y = y - y1
end if
f = -1
x = x + fnf(1) * y
if abs(x - 50) >= 50 then routine = 4 else routine = 3
else if z == 7 then // Place kick
y = floor(100 * ((r - 0.5))^3 + 35)
if r1 <= 0.15 then
print "Kick is blocked ***"
x = x - 5 * fnf(1)
globals.p = 1 - p
start = 4
continue
end if
x = x + fnf(1) * y
if abs(x - 50) >= 60 then
if r1 <= 0.5 then
print "Kick is off to the side."
print ls[18]
globals.p = 1 - p
x = 20 + p * 60
start = 4
continue
else
print "Field goal ***"
sa[p] = sa[p] + 3
show_score
print os[p] + " kicks off"
globals.p = 1 - p
start = 1
continue
end if
else
print "Kick is short."
if abs(x - 50) >= 50 then
// Touchback
print ls[18]
globals.p = 1 - p
x = 20 + p * 60
start = 4
continue
end if
globals.p = 1 - p
start = 3
continue
end if
end if
// Gain or loss
if routine <= 1 then
x3 = x
x = x + fnf(1) * y
if abs(x - 50) >= 50 then
routine = 4
end if
end if
if routine <= 2 then
if y != 0 then
print " " + abs(y) + " " + ls[3]
if (y < 0) then
yt = -1
else if y > 0 then
yt = 1
else
yt = 0
end if
print ls[15 + yt]
if abs(x3 - 50) <= 40 and rnd < 0.1 then
// Penalty
p3 = floor(2 * rnd)
print os[p3] + " offsides -- penalty of 5 yards."
print
print
if p3 != 0 then
print "Do you accept the penalty?"
while true
str = input.lower
if str and (str[0] == "y" or str[0] == "n") then break
print "Yype 'yes' or 'no'"
end while
if str[0] == "y" then
f = 0
d = d - 1
if (p != p3) then
x = x3 + fnf(1) * 5
else
x = x3 - fnf(1) * 5
end if
end if
else
// opponent's strategy on penalty
if ((p != 1 and (y <= 0 or f < 0 or fng(1) < 3 * d - 2)) or
(p == 1 and ((y > 5 and f >= 0) or d < 4 or fng(1) >= 10))) then
print "penalty refused."
else
print "penalty accepted."
f = 0
d = d - 1
if (p != p3) then
x = x3 + fnf(1) * 5
else
x = x3 - fnf(1) * 5
end if
end if
end if
routine = 3
end if
end if
end if
if routine <= 3 then
show_position
if f != 0 then
globals.p = 1 - p
start = 5
continue
else if fng(1) >= 10 then
start = 5
continue
else if d == 4 then
globals.p = 1 - p
start = 5
continue
else
d += 1
print "DOWN: " + d + " "
if (x1 - 50) * fnf(1) >= 40 then
print "Goal to go"
else
print "Yards to go: " + (10 - fng(1))
end if
print
print
start = 6
continue
end if
end if
if routine <= 4 then
// Ball in end-zone
e = (x >= 100)
case = 1 + e - f * 2 + p * 4
if case == 1 or case == 5 then
// Safety
sa[1 - p] = sa[1 - p] + 2
print ls[19]
show_score
print os[p] + " kicks off from its 20 yard line."
x = 20 + p * 60
globals.p = 1 - p
start = 2
continue
end if
if case == 3 or case == 6 then
// defensive td
print ls[17] + "for " + os[1 - p] + "***"
globals.p = 1 - p
end if
if case == 3 or case == 6 or case == 2 or case == 8 then
// offensive td
print ls[17] + "***"
if rnd <= 0.8 then
sa[p] = sa[p] + 7
print "kick is good."
else
print "kick is off to the side"
sa[p] = sa[p] + 6
end if
show_score
print os[p] + " kicks off"
globals.p = 1 - p
start = 1
continue
end if
if case == 4 or case == 7 then
// Touchback
print ls[18]
globals.p = 1 - p
x = 20 + p * 60
start = 4
continue
end if
end if
end while
print "END OF GAME ***"
print "FINAL SCORE: " + os[0] + ": " + sa[0] + " " + os[1] + ": " + sa[1]
end function
main
@@ -0,0 +1,19 @@
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 furtrader.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 "furtrader"
run
```
@@ -0,0 +1,171 @@
print " "*31 + "Fur Trader"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
furs = [0,0,0,0] // how many of each type of fur you have
value = [0,0,0,0] // value of each type of fur
furNames = "mink beaver ermine fox".split
getYesNo = function
while true
ans = input("Answer yes or no: ").upper
if not ans then continue
if ans[0] == "Y" then return "YES"
if ans[0] == "N" then return "NO"
end while
end function
printInstructions = function
print "You are the leader of a French fur trading expedition in "
print "1776 leaving the Lake Ontario area to sell furs and get"
print "supplies for the next year. You have a choice of three"
print "forts at which you may trade. The cost of supplies"
print "and the amount you receive for your furs will depend"
print "on the fort that you choose."
print
end function
pickFort = function
print
while true
print "You may trade your furs at fort 1, fort 2,"
print "or fort 3. Fort 1 is Fort Hochelaga (Montreal)"
print "and is under the protection of the French army."
print "Fort 2 is Fort Stadacona (Quebec) and is under the"
print "protection of the French Army. However, you must"
print "make a portage and cross the Lachine rapids."
print "Fort 3 is Fort New York and is under Dutch control."
print "You must cross through Iroquois land."
b = input("Answer 1, 2, or 3: ").val
if b == 1 then
print "You have chosen the easiest route. However, the fort"
print "is far from any seaport. The value"
print "you receive for your furs will be low and the cost"
print "of supplies higher than at Forts Stadacona or New York."
else if b == 2 then
print "You have chosen a hard route. It is, in comparsion,"
print "harder than the route to Hochelaga but easier than"
print "the route to New York. You will receive an average value"
print "for your furs and the cost of your supplies will be average."
else if b == 3 then
print "You have chosen the most difficult route. At"
print "Fort New York you will receive the highest value"
print "for your furs. The cost of your supplies"
print "will be lower than at all the other forts."
else
continue
end if
print "Do you want to trade at another fort?"
if getYesNo == "NO" then return b
end while
end function
visitFort = function(fort)
print
if fort == 1 then
value[0] = floor((.2*rnd+.7)*100+.5)/100
value[2] = floor((.2*rnd+.65)*100+.5)/100
value[1] = floor((.2*rnd+.75)*100+.5)/100
value[3] = floor((.2*rnd+.8)*100+.5)/100
print "Supplies at Fort Hochelaga cost $150.00."
print "Your travel expenses to Hochelaga were $10.00."
globals.money -= 150 + 10
else if fort == 2 then
value[0] = floor((.3*rnd+.85)*100+.5)/100
value[2] = floor((.15*rnd+.8)*100+.5)/100
value[1] = floor((.2*rnd+.9)*100+.5)/100
p = floor(10*rnd)+1
if p <= 2 then
furs[1] = 0
print "Your beaver were too heavy to carry across"
print "the portage. You had to leave the pelts, but found"
print "them stolen when you returned."
else if p <= 6 then
print "You arrived safely at Fort Stadacona."
else if p <= 8 then
for j in range(0,3); furs[j] = 0; end for
print "Your canoe upset in the Lachine rapids. You"
print "lost all your furs."
else if furs[3] then
furs[3] = 0
print "Your fox pelts were not cured properly."
print "No one will buy them."
end if
print "Supplies at Fort Stadacona cost $125.00."
print "Your travel expenses to Stadacona were $15.00."
globals.money -= 125 + 15
else
value[0] = floor((.15*rnd+1.05)*100+.5)/100
value[3] = floor((.25*rnd+1.1)*100+.5)/100
p = floor(10*rnd)+1
if p <= 2 then
print "You were attacked by a party of Iroquois."
print "All people in your trading group were"
print "killed. This ends the game."
globals.gameOver = true
return
else if p<=6 then
print "You were lucky. You arrived safely"
print "at Fort New York."
else if p<=8 then
for j in range(0,3); furs[j] = 0; end for
print "You narrowly escaped an iroquois raiding party."
print "However, you had to leave all your furs behind."
else
value[1] /= 2
value[0] /= 2
print "Your mink and beaver were damaged on your trip."
print "You receive only half the current price for these furs."
end if
print "Supplies at New York cost $80.00."
print "Your travel expenses to New York were $25.00."
globals.money -= 80 + 25
end if
end function
printInstructions
gameOver = false
money=600
while not gameOver
print "Do you wish to trade furs?"
if getYesNo == "NO" then break
value[2]=floor((.15*rnd+.95)*100+.5)/100 // ermine value
value[1]=floor((.25*rnd+1.00)*100+.5)/100 // beaver value
print
print "You have $" + money + " savings."
print "And 190 furs to begin the expedition."
print
print "Your 190 furs are distributed among the following"
print "kinds of pelts: mink, beaver, ermine and fox."
print
furs = [0,0,0,0]
for j in range(0, 3)
furs[j] = input("How many " + furNames[j] + " do you have? ").val
if furs.sum >= 190 then break
end for
if furs.sum > 190 then
print "You may not have that many furs."
print "Do not try to cheat. I can add."
print "You must start again."
continue
end if
fort = pickFort
visitFort fort
if gameOver then break
print
for j in [1, 3, 2, 0]
if not furs[j] then continue
revenue = value[j] * furs[j]
print "Your " + furNames[j] + " sold for $" + revenue + "."
money += revenue
end for
print
print "You now have $" + money + " including your previous savings."
end while
@@ -0,0 +1,19 @@
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 golf.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 "golf"
run
```
@@ -0,0 +1,303 @@
print " "*34 + "Golf"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
print "Welcome to the creative computing country club,"
print "an eighteen hole championship layout located a short"
print "distance from scenic downtown Morristown. The"
print "commentator will explain the game as you play."
print "Enjoy your game; see you at the 19th hole..."
print;print
l = [0] * 11
holesInCourse=18
totalScore=0
totalPar=0
dubChance=.8
s2=0
curHole=1
getHoleData = function(hole)
// data for all the holes: distance, par, locOnLeft, and locOnRight for each one
data = [
361,4,4,2,389,4,3,3,206,3,4,2,500,5,7,2,
408,4,2,4,359,4,6,4,424,4,4,2,388,4,4,4,
196,3,7,2,400,4,7,2,560,5,7,2,132,3,2,2,
357,4,4,4,294,4,2,4,475,5,2,3,375,4,4,2,
180,3,6,2,550,5,6,6]
i = (hole-1) * 4
globals.distance = data[i]
globals.par = data[i+1]
globals.locOnRight = data[i+2]
globals.locOnLeft = data[i+3]
end function
startHole = function(hole)
getHoleData hole
print
print "You are at the tee off hole " + hole + " distance " + distance + " yards, par " + par
globals.totalPar += par
print "On your right is ", ""
printLocation locOnRight
print "On your left is ", ""
printLocation locOnLeft
end function
// Get player's handicap
while true
handicap = input("What is your handicap? ").val
if 0 <= handicap <= 30 then break
print "PGA handicaps range from 0 to 30."
end while
// Get player's weak point
while true
print "Difficulties at golf include:"
print "0=hook, 1=slice, 2=poor distance, 3=trap shots, 4=putting"
weakness = input("Which one (only one) is your worst? ").val
if 0 <= weakness <= 4 then break
end while
// End a sentence by printing the name of the given location
printLocation = function(locIdx)
if locIdx < 1 or locIdx > 6 then
print "out of bounds."
else
print ["fairway.", "rough.", "trees.", "adjacent fairway.",
"trap.", "water."][locIdx-1]
end if
end function
// Print score for one hole (plus total), and some praise or advice.
printScore = function(hole, score, par, totalScore, totalPar)
print "Your score on hole " + hole + " was " + score
print "Total par for " + hole + " holes is " + totalPar + " Your total is " + totalScore
if hole == holesInCourse then return
if score > par+2 then
print "Keep your head down."
else if score == par then
print "A par. Nice going."
else if score == par-1 then
print "A birdie."
else if score == 1 then
print "A hole in one."
else if score == par-2 then
print "A great big eagle."
end if
end function
// Print club advice -- but only once.
clubAdviceGiven = false
printClubAdvice = function
if clubAdviceGiven then return // (already done)
globals.clubAdviceGiven = true
print "Selection of clubs"
print "yardage desired suggested clubs"
print "200 to 280 yards 1 to 4"
print "100 to 200 yards 19 to 13"
print " 0 to 100 yards 29 to 23"
end function
doPenalty = function
print "Penalty stroke assessed. Hit from previous location."
globals.score += 1
globals.j += 1
globals.curLoc = 1
globals.distance = prevDistance
end function
// Try to get out of a trap. Return true if succeeded, false if failed.
doTrapShot = function
if weakness == 3 then
if rnd <= dubChance then
globals.dubChance *= 0.2
print "Shot dubbed, still in trap."
return false
end if
globals.dubChance = 0.8
end if
globals.distToPin = 1 + (3*floor((80/(40-handicap))*rnd))
return true
end function
getClub = function
//print "DEBUG: getClub, with curLoc=" + curLoc
while true
club = input("What club do you choose? ").val
print
if club < 1 or club > 29 then continue
if club > 4 and club < 12 then
print "That club is not in the bag."
continue
end if
if club >= 12 then club -= 6
if curLoc <= 5 or club == 14 or club == 23 then break
print "That club is not in the bag."
print
continue
end while
return club
end function
getSwing = function(club)
if club <= 13 then return 1 // (full swing)
while true
print "Now gauge your distance by a percentage (1 to 100)"
swing = input("of a full swing? ").val / 100
print
if 0 <= swing <= 1 then return swing
// Given an invalid swing input, the original BASIC code would
// print "That club is not in the bag" and go back to choosing a club.
// But that is convoluted spaghetti, and I'm not doing it.
end while
end function
playOneHole = function
q = 0 // counts certain kinds of shots on every third hole (?)
distanceHit = 0
offLine = 0
// shot loop -- take as many shots as you need for this hole
while true
if curLoc < 1 then curLoc = 1
if curLoc > 6 then
print "Your shot went out of bounds."
doPenalty
distanceHit = 0
else if curLoc > 5 then
print "Your shot went into the water."
doPenalty
distanceHit = 0
end if
if score > 0 and distanceHit then
print "Shot went " + distanceHit + " yards. It's " + distToPin + " yards from the cup."
print "Ball is " + floor(offLine) + " yards off line... in ", ""
printLocation curLoc
end if
printClubAdvice
club = getClub
swing = getSwing(club)
globals.score += 1
if curLoc == 5 and not doTrapShot then continue
if club > 14 then club -= 10
//print "DEBUG Club:"+club + " Swing:"+swing + " Weakness:"+weakness
if curHole % 3 == 0 then
if s2 + q + (10*(curHole-1)/18) < (curHole-1)*(72+((handicap+1)/.85))/18 then
q += 1
if score % 2 and distance >= 95 then
globals.distance -= 75
distanceHit = 0
print "Ball hit tree - bounced into rough " + distance + " yards from hole."
continue
end if
end if
end if
if club >= 4 and curLoc == 2 then
print "You dubbed it."
distanceHit = 35
else if score > 7 and distance < 200 then
// user is really sucking, let's cut them a break
putt 1 + (3 * floor((80/(40-handicap))*rnd))
return
else
//print "DEBUG: SWING with handicap:" + handicap + " club:" + club
distanceHit = floor(((30-handicap)*2.5+187-((30-handicap)*.25+15)*club/2)+25*rnd)
distanceHit = floor(distanceHit*swing)
if weakness == 2 then distanceHit = floor(.85*distanceHit)
end if
offLine = (rnd/.8)*(2*handicap+16)*abs(tan(distanceHit*.0035))
distToPin = floor(sqrt(offLine^2+abs(distance-distanceHit)^2))
//print "DEBUG distance:"+distance+"; distanceHit:"+distanceHit+"; distToPin:"+distToPin+"; offLine:"+offLine
if distanceHit > distance and distToPin >= 20 then print "Too much club. You're past the hole."
globals.prevDistance = distance
globals.distance = distToPin
if distToPin > 27 then
if offLine < 30 or j > 0 then
curLoc = 1
continue
end if
// hook or slice
s9 = (s2+1)/15
if weakness == 0 then
isSlice = floor(s9) == s9
else
isSlice = not floor(s9) == s9
end if
if isSlice then
print "You sliced- "
curLoc = locOnRight
else
print "You hooked- "
curLoc = locOnLeft
end if
if offLine > 45 then print "badly."
else if distToPin > 20 then
curLoc = 5
else if distToPin > .5 then
globals.curLoc = 8 // on the green!
putt distToPin * 3 // (convert yards to feet, and putt)
return
else
curLoc = 9
print "You holed it."
print
globals.curHole += 1
return
end if
end while
end function
putt = function(distToPin)
puttAttempts = 0
while true
distToPin = abs(floor(distToPin))
print "On green, " + distToPin + " feet from the pin."
i = input("Choose your putt potency (1 to 13): ").val
globals.score += 1
if score+1 - par > handicap*0.072 + 2 or puttAttempts > 2 then break
puttAttempts += 1
if weakness == 4 then
distToPin -= i*(4+1*rnd)+1
else
distToPin -= i*(4+2*rnd)+1.5
end if
if -2 <= distToPin <= 2 then break
if distToPin < 0 then
print "Passed by cup."
else
print "Putt short."
end if
end while
print "You holed it."
print
return
end function
// main loop
while true
curLoc = 0
j = 0
s2 += 1
if curHole > 1 then
end if
print
score = 0
startHole curHole
playOneHole
totalScore += score
printScore curHole, score, par, totalScore, totalPar
if curHole == holesInCourse then break
curHole += 1
end while
@@ -0,0 +1,19 @@
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 gomoko.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 "gomoko"
run
```
@@ -0,0 +1,94 @@
print " "*33 + "Gomoku"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
print "Welcome to the Oriental game of Gomoko."
print; print "The game is played on an N by N grid of a size"
print "that you specify During your play, you may cover one grid"
print "intersection with a marker. The object of the game is to get"
print "5 adjacent markers in a row -- horizontally, vertically, or"
print "diagonally. On the board diagram, your moves are marked"
print "with a '1' and the computer moves with a '2'."
print; print "The computer does not keep track of who has won."
print "To end the game, type -1,-1 for your move."; print
inBounds = function(x,y)
return 0 < x <= n and 0 < y <= n
end function
empty = function(x,y)
return A[x][y] == 0
end function
printBoard = function
for y in range(1,n)
print A[y][1:n+1].join
end for
print
end function
doPlayerMove = function
while true
inp = input("Your play (i,j)? ").replace(" ", "").split(",")
print
if inp.len != 2 then continue
x = inp[0].val; y = inp[1].val
if x == -1 then return false
if not inBounds(x,y) then
print "Illegal move. Try again..."
else if not empty(x,y) then
print "Square occupied. Try again..."
else
break
end if
end while
A[x][y] = 1
globals.lastPlayerMove = [x,y]
return true
end function
doComputerMove = function
// Computer tries a move near the player's last move
for e in range(-1,1)
for f in range(-1,1)
if e==0 and f==0 then continue
x = lastPlayerMove[0] + e; y = lastPlayerMove[1] + f
if inBounds(x,y) and empty(x,y) then
A[x][y] = 2
return
end if
end for
end for
// Computer tries a random move
while true
x = floor(n * rnd + 1); y = floor(n * rnd + 1)
if empty(x,y) then break
end while
A[x][y] = 2
end function
playGame = function
while true
globals.n = input("What is your board size (min 7/ max 19)? ").val
if 7 <= n <= 19 then break
print "I said, the minimum is 7, the maximum is 19."
end while
globals.A = []
for i in range(0,19)
A.push [0]*20
end for
print; print "We alternate moves. You go first..."; print
while true
if not doPlayerMove then return
doComputerMove
printBoard
end while
end function
// Main loop
while true
playGame
print; print "Thanks for the game!!"
q = input("Play again (1 for Yes, 0 for No)? ").val
if q != 1 then break
end while
@@ -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:
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 guess.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 "guess"
run
```
3. "Try-It!" page on the web:
Go to https://miniscript.org/tryit/, clear the default program from the source code editor, paste in the contents of guess.ms, and click the "Run Script" button.
@@ -0,0 +1,59 @@
setup = function
print " "*33 + "GUESS"
print " "*15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
print; print; print
print "This is a number guessing game. I'll think"
print "of a number between 1 and any limit you want."
print "Then you have to guess what it is."
print
while true
globals.limit = input("What limit do you want? ").val
if limit > 1 then break
print "Please enter a number greater than 1."
end while
globals.par = floor(log(limit, 2)) + 1
end function
printGap = function
for i in range(1, 5)
print
end for
end function
doOneGame = function
rightAnswer = ceil(rnd * limit)
print "I'm thinking of a number between 1 and " + limit
print "Now you try to guess what it is."
guess = 0
while true
guess = guess + 1
num = input("Your guess: ").val
if num <= 0 then
printGap
setup
return
end if
if num == rightAnswer then
print "That's it! You got it in " + guess + " tries."
if guess < par then
print "Very good."
else if guess == par then
print "Good."
else
print "You should have been able to get it in only " + par + "."
end if
printGap
return
end if
if num > rightAnswer then
print "Too high. Try a smaller answer."
else
print "Too low. Try a bigger answer."
end if
end while
end function
setup
while true
doOneGame
end while
@@ -0,0 +1,19 @@
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 gunner.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 "gunner"
run
```
@@ -0,0 +1,78 @@
print " "*30 + "Gunner"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
print "You are the officer-in-charge, giving orders to a gun"
print "crew, telling them the degrees of elevation you estimate"
print "will place a projectile on target. A hit within 100 yards"
print "of the target will destroy it."; print
// Select a target and give the player up to 5 tries to hit it.
// Return the number of shots taken, or set globals.gameOver to true.
playOneTarget = function(maxRange)
globals.gameOver = false
targetDist = floor(maxRange * (.1 + .8 * rnd))
shot = 0
print "Distance to the target is " + targetDist + " yards."
print
while true
print
degrees = input("Elevation? ").val
if degrees > 89 then
print "Maximum elevation is 89 degrees."
continue
else if degrees < 1 then
print "Minimum elevation is one degree."
continue
end if
shot += 1
if shot >= 6 then
globals.gameOver = true
return
end if
radiansX2 = 2 * degrees * pi/180
throw = maxRange * sin(radiansX2)
diff = floor(targetDist - throw)
if abs(diff) < 100 then
print "*** TARGET DESTROYED *** " + shot + " rounds of ammunition expended."
return shot
end if
if diff > 0 then
print "Short of target by " + diff + " yards."
else
print "Over target by " + abs(diff) + " yards."
end if
end while
end function
playOneGame = function
maxRange = floor(40000*rnd + 20000)
print "Maximum range of your gun is " + maxRange + " yards."
shots = 0
for targetNum in range(1,4)
shots += playOneTarget(maxRange)
if gameOver then break
if targetNum < 4 then
print
print "The forward observer has sighted more enemy activity..."
end if
end for
if gameOver then
print; print "Boom !!!! You have just been destroyed"
print "by the enemy."; print; print; print
else
print; print; print "Total rounds expended were: " + shots
end if
if shots > 18 or gameOver then
print "Better go back to font sill for refresher training!"
else
print "Nice shooting !!"
end if
end function
// Main loop
while true
playOneGame
print; yn = input("Try again (Y or N)? ").upper
if not yn or yn[0] != "Y" then break
end while
print; print "OK. Return to base camp."
@@ -0,0 +1,19 @@
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 hammurabi.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 "hammurabi"
run
```
@@ -0,0 +1,190 @@
print " "*32 + "Hamurabi"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
print "Try your hand at governing ancient Sumeria"
print "for a ten-year term of office."; print
eol = char(10)
game = {}
game.z = 0 // year
game.p = 95
game.s = 2800 // bushels in store
game.h = 3000
game.e = game.h - game.s // bushels eaten by rats
game.food = 0 // bushels given to people to eat
game.y = 3 // value (in bushels) per acre
game.a = game.h / game.y // acres owned
game.i = 5 // immigration/births
game.d = 0 // how many starved this year
game.d1 = 0 // total starved over the whole game
game.p1 = 0 // average % of population starved per year
game.q = 1 // if negative, then a plague strikes
startYear = function
print; print; print "Hamurabi: I beg to report to you,"
game.z += 1
print "In year " + game.z + ", " +
game.d + " people starved, " +
game.i + " came to the city,"
game.p += game.i
if game.q < 0 then
game.p = floor(game.p / 2)
print "A horrible plague struck! Half the people died."
end if
print "Population is now " + game.p + "."
print "The city now owns " + game.a + " acres."
print "You harvested " + game.y + " bushels per acre."
print "The rats ate " + game.e + " bushels."
print "You now have " + game.s + " bushels in store."; print
end function
exitGame = function
print; print char(7)*10
print "So long for now."; print
exit
end function
impeach = function
print "Due to this extreme mismanagement you have not only"
print "been impeached and thrown out of office but you have"
print "also been declared national fink!!!!"
exitGame
end function
getNumber = function(prompt, max, maxMsg)
while true
value = input(prompt + "? ").val
if value < 0 then
print; print "Hamurabi: I cannot do what you wish."
print "Get yourself another steward!"
exitGame
end if
if value <= max then return value
print "Hamurabi: Think again. " + maxMsg + " Now then,"
end while
end function
hint = function(msg)
// This was not in the original program. But if you want to make
// the game easier, uncomment this line:
//print msg
end function
min = function(a, b, c)
m = [a, b, c]
m.sort
return m[0]
end function
getDecisions = function
// buy/sell land
c = floor(10 * rnd); game.y = c + 17
print "Land is trading at " + game.y + " bushels per acre."
qty = getNumber("How many acres do you wish to buy",
floor(game.s / game.y), "You have only" + eol + game.s + " bushels of grain.")
if qty > 0 then
game.a += qty
game.s -= game.y * qty
else
qty = getNumber("How many acres do you wish to sell",
game.a, "You own only" + eol + game.a + " acres.")
game.a -= qty
game.s += game.y * qty
end if
// feed the people
hint "Your people want " + (game.p * 20) + " bushels of food."
game.food = getNumber("How many bushels do you wish to feed your people",
game.s, "You have only" + eol + game.s + " bushels of grain.")
game.s -= game.food
// planting (a little more complicate because there are THREE limits)
hint "You can plant up to " +
min(game.a, floor(game.s * 2), floor(game.p*10-1)) + " acres."
game.d = 0
while game.a > 0 and game.s > 2
game.d = getNumber("How many acres do you wish to plant with seed",
game.a, "You own only " + game.a + " acres.")
// enough grain for seed? (each bushel can plant 2 acres)
if floor(game.d / 2) > game.s then
print "Hamurabi: Think again. You have only" + eol + game.s +
" bushels of grain. Now then,"
continue
end if
// enough people to tend the crops? (each person can tend 10 acres)
if game.d >= game.p * 10 then
print "But you have only " + game.p + " people to tend the fields! Now then,"
continue
end if
break
end while
game.s -= floor(game.d / 2)
end function
simulateYear = function
// A bountiful harvest!
c = floor(rnd * 5) + 1
game.y = c; game.h = game.d * game.y; game.e = 0
c = floor(rnd * 5) + 1
if c % 2 == 0 then
// rats are running wild!!
game.e = floor(game.s / c)
end if
game.s += game.h - game.e
// Let's have some babies
c = floor(rnd * 5) + 1
game.i = floor(c * (20 * game.a + game.s) / game.p / 100 + 1)
// How many people had full tummies?
c = floor(game.food / 20)
// Horros, a 15% chance of plague
game.q = floor(10 * (2 * rnd - 0.3))
if game.p < c then
game.d = 0
else
// starve enough for impeachment?
game.d = game.p - c
if game.d > 0.45 * game.p then
print; print "You starved " + game.d + " people in one year!!!"
impeach
end if
game.p1 = ((game.z - 1) * game.p1 + game.d * 100 / game.p) / game.z
game.p = c
game.d1 += game.d
end if
end function
printFinalResult = function
print "In your 10-year term of office, " + game.p1 + " percent of the"
print "population starved per year on the average, i.e., a total of"
print game.d1 + " people died!!"
acresPer = game.a / game.p
print "You started with 10 acres per person and ended with"
print acresPer + " acres per person."; print
if game.p1 > 33 or acresPer < 7 then impeach
if game.p1 > 10 or acresPer < 9 then
print "Your heavy-handed performance smacks of Nero and Ivan IV."
print "The people (remaining) find you an unpleasant ruler, and,"
print "frankly, hate your guts!!"
else if game.p1 > 3 or acresPer < 10 then
print "Your performance could have been somewhat better, but"
print "really wasn't too bad at all. " + floor(game.p * 0.8 * rnd) + " people"
print "would dearly like to see you assassinated but we all have our"
print "trivial problems."
else
print "A fantastic performance!! Charlemange, Disraeli, and"
print "Jefferson combined could not have done better!"
end if
end function
// Main loop
while true
startYear
if game.z == 11 then break
getDecisions
simulateYear
end while
printFinalResult
exitGame
@@ -1,119 +1,119 @@
10 PRINT TAB(32);"HAMURABI"
20 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
30 PRINT:PRINT:PRINT
10 PRINT TAB(32); "HAMURABI"
20 PRINT TAB(15); "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
30 PRINT : PRINT : PRINT
80 PRINT "TRY YOUR HAND AT GOVERNING ANCIENT SUMERIA"
90 PRINT "FOR A TEN-YEAR TERM OF OFFICE.":PRINT
95 D1=0: P1=0
100 Z=0: P=95:S=2800: H=3000: E=H-S
110 Y=3: A=H/Y: I=5: Q=1
210 D=0
215 PRINT:PRINT:PRINT "HAMURABI: I BEG TO REPORT TO YOU,": Z=Z+1
217 PRINT "IN YEAR";Z;",";D;"PEOPLE STARVED,";I;"CAME TO THE CITY,"
218 P=P+I
227 IF Q>0 THEN 230
228 P=INT(P/2)
90 PRINT "FOR A TEN-YEAR TERM OF OFFICE." : PRINT
95 D1 = 0 : P1 = 0
100 Z = 0 : P = 95 : S = 2800 : H = 3000 : E = H - S
110 Y = 3 : A = H / Y : I = 5 : Q = 1
210 D = 0
215 PRINT : PRINT : PRINT "HAMURABI: I BEG TO REPORT TO YOU," : Z = Z + 1
217 PRINT "IN YEAR "; Z; ","; D; " PEOPLE STARVED, "; I; " CAME TO THE CITY,"
218 P = P + I
227 IF Q > 0 THEN 230
228 P = INT(P / 2)
229 PRINT "A HORRIBLE PLAGUE STRUCK! HALF THE PEOPLE DIED."
230 PRINT "POPULATION IS NOW";P
232 PRINT "THE CITY NOW OWNS ";A;"ACRES."
235 PRINT "YOU HARVESTED";Y;"BUSHELS PER ACRE."
250 PRINT "THE RATS ATE";E;"BUSHELS."
260 PRINT "YOU NOW HAVE ";S;"BUSHELS IN STORE.": PRINT
270 IF Z=11 THEN 860
310 C=INT(10*RND(1)): Y=C+17
312 PRINT "LAND IS TRADING AT";Y;"BUSHELS PER ACRE."
230 PRINT "POPULATION IS NOW "; P
232 PRINT "THE CITY NOW OWNS "; A; " ACRES."
235 PRINT "YOU HARVESTED "; Y; " BUSHELS PER ACRE."
250 PRINT "THE RATS ATE "; E; " BUSHELS."
260 PRINT "YOU NOW HAVE "; S; " BUSHELS IN STORE." : PRINT
270 IF Z = 11 THEN 860
310 C = INT(10 * RND(1)) : Y = C + 17
312 PRINT "LAND IS TRADING AT "; Y; " BUSHELS PER ACRE."
320 PRINT "HOW MANY ACRES DO YOU WISH TO BUY";
321 INPUT Q: IF Q<0 THEN 850
322 IF Y*Q<=S THEN 330
321 INPUT Q : IF Q < 0 THEN 850
322 IF Y * Q <= S THEN 330
323 GOSUB 710
324 GOTO 320
330 IF Q=0 THEN 340
331 A=A+Q: S=S-Y*Q: C=0
330 IF Q = 0 THEN 340
331 A = A + Q : S = S - Y * Q : C = 0
334 GOTO 400
340 PRINT "HOW MANY ACRES DO YOU WISH TO SELL";
341 INPUT Q: IF Q<0 THEN 850
342 IF Q<A THEN 350
341 INPUT Q : IF Q < 0 THEN 850
342 IF Q < A THEN 350
343 GOSUB 720
344 GOTO 340
350 A=A-Q: S=S+Y*Q: C=0
400 PRINT
350 A = A - Q : S = S + Y * Q : C = 0
400 PRINT
410 PRINT "HOW MANY BUSHELS DO YOU WISH TO FEED YOUR PEOPLE";
411 INPUT Q
412 IF Q<0 THEN 850
412 IF Q < 0 THEN 850
418 REM *** TRYING TO USE MORE GRAIN THAN IS IN SILOS?
420 IF Q<=S THEN 430
420 IF Q <= S THEN 430
421 GOSUB 710
422 GOTO 410
430 S=S-Q: C=1: PRINT
430 S = S - Q : C = 1 : PRINT
440 PRINT "HOW MANY ACRES DO YOU WISH TO PLANT WITH SEED";
441 INPUT D: IF D=0 THEN 511
442 IF D<0 THEN 850
441 INPUT D : IF D = 0 THEN 511
442 IF D < 0 THEN 850
444 REM *** TRYING TO PLANT MORE ACRES THAN YOU OWN?
445 IF D<=A THEN 450
445 IF D <= A THEN 450
446 GOSUB 720
447 GOTO 440
449 REM *** ENOUGH GRAIN FOR SEED?
450 IF INT(D/2)<=S THEN 455
450 IF INT(D / 2) <= S THEN 455
452 GOSUB 710
453 GOTO 440
454 REM *** ENOUGH PEOPLE TO TEND THE CROPS?
455 IF D<10*P THEN 510
460 PRINT "BUT YOU HAVE ONLY";P;"PEOPLE TO TEND THE FIELDS! NOW THEN,"
455 IF D < 10 * P THEN 510
460 PRINT "BUT YOU HAVE ONLY "; P; " PEOPLE TO TEND THE FIELDS! NOW THEN,"
470 GOTO 440
510 S=S-INT(D/2)
510 S = S - INT(D / 2)
511 GOSUB 800
512 REM *** A BOUNTIFUL HARVEST!
515 Y=C: H=D*Y: E=0
515 Y = C : H = D * Y : E = 0
521 GOSUB 800
522 IF INT(C/2)<>C/2 THEN 530
522 IF INT(C / 2) <> C / 2 THEN 530
523 REM *** RATS ARE RUNNING WILD!!
525 E=INT(S/C)
530 S=S-E+H
525 E = INT(S / C)
530 S = S - E + H
531 GOSUB 800
532 REM *** LET'S HAVE SOME BABIES
533 I=INT(C*(20*A+S)/P/100+1)
533 I = INT(C *(20 * A + S) / P / 100 + 1)
539 REM *** HOW MANY PEOPLE HAD FULL TUMMIES?
540 C=INT(Q/20)
540 C = INT(Q / 20)
541 REM *** HORROS, A 15% CHANCE OF PLAGUE
542 Q=INT(10*(2*RND(1)-.3))
550 IF P<C THEN 210
542 Q = INT(10 *(2 * RND(1) - 0.3))
550 IF P < C THEN 210
551 REM *** STARVE ENOUGH FOR IMPEACHMENT?
552 D=P-C: IF D>.45*P THEN 560
553 P1=((Z-1)*P1+D*100/P)/Z
555 P=C: D1=D1+D: GOTO 215
560 PRINT: PRINT "YOU STARVED";D;"PEOPLE IN ONE YEAR!!!"
552 D = P - C : IF D > 0.45 * P THEN 560
553 P1 =((Z - 1) * P1 + D * 100 / P) / Z
555 P = C : D1 = D1 + D : GOTO 215
560 PRINT : PRINT "YOU STARVED "; D; " PEOPLE IN ONE YEAR!!!"
565 PRINT "DUE TO THIS EXTREME MISMANAGEMENT YOU HAVE NOT ONLY"
566 PRINT "BEEN IMPEACHED AND THROWN OUT OF OFFICE BUT YOU HAVE"
567 PRINT "ALSO BEEN DECLARED NATIONAL FINK!!!!": GOTO 990
567 PRINT "ALSO BEEN DECLARED NATIONAL FINK!!!!" : GOTO 990
710 PRINT "HAMURABI: THINK AGAIN. YOU HAVE ONLY"
711 PRINT S;"BUSHELS OF GRAIN. NOW THEN,"
712 RETURN
720 PRINT "HAMURABI: THINK AGAIN. YOU OWN ONLY";A;"ACRES. NOW THEN,"
730 RETURN
800 C=INT(RND(1)*5)+1
801 RETURN
850 PRINT: PRINT "HAMURABI: I CANNOT DO WHAT YOU WISH."
711 PRINT S; "BUSHELS OF GRAIN. NOW THEN,"
712 RETURN
720 PRINT "HAMURABI: THINK AGAIN. YOU OWN ONLY "; A; " ACRES. NOW THEN,"
730 RETURN
800 C = INT(RND(1) * 5) + 1
801 RETURN
850 PRINT : PRINT "HAMURABI: I CANNOT DO WHAT YOU WISH."
855 PRINT "GET YOURSELF ANOTHER STEWARD!!!!!"
857 GOTO 990
860 PRINT "IN YOUR 10-YEAR TERM OF OFFICE,";P1;"PERCENT OF THE"
860 PRINT "IN YOUR 10-YEAR TERM OF OFFICE,"; P1; "PERCENT OF THE"
862 PRINT "POPULATION STARVED PER YEAR ON THE AVERAGE, I.E. A TOTAL OF"
865 PRINT D1;"PEOPLE DIED!!": L=A/P
865 PRINT D1; "PEOPLE DIED!!" : L = A / P
870 PRINT "YOU STARTED WITH 10 ACRES PER PERSON AND ENDED WITH"
875 PRINT L;"ACRES PER PERSON.": PRINT
880 IF P1>33 THEN 565
885 IF L<7 THEN 565
890 IF P1>10 THEN 940
892 IF L<9 THEN 940
895 IF P1>3 THEN 960
896 IF L<10 THEN 960
875 PRINT L; "ACRES PER PERSON." : PRINT
880 IF P1 > 33 THEN 565
885 IF L < 7 THEN 565
890 IF P1 > 10 THEN 940
892 IF L < 9 THEN 940
895 IF P1 > 3 THEN 960
896 IF L < 10 THEN 960
900 PRINT "A FANTASTIC PERFORMANCE!!! CHARLEMANGE, DISRAELI, AND"
905 PRINT "JEFFERSON COMBINED COULD NOT HAVE DONE BETTER!":GOTO 990
905 PRINT "JEFFERSON COMBINED COULD NOT HAVE DONE BETTER!" : GOTO 990
940 PRINT "YOUR HEAVY-HANDED PERFORMANCE SMACKS OF NERO AND IVAN IV."
945 PRINT "THE PEOPLE (REMAINING) FIND YOU AN UNPLEASANT RULER, AND,"
950 PRINT "FRANKLY, HATE YOUR GUTS!!":GOTO 990
950 PRINT "FRANKLY, HATE YOUR GUTS!!" : GOTO 990
960 PRINT "YOUR PERFORMANCE COULD HAVE BEEN SOMEWHAT BETTER, BUT"
965 PRINT "REALLY WASN'T TOO BAD AT ALL. ";INT(P*.8*RND(1));"PEOPLE"
965 PRINT "REALLY WASN'T TOO BAD AT ALL. "; INT(P * 0.8 * RND(1)); "PEOPLE"
970 PRINT "WOULD DEARLY LIKE TO SEE YOU ASSASSINATED BUT WE ALL HAVE OUR"
975 PRINT "TRIVIAL PROBLEMS."
990 PRINT: FOR N=1 TO 10: PRINT CHR$(7);: NEXT N
995 PRINT "SO LONG FOR NOW.": PRINT
999 END
990 PRINT : FOR N = 1 TO 10 : PRINT CHR$(7); : NEXT N
995 PRINT "SO LONG FOR NOW." : PRINT
999 END
@@ -0,0 +1,19 @@
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 hangman.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 "hangman"
run
```
@@ -0,0 +1,127 @@
print " "*32 + "Hangman"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
words = []
words += ["gum","sin","for","cry","lug","bye","fly"]
words += ["ugly","each","from","work","talk","with","self"]
words += ["pizza","thing","feign","fiend","elbow","fault","dirty"]
words += ["budget","spirit","quaint","maiden","escort","pickax"]
words += ["example","tension","quinine","kidney","replica","sleeper"]
words += ["triangle","kangaroo","mahogany","sergeant","sequence"]
words += ["moustache","dangerous","scientist","different","quiescent"]
words += ["magistrate","erroneously","loudspeaker","phytotoxic"]
words += ["matrimonial","parasympathomimetic","thigmotropism"]
// Note: on Mini Micro, you could instead do:
// words = file.readLines("/sys/data/englishWords.txt")
words.shuffle
addToPic = function(guessCount)
if guessCount == 1 then
print "First, we draw a head"
ps[3][6]="-"; ps[3][7]="-"; ps[3][8]="-"; ps[4][5]="("; ps[4][6]="."
ps[4][8]="."; ps[4][9]=")"; ps[5][6]="-"; ps[5][7]="-"; ps[5][8]="-"
else if guessCount == 2 then
print "Now we draw a body."
for i in range(6, 9); ps[i][7]="x"; end for
else if guessCount == 3 then
print "Next we draw an arm."
for i in range(4, 7); ps[i][i-1]="\"; end for
else if guessCount == 4 then
print "This time it's the other arm."
ps[4][11]="/"; ps[5][10]="/"; ps[6][9]="/"; ps[7][8]="/"
else if guessCount == 5 then
print "Now, let's draw the right leg."
ps[10][6]="/"; ps[11][5]="/"
else if guessCount == 6 then
print "This time we draw the left leg."
ps[10][8]="\"; ps[11][9]="\"
else if guessCount == 7 then
print "Now we put up a hand."
ps[3][11]="\"
else if guessCount == 8 then
print "Next the other hand."
ps[3][3]="/"
else if guessCount == 9 then
print "Now we draw one foot"
ps[12][10]="\"; ps[12][11]="-"
else if guessCount == 10 then
print "Here's the other foot -- you're hung!!"
ps[12][3]="-"; ps[12][4]="/"
end if
for i in range(1, 12)
print ps[i].join("")
end for
print
end function
doOneGame = function
usedLetters = []
globals.ps = []
for i in range(0, 12); ps.push [" "]*12; end for
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 + ")"
visibleWord = ["-"] * secretWord.len
wrongGuesses = 0
while true
print "Here are the letters you used:"
print usedLetters.join(",")
print
print visibleWord.join("")
print
guess = input("What is your guess? ").upper
guess = (guess + " ")[0]
if guess < "A" or guess > "Z" then continue
if usedLetters.indexOf(guess) != null then
print "You guessed that letter before!"
continue
end if
usedLetters.push guess
for i in visibleWord.indexes
if secretWord[i] == guess then visibleWord[i] = guess
end for
if visibleWord.indexOf("-") == null then
print "You found the word!"
return true
else if secretWord.indexOf(guess) != null then
print
print visibleWord.join("")
print
guess = input("What is your guess for the word? ").upper
if guess == secretWord then
print "Right!! It took you " + usedLetters.len + " guesses!"
return true
else
print "Wrong. Try another letter."
end if
print
else
print "Sorry, that letter isn't in the word."
wrongGuesses += 1
addToPic wrongGuesses
if wrongGuesses > 9 then
print "Sorry, you lose. The word was " + secretWord
return false
end if
end if
end while
end function
while true
if not words then
print "You did all the words!!"
break
end if
won = doOneGame
if won then
yn = input("Want another word? ").upper
else
yn = input("You missed that one. Do you want another word? ").upper
end if
if not yn or yn[0] != "Y" then break
end while
print
print "It's been fun! Bye for now."
@@ -0,0 +1,19 @@
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 hello.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 "hello"
run
```
@@ -0,0 +1,108 @@
print " "*33 + "Hello"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
print "Hello. My name is Creative Computer."
print
print
ns = input("What's your name? ")
print
print "Hi there, " + ns + ", are you enjoying yourself here?"
while true
bs = input.lower
print
if bs == "yes" then
print "I'm glad to hear that, " + ns + "."
print
break
else if bs == "no" then
print "Oh, I'm sorry to hear that, " + ns + ". Maybe we can"
print "brighten up your visit a bit."
break
else
print "Please answer 'yes' or 'no'. Do you like it here?"
end if
end while
print
print "Say, " + ns + ", I can solve all kinds of problems except"
print "those dealing with Greece. What kind of problems do"
print "you have (answer sex, health, money, or job)?"
while true
cs = input
print
if cs != "sex" and cs != "health" and cs != "money" and cs != "job" then
print "Oh, " + ns + ", your answer of " + cs + " is Greek to me."
else if cs == "job" then
print "I can sympathize with you " + ns + ". I have to work"
print "very long hours for no pay -- and some of my bosses"
print "really beat on my keyboard. My advice to you, " + ns + ","
print "is to open a retail computer store. It's great fun."
else if cs == "money" then
print "Sorry, " + ns + ", I'm broke too. Why don't you sell"
print "encyclopeadias or marry someone rich or stop eating"
print "so you won't need so much money?"
else if cs == "health" then
print "My advice to you " + ns + " is:"
print " 1. Take two asprin"
print " 2. Drink plenty of fluids (orange juice, not beer!)"
print " 3. Go to bed (alone)"
else
print "Is your problem too much or too little?"
while true
ds = input.lower
print
if ds == "too much" then
print "You call that a problem?!! I should have such problems!"
print "If it bothers you, " + ns + ", take a cold shower."
break
else if ds == "too little" then
print "Why are you here in suffern, " + ns + "? You should be"
print "in Tokyo or New York or Amsterdam or someplace with some"
print "real action."
break
else
print "Don't get all shook, " + ns + ", just answer the question"
print "with 'too much' or 'too little'. Which is it?"
end if
end while
end if
print
print "Any more problems you want solved, " + ns + "?"
es = input.lower
print
if es == "yes" then
print "What kind (sex, money, health, job)?"
else if es == "no" then
print "That will be $5.00 for the advice, " + ns + "."
print "Please leave the money on the terminal."
print
wait 2
print
print
while true
gs = input("Did you leave the money? ").lower
print
if gs == "yes" then
print "Hey, " + ns + "??? You left no money at all!"
print "You are cheating me out of my hard-earned living."
print
print "What a rip off, " + ns + "!!!"
print
break
else if gs == "no" then
print "That's honest, " + ns + ", but how do you expect"
print "me to go on with my psychology studies if my patient"
print "don't pay their bills?"
break
else
print "Your answer of '" + gs + "' confuses me, " + ns + "."
print "Please respond with 'yes' or 'no'."
end if
end while
break
end if
end while
print
print "Take a walk, " + ns + "."
print
print
@@ -0,0 +1,19 @@
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 hexapawn.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 "hexapawn"
run
```

Some files were not shown because too many files have changed in this diff Show More