Merge pull request #863 from JoeStrout/main

add MiniScript implementations of 14 programs
This commit is contained in:
Jeff Atwood
2023-07-08 12:46:28 -07:00
committed by GitHub
30 changed files with 961 additions and 2 deletions

View File

@@ -0,0 +1,16 @@
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
Conversion to [MiniScript](https://miniscript.org).
Ways to play:
1. Command-Line MiniScript:
Download for your system from https://miniscript.org/cmdline/, install, and then run the program with a command such as:
miniscript 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 BASIC program. Then, at the Mini Micro command prompt, enter:
load "craps"
run

View File

@@ -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

View File

@@ -0,0 +1,16 @@
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
Conversion to [MiniScript](https://miniscript.org).
Ways to play:
1. Command-Line MiniScript:
Download for your system from https://miniscript.org/cmdline/, install, and then run the program with a command such as:
miniscript 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 BASIC program. Then, at the Mini Micro command prompt, enter:
load "depthcharge.ms"
run

View File

@@ -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

View File

@@ -0,0 +1,16 @@
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
Conversion to [MiniScript](https://miniscript.org).
Ways to play:
1. Command-Line MiniScript:
Download for your system from https://miniscript.org/cmdline/, install, and then run the program with a command such as:
miniscript 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 BASIC program. Then, at the Mini Micro command prompt, enter:
load "diamond"
run

View File

@@ -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

View File

@@ -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 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 BASIC program. 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.

View File

@@ -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

View File

@@ -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 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 BASIC program. 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.

View File

@@ -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

View File

@@ -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 kinema.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 BASIC program. Then, at the Mini Micro command prompt, enter:
load "kinema"
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 kinema.ms, and click the "Run Script" button.

View File

@@ -0,0 +1,40 @@
// Kinema
//
// Ported from BASIC to MiniScript by Joe Strout
print " "*33 + "KINEMA"
print " "*15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
print; print; print
checkAnswer = function(prompt, correctValue)
answer = input(prompt).val
right = abs((answer - correctValue)/answer) < 0.15
if right then
print "Close enough!"
else
print "Not even close...."
end if
print "Correct answer is " + correctValue
return right
end function
doOneRun = function
print; print
rightCount = 0
V = 5 + floor(35*rnd)
print "A ball is thrown upwards at " + V + " meters per second."
print
rightCount += checkAnswer("How high will it go (in meters)? ", 0.05 * V^2)
rightCount += checkAnswer("How long until it returns (in seconds)? ", V/5)
t = 1 + floor(2*V*rnd)/10
rightCount += checkAnswer("What will its velocity be after " + t +
" seconds? ", V-10*t)
print
print rightCount + " right out of 3."
if rightCount >= 2 then print " Not bad."
end function
// main loop (press control-C to break out)
while true
doOneRun
end while

View File

@@ -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 letter.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 BASIC program. Then, at the Mini Micro command prompt, enter:
load "letter"
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 letter.ms, and click the "Run Script" button.

View File

@@ -0,0 +1,44 @@
// Letter Guessing Game
// Ported to MiniScript by Joe Strout, 2023
print " "*33 + "LETTER"
print " "*15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
print; print; print
print "Letter Guessing Game"; print
print "I'll think of a letter of the alphabet, A to Z."
print "Try to guess my letter and I'll give you clues"
print "as to how close you're getting to my letter."
// Function to play one round of the game
playOneGame = function
letter = char(65 + floor(rnd * 26))
guesses = 0
print; print "OK, I have a letter. Start guessing."
while true
print; guess = input("What is your guess? ")[:1].upper
guesses = guesses + 1
if guess == letter then
print; print "You got it in " + guesses + " guesses!!"
if guesses > 5 then
print "But it shouldn't take more than 5 guesses!"
else
print "Good job !!!!!"
print char(7) * 15
end if
return
else if guess < letter then
print "Too low. Try a higher letter."
else
print "Too high. Try a lower letter."
end if
end while
end function
// main loop -- press Control-C to exit
while true
print
playOneGame
print
print "Let's play again....."
end while

View File

@@ -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 nicomachus.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 BASIC program. Then, at the Mini Micro command prompt, enter:
load "nicomachus"
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 nicomachus.ms, and click the "Run Script" button.

View File

@@ -0,0 +1,45 @@
// Nicomachus
// originally by David Ahl
// Ported from BASIC to MiniScript by Joe Strout, 2023
print " "*33 + "NICOMA"
print " "*15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
print; print; print
print "Boomerang puzzle from Arithmetica of Nicomachus -- A.D. 90!"
// Get a yes/no (or at least y/n) response from the user.
askYesNo = function(prompt)
while true
answer = input(prompt)
a1 = answer.lower[:1]
if a1 == "y" or a1 == "n" then return a1
print "Eh? I don't understand '" + answer + "' Try 'yes' or 'no'."
end while
end function
doOne = function
print
print "Please think of a number between 1 and 100."
A = input("Your number divided by 3 has a remainder of: ").val
B = input("Your number divided by 5 has a remainder of: ").val
C = input("Your number divided by 7 has a remainder of: ").val
print
print "Let me think a moment..."
print
wait 1.5
D = 70*A + 21*B + 15*C
D = D % 105 // gets the remainder after dividing by 105
yesNo = askYesNo("Your number was " + D + ", right? ")
if yesNo == "y" then
print "How about that!"
else
print "I feel your arithmetic is in error."
end if
end function
// Main loop -- press Control-C to break
while true
doOne
print
print "Let's try another."
end while

View File

@@ -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 number.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 BASIC program. Then, at the Mini Micro command prompt, enter:
load "number"
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 number.ms, and click the "Run Script" button.

View File

@@ -0,0 +1,44 @@
// Number Game
// originally by Tom Adametx
// Ported from BASIC to MiniScript by Joe Strout, 2023
print " "*33 + "NUMBER"
print " "*15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
print; print; print
print "You have 100 points. By guessing numbers from 1 to 5, you"
print "can gain or lose points depending on how close you get to"
print "a random number selected by the computer."; print
print "You occasionally will get a jackpot which will double(!)"
print "your point count. You win when you get to 500 points."
print
P = 100
fnr = function; return ceil(5*rnd); end function
while true
guess = input("Guess a number from 1 to 5: ").val
R = fnr
S = fnr
T = fnr
U = fnr
V = fnr
if guess == R then
P = P - 5
else if guess == S then
P = P + 5
else if guess == T then
P = P+P
print "You hit the jackpot!!!"
else if guess == U then
P = P + 1
else if guess == V then
P = P - floor(P*0.5)
else if guess > 5 then
continue
end if
if P > 500 then
print "!!!!You win!!!! with " + P + " points."
break
end if
print "You have " + P + " points."; print
end while

View File

@@ -0,0 +1,16 @@
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
Conversion to [MiniScript](https://miniscript.org).
Ways to play:
1. Command-Line MiniScript:
Download for your system from https://miniscript.org/cmdline/, install, and then run the program with a command such as:
miniscript sinewave.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 BASIC program. Then, at the Mini Micro command prompt, enter:
load "sinewave"
run

View File

@@ -0,0 +1,15 @@
print " "*30 + "SINE WAVE"
print " "*15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
print; print; print; print; print
// Remarkable program by David Ahl, ported
// from BASIC to MiniScript by Joe Strout
B = 0
// start long loop
for t in range(0, 40, 0.25)
A = floor(26 + 25*sin(t))
print " "*A, ""
if not B then print "CREATIVE" else print "COMPUTING"
B = not B
wait 0.01
end for

View File

@@ -0,0 +1,26 @@
// 3dPlot
//
// Converted from BASIC to MiniScript by Joe Strout
print " "*32 + "3D PLOT"
print " "*15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
print; print; print
e = 2.71828
fna = function(z)
return 30 * e^(-z*z/100)
end function
for x in range(-30, 30, 1.5)
lastZ = 0
y1 = 5 * floor(sqrt(900-x*x)/5)
for y in range(y1, -y1, -5)
z = floor(25+fna(sqrt(x*x+y*y))-.7*y)
if z > lastZ then
print " "*(z-lastZ) + "*", ""
lastZ = z
end if
end for
print
wait 0.1 // (optional)
end for

View File

@@ -0,0 +1,16 @@
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
Conversion to [MiniScript](https://miniscript.org).
Ways to play:
1. Command-Line MiniScript:
Download for your system from https://miniscript.org/cmdline/, install, and then run the program with a command such as:
miniscript number.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 BASIC program. Then, at the Mini Micro command prompt, enter:
load "number"
run

View File

@@ -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 train.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 BASIC program. Then, at the Mini Micro command prompt, enter:
load "train"
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 train.ms, and click the "Run Script" button.

View File

@@ -0,0 +1,28 @@
// TRAIN
//
// Converted from BASIC to MiniScript by Ryushinaka and Joe Strout
while true
print "TRAIN"
print "CREATIVE COMPUTER MORRISTOWN, NEW JERSEY"
print ""
print "TIME - SPEED DISTANCE EXERCISE"
carSpeed = floor(25*rnd + 40)
difference = floor(15*rnd + 5)
trainSpeed = floor(19*rnd + 20)
print " A car traveling " + carSpeed + " MPH can make a certain trip in"
print difference + " hours less than a train traveling at " + trainSpeed + " MPH."
answer = input("How long does the trip take by car? ").val
carTime = difference*trainSpeed/(carSpeed-trainSpeed)
error = round(abs((carTime-answer)*100/answer))
if error < 5 then
print "GOOD! Answer within " + error + " PERCENT."
else
print "Sorry. You were off by " + floor(error) + " percent."
print "Correct answer is " + round(carTime, 1) + " hours."
end if
answer = input("Another problem (YES or NO)? ")
if not answer or answer[0].upper != "Y" then break
end while

View File

@@ -0,0 +1,16 @@
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
Conversion to [MiniScript](https://miniscript.org).
Ways to play:
1. Command-Line MiniScript:
Download for your system from https://miniscript.org/cmdline/, install, and then run the program with a command such as:
miniscript trap.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 BASIC program. Then, at the Mini Micro command prompt, enter:
load "trap"
run

View File

@@ -0,0 +1,69 @@
// TRAP
// STEVE ULLMAN, 8-1-72
// Ported to MiniScript by Ryushinaka and Joe Strout, 2023
print " "*34 + "TRAP"
print " "*15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
print
// constants:
G = 6 // number of guesses
N = 100 // range of numbers
// 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
if askYesNo("Instructions? ") == "y" then
print "I am thinking of a number between 1 and " + N
print "Try to guess my number. On each guess, "
print "you are to enter 2 numbers, trying to trap"
print "my number between the two numbers. I will"
print "tell you if you have trapped my number, if my"
print "number is larger than your two numbers, or if"
print "my number is smaller than your two numbers."
print "If you want to guess one single number, type"
print "your guess for both your trap numbers."
print "You get " + G + " guesses to get my number."
print
end if
doOneGame = function
computers_number = ceil(N*rnd)
for Q in range(1,G)
print ""
while true
guess = input("Guess #" + Q + ": ").replace(" ","")
guess = guess.split(",")
if guess.len == 2 then break
print "Enter your guess like: 30,40"
end while
A = guess[0].val
B = guess[1].val
if A == computers_number and B == computers_number then
print "You got it!!!"
return
else if A <= computers_number and B >= computers_number then
print "You have trapped my number."
else if A > computers_number and B > computers_number then
print "My number is smaller than your trap numbers."
else if A < computers_number and B < computers_number then
print "My number is larger than your trap numbers."
end if
end for
print "Sorry, that's " + G + " guesses. The number was " + computers_number
end function
// main loop
while true
print
doOneGame
print
if askYesNo("Try Again? ") == "n" then break
end while

View File

@@ -0,0 +1,16 @@
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
Conversion to [MiniScript](https://miniscript.org).
Ways to play:
1. Command-Line MiniScript:
Download for your system from https://miniscript.org/cmdline/, install, and then run the program with a command such as:
miniscript war.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 BASIC program. Then, at the Mini Micro command prompt, enter:
load "war"
run

View File

@@ -0,0 +1,65 @@
print " "*33 + "WAR"
print " "*15 + "CREATIVE COMPUTER MORRISTOWN, NEW JERSEY"
print; print; print
print "This is the card game of War. Each card is given by SUIT-#"
print "as S-7 for Spade 7."
// 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
print "Answer yes or no, please."
end while
end function
if askYesNo("Do you want directions") == "y" then
print "The computer gives you and it a 'card'. The higher card"
print "(numerically) wins. The game ends when you choose not to"
print "continue or when you have finished the pack."
end if
print
print
cardValues = "2 3 4 5 6 7 8 9 10 J Q K A".split
deck = []
for suits in "SHCD"
for value in cardValues
deck.push suits + "-" + value
end for
end for
deck.shuffle
playerScore = 0
computerScore = 0
while true
m1 = deck.pop
m2 = deck.pop
print "You: " + m1 + "; Computer: " + m2
n1 = cardValues.indexOf(m1[2:])
n2 = cardValues.indexOf(m2[2:])
if n1 > n2 then
playerScore += 1
print "You win. You have " + playerScore + " and the computer has " + computerScore
else if n2 > n1 then
computerScore += 1
print "The computer wins!!! You have " + playerScore + " and the computer has " + computerScore
else
print "Tie. No score change."
end if
if not deck then break
if askYesNo("Do you want to continue") == "n" then break
end while
if not deck then
print
print
print "We have run out of cards. Final score: You: " + playerScore +
" The computer: " + computerScore
print
end if
print "Thanks for playing. It was fun."
print

View File

@@ -15,4 +15,4 @@ http://www.vintage-basic.net/games.html
#### Porting Notes
(please note any difficulties or challenges in porting here)
Contrary to the description, the computer picks *five* random numbers per turn, not one. You are not rewarded based on how close your guess is to one number, but rather to which of these five random numbers (if any) it happens to match exactly.

View File

@@ -1,6 +1,6 @@
### Sine Wave
Did you ever go to a computer show and see a bunch of CRT terminals just sitting there waiting forlornly for someone to give a demo on them. It was one of those moments when I was at DEC that I decided there should be a little bit of background activity. And why not plot with words instead of the usual Xs? Thus SINE WAVE was born and lives on in dozens on different versions. At least those CRTs dont look so lifeless anymore.
Did you ever go to a computer show and see a bunch of CRT terminals just sitting there waiting forlornly for someone to give a demo on them. It was one of those moments when I was at DEC that I decided there should be a little bit of background activity. And why not plot with words instead of the usual Xs? Thus SINE WAVE was born and lives on in dozens of different versions. At least those CRTs dont look so lifeless anymore.
---