Tic Tac Toe AI HELP/CORRECTION 
	 
	
		| Author | 
		Message | 
	 
		 
		phillipsworld
 
 
 
    
		 | 
		
		
			
				  Posted: Thu Mar 03, 2011 6:58 pm    Post subject: Tic Tac Toe AI HELP/CORRECTION  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				Okay i dont know why but everything just disappeared and i am retyping this for the second time :@.
 
 
Okay i need help with my AI. This is a Tic Tac Toe game once i place a mark the computer wont do it after me. 
 
The code is there can some one adjust/change around for me so it works or tell me how to change it i would really appreciate it.  
 
 
For the player you click the black circles to make your move. computer wont work that is my problem....
 
 
I am new to turing i only started it couple weeks ago please don't hate.
 
 
Turing Code if you do not want to download it:
 
 
 
%Tic Tac Toe
 
View.Set ("graphics:1000,480")
 
%Grid
 
var start : string (1)
 
var font0 : int := Font.New ("Arial:15")
 
var font : int := Font.New ("Courier New:20")
 
var font1 : int := Font.New ("Viner Hand ITC:20")
 
var font2 : int := Font.New ("Courier New:40")
 
var font3 : int := Font.New ("BankGothic Md BT:30")
 
var font4 : int := Font.New ("BankGothic Md BT:20")
 
var font5 : int := Font.New ("BankGothic Md BT:15")
 
var unt1, unt2, unt3, unt4, unt5, unt6, unt7, unt8, unt9 : int := 0
 
var slct, cslct, AIslct : int := 0
 
var playwn, dcsn : int := 0
 
%Ground
 
drawfillbox (0, 0, 1000, 20, 115)
 
%Sky
 
drawfillbox (0, 20, 1000, 480, 125)
 
%MOON
 
drawfilloval (885, 310, 55, 50, 44)
 
%CLOUD
 
drawfilloval (800, 310, 60, 20, grey)
 
drawfilloval (800, 328, 30, 10, grey)
 
drawfilloval (790, 290, 50, 10, grey)
 
drawfilloval (770, 308, 40, 20, grey)
 
drawfilloval (770, 308, 60, 20, grey)
 
%CLOUD2
 
drawfilloval (400, 390, 60, 20, grey)
 
drawfilloval (400, 408, 30, 10, grey)
 
drawfilloval (380, 370, 50, 10, grey)
 
drawfilloval (360, 388, 40, 20, grey)
 
drawfilloval (360, 388, 60, 20, grey)
 
%CLOUD3
 
drawfilloval (140, 260, 60, 20, grey)
 
drawfilloval (140, 278, 30, 10, grey)
 
drawfilloval (120, 240, 50, 10, grey)
 
drawfilloval (100, 258, 40, 20, grey)
 
drawfilloval (100, 258, 60, 20, grey)
 
%CITY
 
drawfillbox (490, 20, 550, 100, 140)
 
drawfillbox (510, 20, 530, 50, black)
 
 
drawfillbox (390, 20, 470, 80, 187)
 
drawfillbox (420, 20, 440, 50, black)
 
 
drawfillbox (570, 20, 650, 60, 140)
 
drawfillbox (590, 20, 610, 46, black)
 
 
%PERSON
 
drawfilloval (480, 53, 9, 9, 139)
 
drawfillbox (485, 45, 475, 20, white)
 
 
%PERSON
 
drawfilloval (680, 53, 9, 9, 139)
 
drawfillbox (685, 45, 675, 20, 28)
 
 
%PERSON
 
drawfilloval (280, 53, 9, 9, 139)
 
drawfillbox (285, 45, 275, 20, 21)
 
Font.Draw ("Defuse The Bomb!", 469, 420, font3, green)
 
Font.Draw ("Defuse The Bomb!", 470, 421, font3, black)
 
Font.Draw ("Defuse The Bomb By Playing Tic Tac Toe.", 292, 160, font5, black)
 
Font.Draw ("Defuse The Bomb By Playing Tic Tac Toe.", 290, 160, font5, black)
 
Font.Draw ("GOOD LUCK ON YOUR MISSION. Press any key to continue.", 51, 130, font4, green)
 
Font.Draw ("GOOD LUCK ON YOUR MISSION. Press any key to continue.", 50, 130, font4, black)
 
Font.Draw ("Phillip Grzybowski?", 751, 20, font5, green)
 
Font.Draw ("Phillip Grzybowski?", 750, 20, font5, black)
 
 
getch (start)
 
 
 
%TABLE
 
drawfillbox (0, 0, 1000, 480, 115)
 
%
 
drawfillbox (0, 0, 251, 291, black)
 
% Paper
 
drawfillbox (0, 0, 250, 290, 0)
 
%TXT
 
Font.Draw ("Defuse The Bomb", 25, 235, font1, black)
 
Font.Draw ("By Getting   3         's", 5, 185, font1, black)
 
Font.Draw ("In  A  Row.", 5, 135, font1, black)
 
Font.Draw ("Good Luck.", 5, 45, font1, black)
 
Font.Draw ("From, Al  Qaeda", 30, 10, font1, black)
 
%circle
 
drawfilloval (210, 190, 17, 17, black)
 
drawfilloval (210, 190, 15, 15, 10)
 
%wires
 
drawarc (625, 353, 65, 40, 270, 180, red)
 
drawarc (624, 354, 65, 40, 270, 180, red)
 
drawarc (623, 355, 65, 40, 270, 180, red)
 
drawarc (622, 356, 65, 40, 270, 180, red)
 
drawarc (621, 357, 65, 40, 270, 180, red)
 
drawarc (620, 358, 65, 40, 270, 180, red)
 
drawarc (619, 359, 65, 40, 270, 180, red)
 
drawarc (618, 360, 65, 40, 270, 180, red)
 
%wire2
 
drawarc (600, 340, 65, 40, 270, 180, yellow)
 
drawarc (599, 340, 65, 40, 271, 180, yellow)
 
drawarc (598, 340, 65, 40, 272, 180, yellow)
 
drawarc (597, 340, 65, 40, 273, 180, yellow)
 
drawarc (596, 340, 65, 40, 274, 180, yellow)
 
 
 
%Bomb
 
drawfillbox (300, 20, 700, 350, black)
 
%
 
drawfillbox (301, 21, 700, 350, 23)
 
%
 
 
%
 
drawfillbox (300, 320, 620, 420, 23)
 
%Bombscreen_around
 
drawfillbox (319, 349, 571, 411, black)
 
%Bombscreen
 
drawfillbox (320, 350, 570, 410, 143)
 
%
 
drawfilloval (595, 375, 15, 15, black)
 
%Red Light
 
drawfilloval (595, 375, 13, 13, 12)
 
%Explosives
 
drawfillbox (699, 19, 921, 351, black)
 
%
 
drawfillbox (700, 20, 920, 350, 190)
 
%
 
drawfillbox (700, 280, 920, 300, black)
 
%
 
drawfillbox (835, 350, 860, 20, black)
 
%
 
drawfillbox (700, 180, 920, 200, black)
 
%
 
drawfillbox (700, 80, 920, 100, black)
 
%
 
drawfillbox (685, 270, 695, 120, black)
 
%
 
drawfillbox (780, 270, 770, 120, black)
 
%
 
drawfillbox (689, 250, 775, 140, grey)
 
%
 
drawline (300, 420, 300, 290, black)
 
%
 
drawline (300, 420, 620, 420, black)
 
%
 
drawline (620, 420, 620, 350, black)
 
%
 
drawline (620, 350, 699, 350, black)
 
%
 
drawline (688, 250, 688, 140, red)
 
drawline (689, 250, 689, 140, red)
 
drawline (690, 250, 690, 140, red)
 
drawline (691, 250, 691, 140, red)
 
drawline (774, 250, 774, 140, red)
 
drawline (775, 250, 775, 140, red)
 
drawline (775, 250, 775, 140, red)
 
drawline (776, 250, 776, 140, red)
 
drawline (695, 220, 770, 220, black)
 
drawline (695, 240, 770, 240, black)
 
drawline (695, 200, 770, 200, black)
 
drawline (695, 180, 770, 180, black)
 
drawline (695, 160, 770, 160, black)
 
proc GameBoard
 
    %chartvertical
 
    drawfillbox (430, 30, 440, 340, black)
 
    drawfillbox (550, 30, 560, 340, black)
 
    %horizontal
 
    drawfillbox (320, 240, 680, 250, black)
 
    drawfillbox (320, 130, 680, 140, black)
 
end GameBoard
 
%Click Guide (Black Circles)
 
%BL
 
drawfilloval (367, 77, 30, 30, black)
 
%BM
 
drawfilloval (492, 77, 30, 30, black)
 
%BR
 
drawfilloval (617, 77, 30, 30, black)
 
%ML
 
drawfilloval (370, 192, 30, 30, black)
 
%MM
 
drawfilloval (492, 192, 30, 30, black)
 
%MR
 
drawfilloval (617, 192, 30, 30, black)
 
%TL
 
drawfilloval (377, 297, 30, 30, black)
 
%TM
 
drawfilloval (492, 297, 30, 30, black)
 
%TR
 
drawfilloval (617, 297, 30, 30, black)
 
%BOMB TXT
 
Font.Draw ("5 min...", 320, 355, font2, 18)
 
%Numbered boxes
 
Font.Draw ("1", 410, 255, font, black)
 
Font.Draw ("1", 411, 255, font, black)
 
%
 
Font.Draw ("2", 530, 255, font, black)
 
Font.Draw ("2", 531, 255, font, black)
 
%
 
Font.Draw ("3", 660, 255, font, black)
 
Font.Draw ("3", 661, 255, font, black)
 
%
 
Font.Draw ("4", 410, 145, font, black)
 
Font.Draw ("4", 411, 145, font, black)
 
%
 
Font.Draw ("5", 530, 145, font, black)
 
Font.Draw ("5", 531, 145, font, black)
 
%
 
Font.Draw ("6", 660, 145, font, black)
 
Font.Draw ("6", 661, 145, font, black)
 
%
 
Font.Draw ("7", 410, 35, font, black)
 
Font.Draw ("7", 411, 35, font, black)
 
%
 
Font.Draw ("8", 530, 35, font, black)
 
Font.Draw ("8", 531, 35, font, black)
 
%
 
Font.Draw ("9", 660, 35, font, black)
 
Font.Draw ("9", 661, 35, font, black)
 
%
 
% draw O in bottom left spot
 
proc OBL
 
    drawfilloval (367, 77, 25, 25, 10)
 
end OBL
 
% draw O in bottom middle spot
 
proc OBM
 
    drawfilloval (492, 77, 25, 25, 10)
 
end OBM
 
% draw O in bottom right spot
 
proc OBR
 
    drawfilloval (617, 77, 25, 25, 10)
 
end OBR
 
% draw O in middle left spot
 
proc OML
 
    drawfilloval (370, 192, 25, 25, 10)
 
 
end OML
 
% draw O in middle spot
 
proc OM
 
    drawfilloval (492, 192, 25, 25, 10)
 
 
end OM
 
% draw O in middle right spot
 
proc OMR
 
    drawfilloval (617, 192, 25, 25, 10)
 
end OMR
 
% draw O in top left spot
 
proc OTL
 
    drawfilloval (377, 297, 25, 25, 10)
 
end OTL
 
% Draw O in top middle spot
 
proc OTM
 
    drawfilloval (492, 297, 25, 25, 10)
 
 
end OTM
 
% draw O in top right spot
 
proc OTR
 
    drawfilloval (617, 297, 25, 25, 10)
 
 
end OTR
 
% draw O in place selected/if statements.
 
proc DrawO
 
    var x, y, b : int
 
    loop
 
        Mouse.Where (x, y, b)
 
 
        if b = 1 and x > 325 and x < 435
 
                and y > 65 and y < 150 then
 
            OBL
 
 
        elsif b = 1 and x > 435 and x < 550
 
                and y > 30 and y < 150 then
 
            OBM
 
 
        elsif b = 1 and x > 550 and x < 640
 
                and y > 65 and y < 150 then
 
            OBR
 
 
        elsif b = 1 and x > 325 and x < 435
 
                and y > 150 and y < 235 then
 
            OML
 
 
        elsif b = 1 and x > 410 and x < 495
 
                and y > 150 and y < 235 then
 
            OM
 
 
        elsif b = 1 and x > 550 and x < 640
 
                and y > 150 and y < 235 then
 
            OMR
 
 
        elsif b = 1 and x > 325 and x < 435
 
                and y > 235 and y < 320 then
 
            OTL
 
 
        elsif b = 1 and x > 410 and x < 495
 
                and y > 235 and y < 320 then
 
            OTM
 
 
        elsif b = 1 and x > 585 and x < 680
 
                and y > 235 and y < 320 then
 
            OTR
 
 
        end if
 
        exit when b = 1
 
    end loop
 
end DrawO
 
 
 
GameBoard
 
DrawO
 
delay (500)
 
DrawO
 
delay (500)
 
DrawO
 
delay (500)
 
DrawO
 
delay (500)
 
DrawO
 
delay (500)
 
 
% COMPUTER
 
% unt1, unt2, unt3, unt4, unt5, unt6, unt7, unt8, unt9 statements
 
 
loop
 
    if (slct = 1) and unt1 = 0 then
 
        drawfilloval (367, 77, 25, 25, 10)
 
        unt1 := 1
 
    elsif (slct = 2) and unt2 = 0 then
 
        drawfilloval (492, 77, 25, 25, 10)
 
        unt2 := 1
 
    elsif (slct = 3) and unt3 = 0 then
 
        drawfilloval (617, 77, 25, 25, 10)
 
        unt3 := 1
 
    elsif (slct = 4) and unt4 = 0 then
 
        drawfilloval (370, 192, 25, 25, 10)
 
        unt4 := 1
 
    elsif (slct = 5) and unt5 = 0 then
 
        drawfilloval (492, 192, 25, 25, 10)
 
        unt5 := 1
 
    elsif (slct = 6) and unt6 = 0 then
 
        drawfilloval (617, 192, 25, 25, 10)
 
        unt6 := 1
 
    elsif (slct = 7) and unt7 = 0 then
 
        drawfilloval (377, 297, 25, 25, 10)
 
        unt7 := 1
 
    elsif (slct = 8) and unt8 = 0 then
 
        drawfilloval (492, 297, 25, 25, 10)
 
        unt8 := 1
 
    elsif (slct = 9) and unt9 = 0 then
 
        drawfilloval (617, 297, 25, 25, 10)
 
        unt9 := 1
 
    end if
 
 
    %COMPUTER STRATS
 
    if AIslct = 0 then
 
        loop
 
            randint (AIslct, 1, 9)
 
            if AIslct = 1 and unt1 > 0 then
 
                AIslct := 0
 
            elsif AIslct = 2 and unt2 > 0 then
 
                AIslct := 0
 
            elsif AIslct = 3 and unt3 > 0 then
 
                AIslct := 0
 
            elsif AIslct = 4 and unt4 > 0 then
 
                AIslct := 0
 
            elsif AIslct = 5 and unt5 > 0 then
 
                AIslct := 0
 
            elsif AIslct = 6 and unt6 > 0 then
 
                AIslct := 0
 
            elsif AIslct = 7 and unt7 > 0 then
 
                AIslct := 0
 
            elsif AIslct = 8 and unt8 > 0 then
 
                AIslct := 0
 
            elsif AIslct = 9 and unt9 > 0 then
 
                AIslct := 0
 
            end if
 
            exit when AIslct > 0
 
        end loop
 
    end if
 
    if (AIslct = 1) and unt1 = 0 then
 
        drawfilloval (367, 77, 25, 25, red)
 
        unt1 := 2
 
    elsif (AIslct = 2) and unt2 = 0 then
 
        drawfilloval (492, 77, 25, 25, red)
 
        unt2 := 2
 
    elsif (AIslct = 3) and unt3 = 0 then
 
        drawfilloval (617, 77, 25, 25, red)
 
        unt3 := 2
 
    elsif (AIslct = 4) and unt4 = 0 then
 
        drawfilloval (370, 192, 25, 25, red)
 
        unt4 := 2
 
    elsif (AIslct = 5) and unt5 = 0 then
 
        drawfilloval (492, 192, 25, 25, red)
 
        unt5 := 2
 
    elsif (AIslct = 6) and unt6 = 0 then
 
        drawfilloval (617, 192, 25, 25, red)
 
        unt6 := 2
 
    elsif (AIslct = 7) and unt7 = 0 then
 
        drawfilloval (377, 297, 25, 25, red)
 
        unt7 := 2
 
    elsif (AIslct = 8) and unt8 = 0 then
 
        drawfilloval (492, 297, 25, 25, red)
 
        unt8 := 2
 
    elsif (AIslct = 9) and unt9 = 0 then
 
        drawfilloval (617, 297, 25, 25, red)
 
        unt9 := 2
 
    end if
 
    AIslct := 0
 
end loop
		
	
  
          
							 
	
	
		
	 
	
		|  Description: | 
		
			
		 | 
		  Download | 
	 
	
		|  Filename: | 
		 TicTacToe.t | 
	 
	
		|  Filesize: | 
		 10.33 KB | 
	 
	
		|  Downloaded: | 
		 195 Time(s) | 
	 
	 
	 
		
 | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
		 
		Sponsor Sponsor 
		 
  
		 | 
		
 | 
	 
	 
		  | 
	 
				 
		Insectoid
 
  
 
    
		 | 
		
		
			
				  Posted: Thu Mar 03, 2011 7:47 pm    Post subject: RE:Tic Tac Toe AI HELP/CORRECTION  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| I recommend looking into loops and functions before thinking about games at all- let alone AI.
		
 | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		phillipsworld
 
 
 
    
		 | 
		
		
			
				  Posted: Fri Mar 04, 2011 12:35 am    Post subject: RE:Tic Tac Toe AI HELP/CORRECTION  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				well thanks for the recommendation but this is a assignment for school...
 
still looking for help
		
 | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		mirhagk
 
 
 
    
		 | 
		
		
			
				  Posted: Fri Mar 04, 2011 8:04 am    Post subject: RE:Tic Tac Toe AI HELP/CORRECTION  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				You really need to learn loops before you can really implement any sort of AI.
 
 
There are many tutorials on this website describing loops, they are easy enough to understand, and very important.
 
 
I very much doubt your school gave you an assignment to make a game before they told you about loops.
		
 | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		Zren
 
  
 
    
		 | 
		
		
			
				  Posted: Fri Mar 04, 2011 12:10 pm    Post subject: Re: Tic Tac Toe AI HELP/CORRECTION  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				If your lost, he meant these places specifically:
 
 
- Turing Tutorials
 
- The Turing Walkthrough - A vast collection of links to learning Turing for beginners (and intermediate)
 
- Loops Tutorial
 
 
The advantages of loops are that you can convert:
 
	  | Turing: | 	 		  
 
put 1
 
put 2
 
put 3
 
...
 
put 10
 
  | 	  
 
 
Into:
 
	  | Turing: | 	 		  for i : 1 .. 10
 
    put i
 
end for  | 	  
 
 
With that you can start with nested loops. Where you do a loop of a loop. Eg: I punched a friend 5 times for 10 days.
 
 
	  | Turing: | 	 		  
 
for day : 1 .. 10
 
    put "Day ", day
 
    for punch : 1 .. 5
 
        put "Attack!"
 
    end for
 
end for
 
  | 	  
 
 
Now look at tic tac toe. It's a 3 by 3 grid right?
 
Imagine printing the character X or O 3 times on one line, then for the second line...
 
 
Tip: The following will print out asdfgh on the same line.
 
put "asd" ..
 
put "fgh"
 
 
Oh, and just a little incentive to learning loops. If I remember right, someone submitted tic tac toe without using loops, and only using conditionals (if/else) for every single possibility. It was around 10 000 lines of code, probably more. With loops, you could probably do the barebones of a 2player tic tac toe match in 100 lines (without the AI) (minus the fancy graphics).
		
 | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		Insectoid
 
  
 
    
		 | 
		
		
			
				  Posted: Fri Mar 04, 2011 2:29 pm    Post subject: RE:Tic Tac Toe AI HELP/CORRECTION  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| tic-tac-toe HAS been done in less than twenty lines, for the record.
		
 | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		mirhagk
 
 
 
    
		 | 
		
		
			
				  Posted: Fri Mar 04, 2011 2:52 pm    Post subject: RE:Tic Tac Toe AI HELP/CORRECTION  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				COMPETITION!!!!!! Do 2 Player Tic-Tac-Toe in as few lines as possible
 
 
EDIT: Rulez must prompt correct player for input, and then redraw the board every move (board may be text if you would like)
 
 
Input must be two numbers, x and y coordinate
		
 | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		Dante
 
  
 
    
		 | 
		
		
			
				  Posted: Tue Mar 08, 2011 8:05 pm    Post subject: Re: RE:Tic Tac Toe AI HELP/CORRECTION  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				Insectoid @ Fri Mar 04, 2011 2:29 pm wrote: tic-tac-toe HAS been done in less than twenty lines, for the record. 
 
 
Woah, that seems pretty amazing.
		
 | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
		 
		Sponsor Sponsor 
		 
  
		 | 
		
 | 
	 
	 
		  | 
	 
				 
		Sur_real
 
 
 
    
		 | 
		
		 | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		Insectoid
 
  
 
    
		 | 
		
		
			
				  Posted: Tue Mar 08, 2011 9:06 pm    Post subject: RE:Tic Tac Toe AI HELP/CORRECTION  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| That's multiple lines of code put onto a single line in the editor. It's still hundreds of lines.
		
 | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		Sur_real
 
 
 
    
		 | 
		
		
			
				  Posted: Tue Mar 08, 2011 10:06 pm    Post subject: RE:Tic Tac Toe AI HELP/CORRECTION  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				yeah that's why I said "technically" lol
 
 
maybe try in the fewest number of characters/words possible rather than lines.
		
 | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		Zren
 
  
 
    
		 | 
		
		
			
				  Posted: Wed Mar 09, 2011 8:23 am    Post subject: Re: RE:Tic Tac Toe AI HELP/CORRECTION  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				Insectoid @ Fri Mar 04, 2011 2:29 pm wrote: tic-tac-toe HAS been done in less than twenty lines, for the record. 
 
Got the link?
 
 
mirhagk @ Fri Mar 04, 2011 2:52 pm wrote: COMPETITION!!!!!! Do 2 Player Tic-Tac-Toe in as few lines as possible
 
 
EDIT: Rulez must prompt correct player for input, and then redraw the board every move (board may be text if you would like)
 
 
Input must be two numbers, x and y coordinate 
 
Challenge accepted!
 
 
	  | Turing: | 	 		  
% Turn is skipped when:
%     selecting cell already taken
%     selecting invalid coords
% unnecessary 3 lines
fcn calcIndex  (x  : string, y  : string) : int
    result (strint (y ) -  1) * 3 +  (strint (x ) -  1) +  1
end calcIndex
 var board  : array 1 ..  9 of int := init (43,  43,  43,  43,  43,  43,  43,  43,  43) % Spaces
var x, y, winner  : string := " "
loop
    for player  : 79 ..  88 by 9 % O, X
        for ind  : 0 ..  8
            locate (ind  div 3 +  1, ind  mod 3 +  1) % output is 1,2,3 \n 4,5,6 ...
            put chr (board  (ind +  1))
        end for
        put "Input [separated by space]: x[1..3] y[1..3] ", skip, " > "..  % This line is unnecessary function wise (-1 line)
        get x, y
         if strintok (x ) and strintok (y ) and 0 <=  strint (x ) and strint (x ) <=  3 and 0 <=  strint (y ) and strint (y ) <=  3 and board  (calcIndex  (x, y )) = 43 then
            board  (calcIndex  (x, y )) := player
         end if
        if board (1) = 79 and board (2) = 79 and board (3) = 79 then %all end cases scenarios
            winner  := chr(player )
        end if
        exit when winner  not=  " "
    end for
    exit when winner  not=  " "
end loop
put "The mighty victor is " + winner +  "!"
  | 	  
 
 
Total: 30 lines
 
Without comments/empty lines: 24 lines
 
Without unnecessary lines: 20 lines
 
 
You could probably go smaller by hacking it with that one technique (like the one used in that recent pong remake), but that's cheap man.
 
 
Edit: This is probably not the place to post (almost) full answers.... >.> Ah well.
 
The looping/exit logic could also probably be different with a non local variable for the turn and moving the endgame logic to the exit when statement. Meh.
		
 | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		Insectoid
 
  
 
    
		 | 
		
		
			
				  Posted: Wed Mar 09, 2011 9:22 am    Post subject: RE:Tic Tac Toe AI HELP/CORRECTION  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| Tony has outlined the best of the 20-line-or-less programs somewhere on his blog, though I can't find it.
		
 | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		mirhagk
 
 
 
    
		 | 
		
		
			
				  Posted: Wed Mar 09, 2011 5:51 pm    Post subject: RE:Tic Tac Toe AI HELP/CORRECTION  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				I gave up with it when I realized turing doesn't treat strings and char arrays the same way (they are completely different in turing).
 
 
Forgot I hate high level things sometimes.
		
 | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		 | 
	 
 
	
	
	 
	
	 |