Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
tic tac toe help
Author Message
anon656

Posted: Thu Jun 08, 2017 8:23 pm   Post subject: RE:tic tac toe help

Turing:
var a1, a2, a3, b1, b2, b3, c1, c2, c3 : boolean := false
var turn : boolean := false %true for X and false for O
var turns : int := 1
var mainWin : int := Window.Open ("position:middle;center,graphics:800;650,nobuttonbar,title:tic-tac-toe")

proc userturns
if turns mod 2 = 0 then
turn := true
else
turn := false
end if
end userturns

proc userInput
userturns
var picX, picO, x, y, button : int
picX := Pic.FileNew ("picX.jpg")
picO := Pic.FileNew ("picO.jpg")
Draw.ThickLine (300, 100, 300, 550, 10, 7)
Draw.ThickLine (500, 100, 500, 550, 10, 7)
Draw.ThickLine (100, 400, 700, 400, 10, 7)
Draw.ThickLine (100, 250, 700, 250, 10, 7)
loop
Mouse.Where (x, y, button)
if button = 1 then
if x >= 100 and x <= 300 and y >= 100 and y <= 250 and a1 = false then
if turn = true then
Pic.Draw (picX, 150, 120, picCopy)
turn := false
else
Pic.Draw (picO, 150, 120, picCopy)
turn := true
end if
a1 := true
elsif x >= 300 and x < 500 and y >= 100 and y <= 250 and a2 = false then
if turn = true then
Pic.Draw (picX, 350, 120, picCopy)
turn := false
else
Pic.Draw (picO, 350, 120, picCopy)
turn := true
end if
a2 := true
elsif x >= 500 and x < 700 and y >= 100 and y <= 250 and a3 = false then
if turn = true then
Pic.Draw (picX, 550, 120, picCopy)
turn := false
else
Pic.Draw (picO, 550, 120, picCopy)
turn := true
end if
a3 := true
elsif x >= 100 and x < 300 and y >= 250 and y <= 400 and b1 = false then
if turn = true then
Pic.Draw (picX, 150, 275, picCopy)
turn := false
else
Pic.Draw (picO, 150, 275, picCopy)
turn := true
end if
b1 := true
elsif x >= 300 and x < 500 and y >= 250 and y <= 400 and b2 = false then
if turn = true then
Pic.Draw (picX, 350, 275, picCopy)
turn := false
else
Pic.Draw (picO, 350, 275, picCopy)
turn := true
end if
b2 := true
elsif x >= 500 and x < 700 and y >= 250 and y <= 400 and b3 = false then
if turn = true then
Pic.Draw (picX, 550, 275, picCopy)
turn := false
else
Pic.Draw (picO, 550, 275, picCopy)
turn := true
end if
b3 := true
elsif x >= 100 and x < 300 and y >= 400 and y <= 550 and c1 = false then
if turn = true then
Pic.Draw (picX, 150, 430, picCopy)
turn := false
else
Pic.Draw (picO, 150, 430, picCopy)
turn := true
end if
c1 := true
elsif x >= 300 and x < 500 and y >= 400 and y <= 550 and c2 = false then
if turn = true then
Pic.Draw (picX, 350, 430, picCopy)
turn := false
else
Pic.Draw (picO, 350, 430, picCopy)
turn := true
end if
c2 := true
elsif x >= 500 and x < 700 and y >= 400 and y <= 550 and c3 = false then
Pic.Draw (picX, 550, 430, picCopy)
if turn = true then
Pic.Draw (picX, 550, 430, picCopy)
turn := false
else
Pic.Draw (picO, 550, 430, picCopy)
turn := true
end if
c3 := true
end if
end if
end loop
end userInput
userInput

anon656

Posted: Thu Jun 08, 2017 8:27 pm   Post subject: RE:tic tac toe help

How can i make something that figures out who wins?
Insectoid

Posted: Fri Jun 09, 2017 4:20 am   Post subject: RE:tic tac toe help

How do you win a game of tic tac toe?
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 2 of 2  [ 18 Posts ]
Goto page Previous  1, 2
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: