mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-21 23:00:43 -08:00
Merge pull request #1 from chinhouse/main
Adding Word, Weekday, 23 Matches, Tower, Target, and Synonym
This commit is contained in:
16
00_Alternate_Languages/73_Reverse/MiniScript/README.md
Normal file
16
00_Alternate_Languages/73_Reverse/MiniScript/README.md
Normal 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 reverse.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 "reverse"
|
||||||
|
run
|
||||||
71
00_Alternate_Languages/73_Reverse/MiniScript/reverse.ms
Normal file
71
00_Alternate_Languages/73_Reverse/MiniScript/reverse.ms
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
num = 9
|
||||||
|
|
||||||
|
reverse = function(i)
|
||||||
|
if i == null then return i
|
||||||
|
ret = []
|
||||||
|
for item in i
|
||||||
|
ret.insert(0,item)
|
||||||
|
end for
|
||||||
|
return ret
|
||||||
|
end function
|
||||||
|
|
||||||
|
showRules = function
|
||||||
|
print
|
||||||
|
print "This is the game of 'Reverse'. To win, all you have"
|
||||||
|
print "to do is arrange a list of numbers (1 through " + num + ")"
|
||||||
|
print "in numerical order from left to right. To move, you"
|
||||||
|
print "tell me how many numbers (counting from the left) to"
|
||||||
|
print "reverse. For example, if the current list is:"
|
||||||
|
print; print "2 3 4 5 1 6 7 8 9"
|
||||||
|
print; print "and you reverse 4, the result will be:"
|
||||||
|
print; print "5 4 3 2 1 6 7 8 9"
|
||||||
|
print; print "Now if reverse 5, you win!"
|
||||||
|
print; print "1 2 3 4 5 6 7 8 9"
|
||||||
|
print
|
||||||
|
print "No doubt you will like this game, but"
|
||||||
|
print "if you want to quit, reverse 0 (zero)."
|
||||||
|
print
|
||||||
|
return
|
||||||
|
end function
|
||||||
|
|
||||||
|
printState = function
|
||||||
|
print;print digits.join(" "); print
|
||||||
|
end function
|
||||||
|
|
||||||
|
print " " * 32 + "REVERSE"
|
||||||
|
print " " * 15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
|
||||||
|
print; print; print
|
||||||
|
print "Reverse -- a game of skill"
|
||||||
|
print
|
||||||
|
|
||||||
|
ans = input("Do you want the rules? ")
|
||||||
|
if ans != null and ans[0].lower == "y" then showRules
|
||||||
|
|
||||||
|
while 1
|
||||||
|
turns = 0
|
||||||
|
digits = range(1, num)
|
||||||
|
digits.shuffle
|
||||||
|
print;print "Here we go ... the list is:"
|
||||||
|
while 1
|
||||||
|
printState
|
||||||
|
amt = input("How many shall I reverse? ").val
|
||||||
|
if amt == null or amt == 0 then break
|
||||||
|
|
||||||
|
if amt > num then
|
||||||
|
print "OOPS! Too many! I can reverse at most " + num
|
||||||
|
else
|
||||||
|
turns += 1
|
||||||
|
digits = reverse(digits[:amt]) + digits[amt:]
|
||||||
|
end if
|
||||||
|
if digits == range(1,num) then
|
||||||
|
printState
|
||||||
|
print "You won it in " + turns + " moves!!"
|
||||||
|
break
|
||||||
|
end if
|
||||||
|
end while
|
||||||
|
print
|
||||||
|
ans = input("Try again (YES or NO)? ")
|
||||||
|
print
|
||||||
|
if ans == null or ans[0].lower == "n" then break
|
||||||
|
end while
|
||||||
|
print "O.K. Hope you had fun!!"
|
||||||
16
00_Alternate_Languages/82_Stars/MiniScript/README.md
Normal file
16
00_Alternate_Languages/82_Stars/MiniScript/README.md
Normal 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 stars.ms
|
||||||
|
|
||||||
|
2. Mini Micro:
|
||||||
|
Download Mini Micro from https://miniscript.org/MiniMicro/, launch, and then click the top disk slot and chose "Mount Folder..." Select the folder containing the MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||||
|
|
||||||
|
load "stars"
|
||||||
|
run
|
||||||
48
00_Alternate_Languages/82_Stars/MiniScript/stars.ms
Normal file
48
00_Alternate_Languages/82_Stars/MiniScript/stars.ms
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
kMaxNum = 100
|
||||||
|
kTries = 7
|
||||||
|
|
||||||
|
instructions = function
|
||||||
|
print "I am thinking of a whole number from 1 to " + kMaxNum
|
||||||
|
print "Try to guess my number. After you guess, I"
|
||||||
|
print "will output one or more stars (*). The more"
|
||||||
|
print "stars I type, the closer you are to my number."
|
||||||
|
print "One star (*) means far away, seven stars (*******)"
|
||||||
|
print "means really close! You get " + kTries + " guesses."
|
||||||
|
print
|
||||||
|
end function
|
||||||
|
|
||||||
|
print " " * 34 + "STARS"
|
||||||
|
print " " * 15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
|
||||||
|
print; print; print
|
||||||
|
|
||||||
|
ans = input("Do you want instructions? ").lower
|
||||||
|
if ans[0] == "y" then
|
||||||
|
instructions
|
||||||
|
end if
|
||||||
|
|
||||||
|
while 1
|
||||||
|
print
|
||||||
|
print "OK, I am thinking of a number, start guessing."
|
||||||
|
starNum = floor(rnd * kMaxNum) + 1
|
||||||
|
try = 0
|
||||||
|
while try < kTries
|
||||||
|
print
|
||||||
|
guess = input("Your guess: ").val
|
||||||
|
|
||||||
|
if guess == starNum then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
d = abs(guess - starNum)
|
||||||
|
print "*" * (7 - floor(log(d,2)))
|
||||||
|
end if
|
||||||
|
try += 1
|
||||||
|
end while
|
||||||
|
|
||||||
|
if try < kTries then
|
||||||
|
print "*" * 59
|
||||||
|
print "You got it in " + (try + 1) + " guesses! Let's play again."
|
||||||
|
else
|
||||||
|
print "Sorry, that's " + try + " guesses. The number was " + starNum
|
||||||
|
end if
|
||||||
|
print
|
||||||
|
end while
|
||||||
16
00_Alternate_Languages/85_Synonym/MiniScript/README.md
Normal file
16
00_Alternate_Languages/85_Synonym/MiniScript/README.md
Normal 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 synonym.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 "synonym"
|
||||||
|
run
|
||||||
47
00_Alternate_Languages/85_Synonym/MiniScript/synonym.ms
Normal file
47
00_Alternate_Languages/85_Synonym/MiniScript/synonym.ms
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
words = [["first", "start", "beginning", "onset", "initial"],
|
||||||
|
["similar", "alike", "same", "like", "resembling"],
|
||||||
|
["model", "pattern", "prototype", "standard", "criterion"],
|
||||||
|
["small", "insignificant", "little", "tiny", "minute"],
|
||||||
|
["stop", "halt", "stay", "arrest", "check", "standstill"],
|
||||||
|
["house", "dwelling", "residence", "domicile", "lodging", "habitation"],
|
||||||
|
["pit", "hole", "hollow", "well", "gulf", "chasm", "abyss"],
|
||||||
|
["push", "shove", "thrust", "prod","poke","butt", "press"],
|
||||||
|
["red", "rouge", "scarlet", "crimson", "flame", "ruby"],
|
||||||
|
["pain", "suffering", "hurt", "misery", "distress", "ache", "discomfort"]]
|
||||||
|
|
||||||
|
words.shuffle
|
||||||
|
|
||||||
|
responses = ["Right","Correct","Fine","Good!","Check"]
|
||||||
|
|
||||||
|
print " " * 33 + "SYNONYM"
|
||||||
|
print " " * 15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
|
||||||
|
print; print; print
|
||||||
|
print "A synonym of a word means another word in the English"
|
||||||
|
print "language which has the same or very nearly the same meaning."
|
||||||
|
print "I choose a word -- you type a synonym."
|
||||||
|
print "If you can't think a synonym, type the word 'HELP'"
|
||||||
|
print "and I will tell you a synonym."
|
||||||
|
print
|
||||||
|
|
||||||
|
for synonyms in words
|
||||||
|
word = synonyms[0]
|
||||||
|
synonyms = synonyms[1:]
|
||||||
|
responses.shuffle
|
||||||
|
|
||||||
|
print
|
||||||
|
while 1
|
||||||
|
guess = input(" What is a synonym of " + word + "? ").lower
|
||||||
|
if guess == "help" then
|
||||||
|
synonyms.shuffle
|
||||||
|
print "**** A synonym of " + word + " is " + synonyms[0] + "."
|
||||||
|
print
|
||||||
|
else if guess == word or synonyms.indexOf(guess) == null then
|
||||||
|
print " Try again."
|
||||||
|
else
|
||||||
|
print responses[0]
|
||||||
|
break
|
||||||
|
end if
|
||||||
|
end while
|
||||||
|
end for
|
||||||
|
print
|
||||||
|
print "Synonym drill completed."
|
||||||
16
00_Alternate_Languages/86_Target/MiniScript/README.md
Normal file
16
00_Alternate_Languages/86_Target/MiniScript/README.md
Normal 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 target.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 "target"
|
||||||
|
run
|
||||||
113
00_Alternate_Languages/86_Target/MiniScript/target.ms
Normal file
113
00_Alternate_Languages/86_Target/MiniScript/target.ms
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
degToRad = function(n)
|
||||||
|
return n * pi / 180
|
||||||
|
end function
|
||||||
|
|
||||||
|
radToDeg = function(n)
|
||||||
|
return n * 180 / pi
|
||||||
|
end function
|
||||||
|
|
||||||
|
roundDown = function(n, r)
|
||||||
|
return floor(n / r) * r
|
||||||
|
end function
|
||||||
|
|
||||||
|
getCoord = function(distance, radX, radZ)
|
||||||
|
xc = sin(radZ)*cos(radX)*distance
|
||||||
|
yc = sin(radZ)*sin(radX)*distance
|
||||||
|
zc = cos(radZ)*distance
|
||||||
|
return [xc,yc,zc]
|
||||||
|
end function
|
||||||
|
|
||||||
|
distanceBetween = function (d1,d2)
|
||||||
|
return ((d1[0]-d2[0])^2 + (d1[1]-d2[1])^2 + (d1[2]-d2[2])^2)^.5
|
||||||
|
end function
|
||||||
|
|
||||||
|
print " " * 33 + "TARGET"
|
||||||
|
print " " * 15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
|
||||||
|
print; print; print
|
||||||
|
|
||||||
|
print "You are the weapons officer on the Starship Enterprise"
|
||||||
|
print "and this is a test to see how accurae a shot you"
|
||||||
|
print "are in a 3-dimensional range. You will be told"
|
||||||
|
print "the radian offset for the X and Z axes, the location"
|
||||||
|
print "of the target in 3-dimensional rectangular coordinates,"
|
||||||
|
print "the approximate number of degrees from the X and Z"
|
||||||
|
print "axes, and the approximate distance to the target."
|
||||||
|
print "You will then proceed to shoot at the target until it is"
|
||||||
|
print "destroyed!"
|
||||||
|
print; print
|
||||||
|
print "Good luck!"
|
||||||
|
roundToList = [20,10,2,1]
|
||||||
|
ready = true
|
||||||
|
while ready
|
||||||
|
turns = -1
|
||||||
|
radX = rnd * 2 * pi
|
||||||
|
radZ = rnd * 2 * pi
|
||||||
|
print "Radians from X axis = " + radX + " from Z axis = " + radZ
|
||||||
|
|
||||||
|
distance = 100000 * rnd * rnd
|
||||||
|
coords = getCoord(distance, radX, radZ)
|
||||||
|
|
||||||
|
print "Target sighted: Approx Coordinates (X,Y,Z) = ("+coords.join(",")+")"
|
||||||
|
|
||||||
|
gameRunning = true
|
||||||
|
while gameRunning
|
||||||
|
turns += 1
|
||||||
|
if turns >=4 then
|
||||||
|
estDistance = distance
|
||||||
|
else
|
||||||
|
estDistance = roundDown(distance, roundToList[turns])
|
||||||
|
end if
|
||||||
|
|
||||||
|
print " Estimated Distance: " + estDistance
|
||||||
|
print
|
||||||
|
tx = input ("Input angle deviation from X in degrees: ").val
|
||||||
|
tz = input ("Input angle deviation from Z in degrees: ").val
|
||||||
|
tdist = input ("Input distance: ").val
|
||||||
|
print
|
||||||
|
if tdist < 20 then
|
||||||
|
print "You blew yourself up!!"
|
||||||
|
gameRunning = false
|
||||||
|
else
|
||||||
|
tx = degToRad(tx)
|
||||||
|
tz = degToRad(tz)
|
||||||
|
|
||||||
|
print "Radians from X-axis = " + tx + " from Z-axis = " + tz
|
||||||
|
targeted = getCoord(tdist, tx,tz)
|
||||||
|
distBet = distanceBetween(coords, targeted)
|
||||||
|
if distBet > 20 then
|
||||||
|
dx = targeted[0] - coords[0]
|
||||||
|
dy = targeted[1] - coords[1]
|
||||||
|
dz = targeted[2] - coords[2]
|
||||||
|
xMsg = {false: "Shot in front of target ", true: "Shot behind target "}
|
||||||
|
print xMsg[dx<0] + dx + " kilometers."
|
||||||
|
yMsg = {false: "Shot to left of target ", true: "Shot to right of target "}
|
||||||
|
print yMsg[dy<0] + dy + " kilometers."
|
||||||
|
zMsg = {false: "Shot above target ", true: "Shot below target "}
|
||||||
|
print zMsg[dz<0] + dz + " kilometers."
|
||||||
|
|
||||||
|
print "Approx position of explosion + (" + targeted.join(",") + ")"
|
||||||
|
print " Distance from target = " + distBet
|
||||||
|
print
|
||||||
|
print
|
||||||
|
|
||||||
|
else
|
||||||
|
print
|
||||||
|
print " * * * HIT * * * Target is non-functional"
|
||||||
|
print
|
||||||
|
print "Distance of explosion from target was " + distBet + "kilometers."
|
||||||
|
print
|
||||||
|
print "Mission accomplished in " + (turns+1) + " shots."
|
||||||
|
print
|
||||||
|
gameRunning = false
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end while
|
||||||
|
print
|
||||||
|
ans = input("Ready for next target? ").lower
|
||||||
|
if ans == "" then
|
||||||
|
ready == false
|
||||||
|
else
|
||||||
|
ready = ans[0].lower == "y"
|
||||||
|
end if
|
||||||
|
print
|
||||||
|
end while
|
||||||
16
00_Alternate_Languages/90_Tower/MiniScript/README.md
Normal file
16
00_Alternate_Languages/90_Tower/MiniScript/README.md
Normal 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 tower.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 "tower"
|
||||||
|
run
|
||||||
202
00_Alternate_Languages/90_Tower/MiniScript/tower.ms
Normal file
202
00_Alternate_Languages/90_Tower/MiniScript/tower.ms
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
kInvalidDisk = 100
|
||||||
|
kNotTopDisk = 200
|
||||||
|
kNotTower = 300
|
||||||
|
kGameOver = 300
|
||||||
|
|
||||||
|
Tower = {"disks": []}
|
||||||
|
Tower.init = function
|
||||||
|
noob = new Tower
|
||||||
|
noob.disks = []
|
||||||
|
return noob
|
||||||
|
end function
|
||||||
|
|
||||||
|
Tower.height = function
|
||||||
|
return self.disks.len
|
||||||
|
end function
|
||||||
|
|
||||||
|
Tower.top = function
|
||||||
|
if self.height == 0 then return 100
|
||||||
|
return self.disks[-1]
|
||||||
|
end function
|
||||||
|
|
||||||
|
Game = {}
|
||||||
|
Game["towers"] = []
|
||||||
|
Game["numOfDisks"] = 0
|
||||||
|
Game["rangeOfDisks"] = []
|
||||||
|
Game["selectedDisk"] = 0
|
||||||
|
Game["selectedDiskOn"] = 0
|
||||||
|
Game["selectedTower"] = 0
|
||||||
|
Game["inputErrors"] = 0
|
||||||
|
Game["turns"] = 0
|
||||||
|
|
||||||
|
Game.display = function
|
||||||
|
print
|
||||||
|
for r in range(7,1,-1)
|
||||||
|
rowstr = ""
|
||||||
|
for tower in self.towers
|
||||||
|
if r > tower.height then
|
||||||
|
rowstr += " " * 12 + "#" + " " * 7
|
||||||
|
else
|
||||||
|
spaces = (15 - tower.disks[r-1])/2
|
||||||
|
disks = " " * 4 + tower.disks[r-1]
|
||||||
|
rowstr += disks[-5:] + " " * spaces
|
||||||
|
rowstr += "#" * tower.disks[r-1]
|
||||||
|
rowstr += " " * spaces
|
||||||
|
end if
|
||||||
|
rowstr += " "
|
||||||
|
end for
|
||||||
|
print rowstr
|
||||||
|
end for
|
||||||
|
rowstr = (" " * 5 + "=" * 15 + " ") * 3
|
||||||
|
print rowstr
|
||||||
|
print
|
||||||
|
end function
|
||||||
|
|
||||||
|
Game.init = function(num)
|
||||||
|
if num < 1 or num > 7 then
|
||||||
|
self.inputErrors += 1
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
Game.towers = []
|
||||||
|
for i in range(0,2)
|
||||||
|
Game.towers.push(Tower.init)
|
||||||
|
end for
|
||||||
|
|
||||||
|
first = self.towers[0]
|
||||||
|
first.disks = range(15, 17 - num * 2, -2)
|
||||||
|
self.numOfDisks = num
|
||||||
|
self.rangeOfDisks = range(17 -num * 2, 15, 2)
|
||||||
|
|
||||||
|
// This game doesn't like to be bothered
|
||||||
|
// and keeps track of how many incorrect inputs
|
||||||
|
// are made before it stops the game
|
||||||
|
self.inputErrors = 0
|
||||||
|
self.turns = 0
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
Game.diskStatus = function
|
||||||
|
n = self.selectedDisk
|
||||||
|
if self.rangeOfDisks.indexOf(n) == null then
|
||||||
|
self.inputErrors +=1
|
||||||
|
return kInvalidDisk
|
||||||
|
end if
|
||||||
|
self.inputErrors = 0
|
||||||
|
for i in range(0, self.towers.len - 1)
|
||||||
|
if self.towers[i].top == n then
|
||||||
|
self.selectedDiskOn = i
|
||||||
|
self.inputErrors = 0
|
||||||
|
return i
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
return kNotTopDisk
|
||||||
|
end function
|
||||||
|
|
||||||
|
Game.pickDisk = function
|
||||||
|
self.selectedDisk = input("Which disk would you like to move? ").val
|
||||||
|
return self.diskStatus
|
||||||
|
end function
|
||||||
|
|
||||||
|
Game.pickTower = function
|
||||||
|
self.selectedTower = input("Place disk on which needle? ").val - 1
|
||||||
|
if not(0<= self.selectedTower and self.selectedTower <= 2) then
|
||||||
|
self.inputErrors += 1
|
||||||
|
return kNotTower
|
||||||
|
end if
|
||||||
|
return self.selectedTower
|
||||||
|
end function
|
||||||
|
|
||||||
|
Game.doneWithYou = function
|
||||||
|
return self.inputErrors >= 2
|
||||||
|
end function
|
||||||
|
|
||||||
|
Game.isFinish = function
|
||||||
|
return self.towers[0].disks.len == 0 and self.towers[1].disks.len == 0
|
||||||
|
end function
|
||||||
|
|
||||||
|
Game.move = function
|
||||||
|
print "Take turn # " + (self.turns + 1)
|
||||||
|
status = -1
|
||||||
|
self.inputErrors = 0
|
||||||
|
while 1
|
||||||
|
status = self.pickDisk
|
||||||
|
if 0 <= status and status <= 2 then break
|
||||||
|
if status == kInvalidDisk and self.doneWithYou then
|
||||||
|
print "Stop wasting my time. Go bother someone else."
|
||||||
|
exit
|
||||||
|
else if status == kInvalidDisk then
|
||||||
|
msg = "Illegal entry ... you may only type "
|
||||||
|
msg += self.rangeOfDisks[0:-1].join(",") + " "
|
||||||
|
if self.rangeOfDisks.len > 1 then
|
||||||
|
msg += "or "
|
||||||
|
end if
|
||||||
|
msg += "15"
|
||||||
|
print msg
|
||||||
|
else if status == kNotTopDisk then
|
||||||
|
print "That disk is below another. Make another choice."
|
||||||
|
end if
|
||||||
|
end while
|
||||||
|
|
||||||
|
self.inputErrors = 0
|
||||||
|
while 1
|
||||||
|
status = self.pickTower
|
||||||
|
if 0 <= status and status <= 2 then break
|
||||||
|
if status == kNotTower and self.doneWithYou then
|
||||||
|
print "I tried to warn you. But you wouldn't listen."
|
||||||
|
print "By bye, big shot."
|
||||||
|
exit
|
||||||
|
else if status == kNotTower then
|
||||||
|
print "I'll assume you hit the wrong ket this time. But watch it"
|
||||||
|
print "I only allow one mistake."
|
||||||
|
end if
|
||||||
|
end while
|
||||||
|
|
||||||
|
if self.selectedDisk > self.towers[self.selectedTower].top then
|
||||||
|
print "You can't place a larger disk on a top of a smaller one,"
|
||||||
|
print "it may crush it!"
|
||||||
|
else
|
||||||
|
n=self.towers[self.selectedDiskOn].disks.pop
|
||||||
|
self.towers[self.selectedTower].disks.push(n)
|
||||||
|
self.turns += 1
|
||||||
|
self.inputErrors = 0
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
|
||||||
|
print " " * 33 + "TOWERS"
|
||||||
|
print " " * 15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
|
||||||
|
print;print
|
||||||
|
print "You must transfer the disks from the left to the right"
|
||||||
|
print "tower, one at a time, never putting a larger disk on a"
|
||||||
|
print "smaller disk."
|
||||||
|
print
|
||||||
|
|
||||||
|
ans = "Y"
|
||||||
|
while ans[0].upper == "Y"
|
||||||
|
while 1
|
||||||
|
disks = input ("How many disks do you want to move (7 is MAX)? ").val
|
||||||
|
status = Game.init(disks)
|
||||||
|
if status == false and Game.doneWithYou then
|
||||||
|
print "All right, wise guy, if you can't play the game right, I'll"
|
||||||
|
print "take my puzzle and go home. So long."
|
||||||
|
exit
|
||||||
|
else if not status then
|
||||||
|
print "Sorry, but I can't do that job for you"
|
||||||
|
else
|
||||||
|
break
|
||||||
|
end if
|
||||||
|
end while
|
||||||
|
|
||||||
|
while not Game.isFinish
|
||||||
|
Game.display
|
||||||
|
|
||||||
|
Game.move
|
||||||
|
end while
|
||||||
|
Game.display
|
||||||
|
print "Congratulations!"
|
||||||
|
print "You performed the task in " + Game.turns + " moves."
|
||||||
|
print
|
||||||
|
ans = input("Play again (Yes or No)? ")
|
||||||
|
end while
|
||||||
|
print
|
||||||
|
print "Thanks for the game!"
|
||||||
67
00_Alternate_Languages/93_23_Matches/MiniScript/23matches.ms
Normal file
67
00_Alternate_Languages/93_23_Matches/MiniScript/23matches.ms
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
CR = char(13)
|
||||||
|
|
||||||
|
print " "*32 + "WEEKDAY"
|
||||||
|
print " "*15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"+CR+CR+CR
|
||||||
|
|
||||||
|
print "This is a game called '23 Matches'."
|
||||||
|
print
|
||||||
|
print "When it is your turn, you may take one, two, or three"
|
||||||
|
print "matches. The object of the game is not to have to take"
|
||||||
|
print "the last match."
|
||||||
|
print
|
||||||
|
print "Let's flip a coin to see who goes first."
|
||||||
|
print "If it comes up heads, I will win the toss."
|
||||||
|
print
|
||||||
|
matches = 23
|
||||||
|
humanTurn = floor(rnd * 2)
|
||||||
|
|
||||||
|
if humanTurn then
|
||||||
|
print "Tails! You go first."
|
||||||
|
prompt = "How many do you wish to remove? "
|
||||||
|
else
|
||||||
|
print "Heads! I win! Ha! Ha!"
|
||||||
|
print "Prepare to lose, meatball-nose!!"
|
||||||
|
end if
|
||||||
|
|
||||||
|
choice = 2
|
||||||
|
while matches > 0
|
||||||
|
if humanTurn then
|
||||||
|
choice = 0
|
||||||
|
if matches == 1 then choice = 1
|
||||||
|
while choice == 0
|
||||||
|
choice = input(prompt).val
|
||||||
|
if choice <1 or choice > 3 or choice > matches then
|
||||||
|
choice = 0
|
||||||
|
print "Very funny! Dummy!"
|
||||||
|
print "Do you want to play or goof around?"
|
||||||
|
prompt = "Now, how many matches do you want? "
|
||||||
|
end if
|
||||||
|
end while
|
||||||
|
matches = matches - choice
|
||||||
|
if matches == 0 then
|
||||||
|
print "You poor boob! You took the last match! I gotcha!!"
|
||||||
|
print "Ha! Ha! I beat you !!"
|
||||||
|
print "Good bye loser!"
|
||||||
|
else
|
||||||
|
print "There are now " + matches + " matches remaining." + CR
|
||||||
|
end if
|
||||||
|
else
|
||||||
|
choice_comp = 4 - choice
|
||||||
|
if matches == 1 then
|
||||||
|
choice_comp = 1
|
||||||
|
else if 1 < matches and matches < 4 then
|
||||||
|
choice_comp = matches - 1
|
||||||
|
end if
|
||||||
|
matches = matches - choice_comp
|
||||||
|
if matches == 0 then
|
||||||
|
print "You won, floppy ears!"
|
||||||
|
print "Think you're pretty smart!"
|
||||||
|
print "Let's play again and I'll blow your shoes off!!"
|
||||||
|
else
|
||||||
|
print "My turn! I remove " + choice_comp + " matches"
|
||||||
|
print "The number of matches is now " + matches + CR
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
humanTurn = not humanTurn
|
||||||
|
prompt = "Your turn -- you may take 1, 2 or 3 matches." + CR + "How many do you wish to remove? "
|
||||||
|
end while
|
||||||
16
00_Alternate_Languages/93_23_Matches/MiniScript/README.md
Normal file
16
00_Alternate_Languages/93_23_Matches/MiniScript/README.md
Normal 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 23matches.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 "23matches"
|
||||||
|
run
|
||||||
16
00_Alternate_Languages/95_Weekday/MiniScript/README.md
Normal file
16
00_Alternate_Languages/95_Weekday/MiniScript/README.md
Normal 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 weekday.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 "weekday"
|
||||||
|
run
|
||||||
177
00_Alternate_Languages/95_Weekday/MiniScript/weekday.ms
Normal file
177
00_Alternate_Languages/95_Weekday/MiniScript/weekday.ms
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
TAB = char(9)
|
||||||
|
CR = char(13)
|
||||||
|
|
||||||
|
Age = {"m": 0, "d": 0, "y": 0}
|
||||||
|
Age.init = function(m,d,y)
|
||||||
|
noob = new Age
|
||||||
|
noob.m = m;noob.d = d;noob.y = y
|
||||||
|
return noob
|
||||||
|
end function
|
||||||
|
|
||||||
|
Age.sub = function(a)
|
||||||
|
m1 = self.m; d1 = self.d; y1 = self.y
|
||||||
|
d1 = d1 - a.d
|
||||||
|
if d1 < 0 then
|
||||||
|
d1 = d1 + 30
|
||||||
|
m1 = m1 - 1
|
||||||
|
end if
|
||||||
|
m1 = m1 - a.m
|
||||||
|
if m1 < 0then
|
||||||
|
m1 = m1 + 12
|
||||||
|
y1 = y1 - 1
|
||||||
|
end if
|
||||||
|
y1 = y1 - a.y
|
||||||
|
return Age.init(m1,d1,y1)
|
||||||
|
end function
|
||||||
|
|
||||||
|
Age.multiply = function(multiplier)
|
||||||
|
ageInDays = self.y *365 + self.m * 30 + self.d + floor(self.m / 2)
|
||||||
|
newAge = ageInDays * multiplier
|
||||||
|
years = floor(newAge/ 365)
|
||||||
|
leftover = newAge % 365
|
||||||
|
months = floor(leftover / 30)
|
||||||
|
days = floor(leftover % 30)
|
||||||
|
return Age.init(months, days, years)
|
||||||
|
end function
|
||||||
|
|
||||||
|
Date = {"m": null, "d": null, "y": null}
|
||||||
|
|
||||||
|
// the number of days between the 1st of one month to the next
|
||||||
|
Date.daysPerMonth = [0,31,28,31,30,31,30, 31,31,30,31,30]
|
||||||
|
Date.dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday",
|
||||||
|
"Thursday", "Friday", "Saturday"]
|
||||||
|
|
||||||
|
Date.init = function(dt)
|
||||||
|
d = dt.split(",")
|
||||||
|
if d.len != 3 then return
|
||||||
|
noob = new Date
|
||||||
|
noob.m = d[0].val
|
||||||
|
noob.d = d[1].val
|
||||||
|
noob.y = d[2].val
|
||||||
|
return noob
|
||||||
|
end function
|
||||||
|
|
||||||
|
Date.diff = function(mdy)
|
||||||
|
dday = self.d - mdy.d
|
||||||
|
dmonth = self.m - mdy.m
|
||||||
|
if dday < 0 then
|
||||||
|
dmonth -= 1
|
||||||
|
dday += 30
|
||||||
|
end if
|
||||||
|
|
||||||
|
dyear = self.y - mdy.y
|
||||||
|
if dmonth <0 then
|
||||||
|
dyear -= 1
|
||||||
|
dmonth += 12
|
||||||
|
end if
|
||||||
|
return Age.init(dmonth, dday, dyear)
|
||||||
|
end function
|
||||||
|
|
||||||
|
Date._isLeapYear = function
|
||||||
|
return (self.y % 4 == 0 and self.y % 100 != 0) or self.y % 400 == 0
|
||||||
|
end function
|
||||||
|
|
||||||
|
Date.value = function
|
||||||
|
//Not accepting dates Jan 1st 1583 this because the
|
||||||
|
//transistion to Gregorian calendar occurred in 1582.
|
||||||
|
|
||||||
|
//calculating days since the end of 1582
|
||||||
|
years = self.y - 1583
|
||||||
|
days = years * 365 + self._leapYears + Date.daysPerMonth[:self.m].sum + self.d
|
||||||
|
return days // returns 1 for 1,1,1583
|
||||||
|
end function
|
||||||
|
|
||||||
|
Date.dayOfWeek = function
|
||||||
|
// 1,1,1583 is a Saturday
|
||||||
|
// Date.value calculates a value of 1 for that date
|
||||||
|
return (self.value + 5) % 7
|
||||||
|
end function
|
||||||
|
|
||||||
|
Date.weekday = function
|
||||||
|
return Date.dayNames[self.dayOfWeek]
|
||||||
|
end function
|
||||||
|
|
||||||
|
// get # of lear yeaps since the change to Gregorian
|
||||||
|
Date._leapYears = function
|
||||||
|
ly = floor((self.y - 1580) / 4)
|
||||||
|
|
||||||
|
//exclude centuries
|
||||||
|
centuries = floor((self.y - 1500) / 100)
|
||||||
|
|
||||||
|
//unless centuries divisible by 400
|
||||||
|
centuries400 = floor((self.y - 1200) / 400)
|
||||||
|
ly = ly - centuries + centuries400
|
||||||
|
|
||||||
|
if self._isLeapYear and self.m < 3 then ly -= 1
|
||||||
|
return ly
|
||||||
|
end function
|
||||||
|
|
||||||
|
print " "*32 + "WEEKDAY"
|
||||||
|
print " "*15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"+CR+CR+CR
|
||||||
|
|
||||||
|
print "WEEKDAY is a computer demonstration that"
|
||||||
|
print "gives facts about a date of interest to you."+CR
|
||||||
|
|
||||||
|
mdy = input("Enter today's date in the form: 3,24,1979?"+CR)
|
||||||
|
today = Date.init(mdy)
|
||||||
|
|
||||||
|
mdy = input("Enter day of birth (or other day of interest)"+CR)
|
||||||
|
dob = Date.init(mdy)
|
||||||
|
|
||||||
|
print
|
||||||
|
if dob.y < 1583 then
|
||||||
|
print "Not prepared to give day of the week prior to 1583"
|
||||||
|
exit
|
||||||
|
end if
|
||||||
|
|
||||||
|
verb = " was a "
|
||||||
|
if today.value < dob.value then verb= " will be a "
|
||||||
|
if today.value == dob.value then verb = " is a "
|
||||||
|
|
||||||
|
if dob.d == 13 and dob.weekday == "Friday" then
|
||||||
|
endMsg = " The Thirteenth--Beware!"
|
||||||
|
else
|
||||||
|
endMsg = "."
|
||||||
|
end if
|
||||||
|
print dob.m + "/" + dob.d + "/" + dob.y + verb + dob.weekday + endMsg
|
||||||
|
|
||||||
|
age = today.diff(dob)
|
||||||
|
|
||||||
|
totalAge = Age.init(age.m,age.d,age.y)
|
||||||
|
if verb == " was a " then
|
||||||
|
lines= [["", "YEARS", "MONTHS", "DAYS"]]
|
||||||
|
lines.push(["", "-----", "------", "----"])
|
||||||
|
lines.push(["Your age (if birthdate)", age.y,age.m, age.d])
|
||||||
|
|
||||||
|
spent = age.multiply(.35)
|
||||||
|
lines.push(["You have slept", spent.y,spent.m, spent.d])
|
||||||
|
totalAge = totalAge.sub(spent)
|
||||||
|
|
||||||
|
spent = age.multiply(.17)
|
||||||
|
lines.push(["You have eaten", spent.y,spent.m, spent.d])
|
||||||
|
totalAge = totalAge.sub(spent)
|
||||||
|
|
||||||
|
if totalAge.y <= 3 then
|
||||||
|
phrase = "You have played"
|
||||||
|
else if totalAge.y <= 9 then
|
||||||
|
phrase = "You have played/studied"
|
||||||
|
else
|
||||||
|
phrase = "You have worked/played"
|
||||||
|
end if
|
||||||
|
|
||||||
|
spent = age.multiply(.23)
|
||||||
|
lines.push([phrase, spent.y,spent.m, spent.d])
|
||||||
|
totalAge = totalAge.sub(spent)
|
||||||
|
|
||||||
|
relaxed = totalAge
|
||||||
|
lines.push(["You have relaxed", relaxed.y, relaxed.m, relaxed.d])
|
||||||
|
for line in lines
|
||||||
|
col0 = (" " * 25 + line[0])[-25:]
|
||||||
|
col1 = (line[1] + " " * 6)[:6]
|
||||||
|
col2 = (line[2] + " " * 7)[:7]
|
||||||
|
col3 = (line[3] + " " * 5)[:5]
|
||||||
|
print (col0+" " + col1+col2+col3)
|
||||||
|
end for
|
||||||
|
end if
|
||||||
|
|
||||||
|
print CR+"Yoy may retire in " + (dob.y + 65)
|
||||||
16
00_Alternate_Languages/96_Word/MiniScript/README.md
Normal file
16
00_Alternate_Languages/96_Word/MiniScript/README.md
Normal 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 word.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 "word"
|
||||||
|
run
|
||||||
63
00_Alternate_Languages/96_Word/MiniScript/word.ms
Normal file
63
00_Alternate_Languages/96_Word/MiniScript/word.ms
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
words = ["dinky", "smoke", "water", "grass", "train", "might",
|
||||||
|
"first", "candy", "champ", "would", "clump", "dopey"]
|
||||||
|
|
||||||
|
playGame = function
|
||||||
|
secret = words[rnd * words.len]
|
||||||
|
guesses = 0
|
||||||
|
exact = ["-"]*5
|
||||||
|
|
||||||
|
print "You are starting a new game..."
|
||||||
|
while true
|
||||||
|
guess = ""
|
||||||
|
while guess == ""
|
||||||
|
print
|
||||||
|
guess = input("Guess a five letter word. ").lower
|
||||||
|
if guess == "?" then break
|
||||||
|
if guess.len != 5 then
|
||||||
|
guess = ""
|
||||||
|
print "You must guess a five letter word. Try again."
|
||||||
|
end if
|
||||||
|
end while
|
||||||
|
guesses += 1
|
||||||
|
|
||||||
|
if guess == "?" then
|
||||||
|
print "The secret word is " + secret
|
||||||
|
break
|
||||||
|
else
|
||||||
|
common = ""
|
||||||
|
for i in range(0, 4)
|
||||||
|
if secret.indexOf(guess[i]) != null then
|
||||||
|
common += guess[i]
|
||||||
|
if secret[i] == guess[i] then
|
||||||
|
exact[i] = guess[i]
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
print "There were " + common.len + " matches and the common letters were..." + common
|
||||||
|
print "From the exact letter matches, you know"+"."*16 + exact.join("")
|
||||||
|
|
||||||
|
if secret == guess or secret == exact.join("") then
|
||||||
|
print "You have guessed the word. It took " + guesses + " guesses!"
|
||||||
|
break
|
||||||
|
else if common.len < 2 then
|
||||||
|
print
|
||||||
|
print "If you give up, type '?' for your next guess."
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end while
|
||||||
|
end function
|
||||||
|
|
||||||
|
print " " * 33 + "WORD"
|
||||||
|
print " " * 15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
|
||||||
|
print
|
||||||
|
print "I am thinking of a word -- you guess it. I will give you"
|
||||||
|
print "clues to help you get it. Good luck!"
|
||||||
|
print
|
||||||
|
|
||||||
|
playing = "y"
|
||||||
|
while playing == "y"
|
||||||
|
playGame
|
||||||
|
print
|
||||||
|
playing = input("Want to play again? ") + " "
|
||||||
|
playing = playing[0].lower
|
||||||
|
end while
|
||||||
Reference in New Issue
Block a user