-----------------------------------
alnamy
Sun Jun 06, 2004 5:16 pm
tic tac toe AI
-----------------------------------
hey i am currently taking grade 10 science and i am having a lot of difficulties making a 1 person tic tac toe game (against computer). I have completed a 1v1 (two players) tic tac toe game . but i am stuck on where to start a 1 person tic tac toe game. Could someone kindly show me the programming logic or if possible, show me the source code? Thank you very much
-----------------------------------
Tony
Sun Jun 06, 2004 7:02 pm
-----------------------------------
defend - block player's 2 in a row to prevent lose
attack - if no need for defend, form 2 in a row of own
random - if no place to attack ether, just place your sign randomly
-----------------------------------
alnamy
Sun Jun 06, 2004 8:29 pm
please help
-----------------------------------
Here's what I have now. I understand the logic now but i am not sure how to modify it for the comp
% By BTSP
% The Tic Tac Toe Game
%Sets the screen size
setscreen ("graphics:400;400")
%Makes the background
drawfillbox (0, 0, maxx, maxy, black)
%Draws the large box
drawbox (5, 5, maxx - 5, maxy - 5, yellow)
%Draws the smaller boxes
drawline (maxx div 3, maxy - 5, maxx div 3, 5, yellow)
drawline (maxx div 1.5, maxy - 5, maxx div 1.5, 5, yellow)
drawline (maxx - 5, maxy div 3, 5, maxy div 3, yellow)
drawline (maxx - 5, maxy div 1.5, 5, maxy div 1.5, yellow)
var x, y, button : int
var squares : array 1 .. 9 of int
var playerturn : int := 1
var deemah : int :=0
for a : 1 .. 9
squares (a) := a+2
end for
var players : array 1 .. 2 of string
players (1) := "Judy"
players (2) := "Alice"
loop
mousewhere (x, y, button)
if x >= 5 and x = maxy div 1.5 and y maxx div 3 and x = maxy div 1.5 and y maxx div 1.5 and x = maxy div 1.5 and y = 5 and x = maxy div 3 and y maxx div 3 and x = maxy div 3 and y maxx div 1.5 and x = maxy div 3 and y = 5 and x 5 and y maxx div 3 and x 5 and y maxx div 1.5 and x 5 and y