Merge branch 'main' into miniscript-batch-8

This commit is contained in:
JoeStrout
2023-09-18 12:52:13 -07:00
4 changed files with 118 additions and 12 deletions

View File

@@ -32,21 +32,21 @@ printState = function
print;print digits.join(" "); print
end function
print " " * 32 + "REVERSE"
print " " * 15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
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? ")
ans = input("Do you want the rules? ") + " "
if ans != null and ans[0].lower == "y" then showRules
while 1
while true
turns = 0
digits = range(1, num)
digits.shuffle
print;print "Here we go ... the list is:"
while 1
while true
printState
amt = input("How many shall I reverse? ").val
if amt == null or amt == 0 then break
@@ -64,8 +64,8 @@ while 1
end if
end while
print
ans = input("Try again (YES or NO)? ")
ans = input("Try again (YES or NO)? ") + " "
print
if ans == null or ans[0].lower == "n" then break
if ans == null or ans[0].lower != "y" then break
end while
print "O.K. Hope you had fun!!"
print "O.K. Hope you had fun!!"

View File

@@ -11,16 +11,16 @@ instructions = function
print
end function
print " " * 34 + "STARS"
print " " * 15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
print " " * 34 + "Stars"
print " " * 15 + "Creative Computing Morristown, New Jersey"
print; print; print
ans = input("Do you want instructions? ").lower
ans = input("Do you want instructions? ").lower + " "
if ans[0] == "y" then
instructions
end if
while 1
while true
print
print "OK, I am thinking of a number, start guessing."
starNum = floor(rnd * kMaxNum) + 1

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 tictactoe.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 "tictactoe"
run

View File

@@ -0,0 +1,90 @@
// This program plays Tic Tac Toe
// The machine goes first and the way this is set up
// there's no way the human player can win. At best
// it will be a draw.
computerNext = function(x)
return x - 8 * floor((x - 1) / 8)
end function
print " " * 30 + "TIC TAC TOE"
print " " * 15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
print; print; print
print "The game board is numbered:"
print
print "1 2 3"
print "8 9 4"
print "7 6 5"
print
while true
computer = 9
gameOver = false
// MOVE ONE line 240 in original
// Computer always moves first and takes the center
print "Computer moves " + computer
player = input("Your move? ").val
playerFirstMove = player
// MOVE TWO line 280
// Computer's 2nd move - always the next space clockwise
// from the player's
computer = computerNext(player + 1)
canWinAt = computerNext(computer+4)
print "Computer moves " + computer
player = input("Your move? ").val
// MOVE THREE line 300
// Computer has two consecutive cells. This includes the
// middle so, to complete this 3-in-a-row, get the opposite
// value of comp's last move - which is four cells clockwise away.
if player != canWinAt then
computer = canWinAt
print "Computer moves " + computer
print "... and wins ********"
gameOver = true
else
// Blocked - so two cells away from comp's last move
// line 360
computer = computerNext(computer + 2)
print "Computer moves " + computer
end if
if gameOver == false then
canWinAt = computerNext(computer+4)
player = input("Your move? ").val
// MOVE FOUR - line 400
if player != canWinAt then
computer = canWinAt
print "Computer moves " + computer
print "... and wins ********"
gameOver = true
else
// Foiled again! - line 450
if playerFirstMove % 2 == 0 then
computer = computerNext(computer + 7)
print "Computer moves " + computer
print "... and wins ********"
gameOver = true
else // line 500
computer = computerNext(computer + 3)
print "Computer moves " + computer
end if
end if
end if
if gameOver == false then
// line 520
player = input("Your move? ").val
if player != computerNext(computer + 4) then
computer = computerNext(computer + 4)
else
computer = computerNext(computer + 6)
end if
print "Computer moves " + computer
print "The game is a draw."
end if
print
end while