%Data11.txt
var window1, window2, window3 : int
window1 := Window.Open ("position:center,center,graphics:400,400")
colourback (black)
cls
colour (white)
Draw.Box (25, 25, maxx - 25, maxy - 25, grey)
Draw.Box (25, 140, maxx - 25, maxy - 25, grey)
Draw.Box (25, 260, maxx - 25, maxy - 25, grey)
Draw.Box (140, 25, maxx - 25, maxy - 25, grey)
Draw.Box (260, 25, maxx - 25, maxy - 25, grey)
var file : int
var game : array 1 .. 9 of int
var turn : string := "blue"
var value : array 1 .. 9 of int
var ch : string (1)
var winning : int := 0
proc redwin
var redwindow : int
redwindow := Window.Open ("position:center,center,graphics:300,200")
put "RED WINS!"
getch (ch)
Window.Close (redwindow)
end redwin
proc bluewin
var bluewindow : int
bluewindow := Window.Open ("position:center,center,graphics:300,200")
put "BLUE WINS!"
getch (ch)
Window.Close (bluewindow)
end bluewin
proc win
%Checks if three are found in a row
if whatdotcolour (85, 85) = red then
if whatdotcolour (85, 200) = red and whatdotcolour (85, 315) = red then
winning := 1
elsif whatdotcolour (200, 85) = red and whatdotcolour (200, 315) = red then
winning := 1
elsif whatdotcolour (200, 200) = red and whatdotcolour (315, 315) = red then
winning := 1
end if
elsif whatdotcolour (200, 85) = red and whatdotcolour (200, 200) = red whatdotcolour (200, 315) = red then
winning := 1
elsif whatdotcolour (315, 85) = red then
if whatdotcolour (200, 200) = red and whatdotcolour (85, 315) = red then
winning := 1
elsif whatdotcolour (315, 200) = red and whatdotcolour (315, 315) = red then
winning := 1
end if
elsif whatdotcolour (85, 200) = red and whatdotcolour (200, 200) = red and whatdotcolour (315, 200) = red then
winning := 1
elsif whatdotcolour (85, 315) = red and whatdotcolour (200, 315) = red and whatdotcolour (315, 315) = red then
winning := 1
end if
if whatdotcolour (85, 85) = brightblue then
if whatdotcolour (85, 200) = brightblue and whatdotcolour (85, 315) = brightblue then
winning := 2
elsif whatdotcolour (200, 85) = brightblue and whatdotcolour (200, 315) = brightblue then
winning := 2
elsif whatdotcolour (200, 200) = brightblue and whatdotcolour (315, 315) = brightblue then
winning := 2
end if
elsif whatdotcolour (200, 85) = brightblue and whatdotcolour (200, 200) = brightblue and whatdotcolour (200, 315) = brightblue then
winning := 2
elsif whatdotcolour (315, 85) = brightblue then
if whatdotcolour (200, 200) = brightblue and whatdotcolour (85, 315) = brightblue then
winning := 2
elsif whatdotcolour (315, 200) = brightblue and whatdotcolour (315, 315) = brightblue then
winning := 2
end if
elsif whatdotcolour (85, 200) = brightblue and whatdotcolour (200, 200) = brightblue and whatdotcolour (315, 200) = brightblue then
winning := 2
elsif whatdotcolour (85, 315) = brightblue and whatdotcolour (200, 315) = brightblue and whatdotcolour (315, 315) = brightblue then
winning := 2
end if
end win
for i : 1 .. upper (value)
value (i) := 0
end for
open : file, "DATA11.txt", get
for i : 1 .. 9
get : file, game (i)
end for
for i : 1 .. 9
if turn = "blue" then
if game (i) > 9 then
turn := "red"
elsif game (i) = 1 and value (i) = 0 then
Draw.FillOval (85, 85, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 2 and value (i) = 0 then
Draw.FillOval (200, 85, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 3 and value (i) = 0 then
Draw.FillOval (315, 85, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 4 and value (i) = 0 then
Draw.FillOval (85, 200, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 5 and value (i) = 0 then
Draw.FillOval (200, 200, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 6 and value (i) = 0 then
Draw.FillOval (315, 200, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 7 and value (i) = 0 then
Draw.FillOval (85, 315, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 8 and value (i) = 0 then
Draw.FillOval (200, 315, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 9 and value (i) = 0 then
Draw.FillOval (315, 315, 40, 40, brightblue)
turn := "red"
value (i) := 1
else
turn := "red"
end if
elsif turn = "red" then
if game (i) > 9 and value (i) = 0 then
turn := "blue"
value (i) := 1
elsif game (i) = 1 and value (i) = 0 then
Draw.FillOval (85, 85, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 2 and value (i) = 0 then
Draw.FillOval (200, 85, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 3 and value (i) = 0 then
Draw.FillOval (315, 85, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 4 and value (i) = 0 then
Draw.FillOval (85, 200, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 5 and value (i) = 0 then
Draw.FillOval (200, 200, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 6 and value (i) = 0 then
Draw.FillOval (315, 200, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 7 and value (i) = 0 then
Draw.FillOval (85, 315, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 8 and value (i) = 0 then
Draw.FillOval (200, 315, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 9 and value (i) = 0 then
Draw.FillOval (315, 315, 40, 40, brightred)
turn := "blue"
else
turn := "blue"
end if
end if
win
exit when winning > 0
getch (ch)
end for
if winning = 1 then
redwin
elsif winning = 2 then
bluewin
end if
getch (ch)
Window.Close (window1)
winning := 0
window2 := Window.Open ("position:center,center,graphics:400,400")
colourback (black)
cls
colour (white)
Draw.Box (25, 25, maxx - 25, maxy - 25, grey)
Draw.Box (25, 140, maxx - 25, maxy - 25, grey)
Draw.Box (25, 260, maxx - 25, maxy - 25, grey)
Draw.Box (140, 25, maxx - 25, maxy - 25, grey)
Draw.Box (260, 25, maxx - 25, maxy - 25, grey)
turn := "blue"
for i : 1 .. upper (value)
value (i) := 0
end for
for i : 1 .. 9
get : file, game (i)
end for
for i : 1 .. 9
if turn = "blue" then
if game (i) > 9 then
turn := "red"
elsif game (i) = 1 and value (i) = 0 then
Draw.FillOval (85, 85, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 2 and value (i) = 0 then
Draw.FillOval (200, 85, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 3 and value (i) = 0 then
Draw.FillOval (315, 85, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 4 and value (i) = 0 then
Draw.FillOval (85, 200, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 5 and value (i) = 0 then
Draw.FillOval (200, 200, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 6 and value (i) = 0 then
Draw.FillOval (315, 200, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 7 and value (i) = 0 then
Draw.FillOval (85, 315, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 8 and value (i) = 0 then
Draw.FillOval (200, 315, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 9 and value (i) = 0 then
Draw.FillOval (315, 315, 40, 40, brightblue)
turn := "red"
value (i) := 1
else
turn := "red"
end if
elsif turn = "red" then
if game (i) > 9 and value (i) = 0 then
turn := "blue"
value (i) := 1
elsif game (i) = 1 and value (i) = 0 then
Draw.FillOval (85, 85, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 2 and value (i) = 0 then
Draw.FillOval (200, 85, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 3 and value (i) = 0 then
Draw.FillOval (315, 85, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 4 and value (i) = 0 then
Draw.FillOval (85, 200, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 5 and value (i) = 0 then
Draw.FillOval (200, 200, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 6 and value (i) = 0 then
Draw.FillOval (315, 200, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 7 and value (i) = 0 then
Draw.FillOval (85, 315, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 8 and value (i) = 0 then
Draw.FillOval (200, 315, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 9 and value (i) = 0 then
Draw.FillOval (315, 315, 40, 40, brightred)
turn := "blue"
else
turn := "blue"
end if
end if
win
exit when winning > 0
getch (ch)
end for
if winning = 1 then
redwin
elsif winning = 2 then
bluewin
end if
getch (ch)
Window.Close (window1)
winning := 0
window3 := Window.Open ("position:center,center,graphics:400,400")
colourback (black)
cls
colour (white)
Draw.Box (25, 25, maxx - 25, maxy - 25, grey)
Draw.Box (25, 140, maxx - 25, maxy - 25, grey)
Draw.Box (25, 260, maxx - 25, maxy - 25, grey)
Draw.Box (140, 25, maxx - 25, maxy - 25, grey)
Draw.Box (260, 25, maxx - 25, maxy - 25, grey)
turn := "blue"
for i : 1 .. upper (value)
value (i) := 0
end for
for i : 1 .. 9
get : file, game (i)
end for
for i : 1 .. 9
if turn = "blue" then
if game (i) > 9 then
turn := "red"
elsif game (i) = 1 and value (i) = 0 then
Draw.FillOval (85, 85, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 2 and value (i) = 0 then
Draw.FillOval (200, 85, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 3 and value (i) = 0 then
Draw.FillOval (315, 85, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 4 and value (i) = 0 then
Draw.FillOval (85, 200, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 5 and value (i) = 0 then
Draw.FillOval (200, 200, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 6 and value (i) = 0 then
Draw.FillOval (315, 200, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 7 and value (i) = 0 then
Draw.FillOval (85, 315, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 8 and value (i) = 0 then
Draw.FillOval (200, 315, 40, 40, brightblue)
turn := "red"
value (i) := 1
elsif game (i) = 9 and value (i) = 0 then
Draw.FillOval (315, 315, 40, 40, brightblue)
turn := "red"
value (i) := 1
else
turn := "red"
end if
elsif turn = "red" then
if game (i) > 9 and value (i) = 0 then
turn := "blue"
value (i) := 1
elsif game (i) = 1 and value (i) = 0 then
Draw.FillOval (85, 85, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 2 and value (i) = 0 then
Draw.FillOval (200, 85, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 3 and value (i) = 0 then
Draw.FillOval (315, 85, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 4 and value (i) = 0 then
Draw.FillOval (85, 200, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 5 and value (i) = 0 then
Draw.FillOval (200, 200, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 6 and value (i) = 0 then
Draw.FillOval (315, 200, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 7 and value (i) = 0 then
Draw.FillOval (85, 315, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 8 and value (i) = 0 then
Draw.FillOval (200, 315, 40, 40, brightred)
turn := "blue"
value (i) := 1
elsif game (i) = 9 and value (i) = 0 then
Draw.FillOval (315, 315, 40, 40, brightred)
turn := "blue"
else
turn := "blue"
end if
end if
win
exit when winning > 0
getch (ch)
end for
if winning = 1 then
redwin
elsif winning = 2 then
bluewin
end if
|