Skip to content

Commit e89ea05

Browse files
authored
Merge pull request #2 from chinhouse/main
add Stars, Reverse and version of Tic Tac Toe with no board updates shown
2 parents a4b68e4 + 171ec0a commit e89ea05

File tree

4 files changed

+118
-12
lines changed

4 files changed

+118
-12
lines changed

00_Alternate_Languages/73_Reverse/MiniScript/reverse.ms

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,21 @@ printState = function
3232
print;print digits.join(" "); print
3333
end function
3434

35-
print " " * 32 + "REVERSE"
36-
print " " * 15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
35+
print " " * 32 + "Reverse"
36+
print " " * 15 + "Creative Computing Morristown, New Jersey"
3737
print; print; print
3838
print "Reverse -- a game of skill"
3939
print
4040

41-
ans = input("Do you want the rules? ")
41+
ans = input("Do you want the rules? ") + " "
4242
if ans != null and ans[0].lower == "y" then showRules
4343

44-
while 1
44+
while true
4545
turns = 0
4646
digits = range(1, num)
4747
digits.shuffle
4848
print;print "Here we go ... the list is:"
49-
while 1
49+
while true
5050
printState
5151
amt = input("How many shall I reverse? ").val
5252
if amt == null or amt == 0 then break
@@ -64,8 +64,8 @@ while 1
6464
end if
6565
end while
6666
print
67-
ans = input("Try again (YES or NO)? ")
67+
ans = input("Try again (YES or NO)? ") + " "
6868
print
69-
if ans == null or ans[0].lower == "n" then break
69+
if ans == null or ans[0].lower != "y" then break
7070
end while
71-
print "O.K. Hope you had fun!!"
71+
print "O.K. Hope you had fun!!"

00_Alternate_Languages/82_Stars/MiniScript/stars.ms

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ instructions = function
1111
print
1212
end function
1313

14-
print " " * 34 + "STARS"
15-
print " " * 15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
14+
print " " * 34 + "Stars"
15+
print " " * 15 + "Creative Computing Morristown, New Jersey"
1616
print; print; print
1717

18-
ans = input("Do you want instructions? ").lower
18+
ans = input("Do you want instructions? ").lower + " "
1919
if ans[0] == "y" then
2020
instructions
2121
end if
2222

23-
while 1
23+
while true
2424
print
2525
print "OK, I am thinking of a number, start guessing."
2626
starNum = floor(rnd * kMaxNum) + 1
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
2+
3+
Conversion to [MiniScript](https://miniscript.org).
4+
5+
Ways to play:
6+
7+
1. Command-Line MiniScript:
8+
Download for your system from https://miniscript.org/cmdline/, install, and then run the program with a command such as:
9+
10+
miniscript tictactoe.ms
11+
12+
2. Mini Micro:
13+
Download Mini Micro from https://miniscript.org/MiniMicro/, launch, and then click the top disk slot and chose "Mount Folder..." Select the folder containing the MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
14+
15+
load "tictactoe"
16+
run
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// This program plays Tic Tac Toe
2+
// The machine goes first and the way this is set up
3+
// there's no way the human player can win. At best
4+
// it will be a draw.
5+
computerNext = function(x)
6+
return x - 8 * floor((x - 1) / 8)
7+
end function
8+
9+
print " " * 30 + "TIC TAC TOE"
10+
print " " * 15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
11+
print; print; print
12+
13+
print "The game board is numbered:"
14+
print
15+
print "1 2 3"
16+
print "8 9 4"
17+
print "7 6 5"
18+
print
19+
20+
while true
21+
computer = 9
22+
gameOver = false
23+
// MOVE ONE line 240 in original
24+
// Computer always moves first and takes the center
25+
print "Computer moves " + computer
26+
player = input("Your move? ").val
27+
playerFirstMove = player
28+
29+
// MOVE TWO line 280
30+
// Computer's 2nd move - always the next space clockwise
31+
// from the player's
32+
computer = computerNext(player + 1)
33+
canWinAt = computerNext(computer+4)
34+
print "Computer moves " + computer
35+
player = input("Your move? ").val
36+
37+
// MOVE THREE line 300
38+
// Computer has two consecutive cells. This includes the
39+
// middle so, to complete this 3-in-a-row, get the opposite
40+
// value of comp's last move - which is four cells clockwise away.
41+
42+
if player != canWinAt then
43+
computer = canWinAt
44+
print "Computer moves " + computer
45+
print "... and wins ********"
46+
gameOver = true
47+
else
48+
// Blocked - so two cells away from comp's last move
49+
// line 360
50+
computer = computerNext(computer + 2)
51+
print "Computer moves " + computer
52+
end if
53+
54+
if gameOver == false then
55+
canWinAt = computerNext(computer+4)
56+
player = input("Your move? ").val
57+
58+
// MOVE FOUR - line 400
59+
if player != canWinAt then
60+
computer = canWinAt
61+
print "Computer moves " + computer
62+
print "... and wins ********"
63+
gameOver = true
64+
else
65+
// Foiled again! - line 450
66+
if playerFirstMove % 2 == 0 then
67+
computer = computerNext(computer + 7)
68+
print "Computer moves " + computer
69+
print "... and wins ********"
70+
gameOver = true
71+
else // line 500
72+
computer = computerNext(computer + 3)
73+
print "Computer moves " + computer
74+
end if
75+
end if
76+
end if
77+
78+
if gameOver == false then
79+
// line 520
80+
player = input("Your move? ").val
81+
if player != computerNext(computer + 4) then
82+
computer = computerNext(computer + 4)
83+
else
84+
computer = computerNext(computer + 6)
85+
end if
86+
print "Computer moves " + computer
87+
print "The game is a draw."
88+
end if
89+
print
90+
end while

0 commit comments

Comments
 (0)