home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

Tic Tac Toe AI??

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 1976
Discussions: 200,919, Posts: 2,379,074, Members: 246,287
Old March 20th, 2003, 05:49 PM   Digg it!   #1 (permalink)
Go back to sleep
 
Creatures's Avatar
 
Join Date: Jul 2002
Location: Switzerland
Posts: 7,385
Send a message via ICQ to Creatures
Question
Tic Tac Toe AI??

well i want to write a tic tac toe game! you remember theses small games?

X_|_O_|_X
O_|_X_|_O
0 | X | X

but i dont know how to write the computer's moves? how can i make him intelligent?

thanks
Creatures
__________________
Canon EOS 450D | Canon EF-S 18-55mm 1:3.5-5.6 IS | Canon EF-S 55-250mm 1:4-5.6 IS | Canon Speedlite 430EX II
Creatures is offline   Reply With Quote
Old March 20th, 2003, 05:54 PM     #2 (permalink)
Member
 
Carl-cox-'s Avatar
 
Join Date: Nov 2002
Location: Kent England
Posts: 395
wouldnt it be helpful to us to know what yr coding in ?????????
Carl-cox- is offline   Reply With Quote
Old March 20th, 2003, 05:56 PM     #3 (permalink)
Go back to sleep
 
Creatures's Avatar
 
Join Date: Jul 2002
Location: Switzerland
Posts: 7,385
Send a message via ICQ to Creatures
well no because i'm programming on my pocket claculator =) TI 83 + (not silver edition)

but a Actionscript or PHP or CGI would help too i can read nearly all scripts (not write) so i just need ideas and tips!

Creatures
Creatures is offline   Reply With Quote
Old March 20th, 2003, 06:02 PM     #4 (permalink)
Member
 
Carl-cox-'s Avatar
 
Join Date: Nov 2002
Location: Kent England
Posts: 395
the only way i can really think is of using if commands like in vb. im doing a vb game atm called shut the box for my college course. luckaly it doesnt hav to hav AI Easiest would be a random command but i think this would make the computer sort of dum if ya know what i mean. i would go for the if command, but this would produce alot of coding i pesume maybe some expert can help better
__________________
http://www.coxeh.com
Carl-cox- is offline   Reply With Quote
Old March 20th, 2003, 06:05 PM     #5 (permalink)
Go back to sleep
 
Creatures's Avatar
 
Join Date: Jul 2002
Location: Switzerland
Posts: 7,385
Send a message via ICQ to Creatures
Quote:
Originally posted by Carl-cox-
the only way i can really think is of using if commands like in vb. im doing a vb game atm called shut the box for my college course. luckaly it doesnt hav to hav AI Easiest would be a random command but i think this would make the computer sort of dum if ya know what i mean. i would go for the if command, but this would produce alot of coding i pesume maybe some expert can help better

well the if command isnt that good because it wont change a thing while your playing because it will always be the same! so i need a good "AI"

Creatures
Creatures is offline   Reply With Quote
Old March 20th, 2003, 06:39 PM     #6 (permalink)
ph34r t3h g04t
 
Whir's Avatar
 
Join Date: Oct 2001
Location: Kingsford, MI
Posts: 19,531
Blog Entries: 7
Hah, LISP would be a great way to program that.

One really lengthy way of doing it would be to figure out all the countermoves the computer should make depending on where the human player places a piece. That's really all Big Blue was. It thought out millions of move possibilities in advance and then selected the best from a list.
Whir is offline   Reply With Quote
Old March 20th, 2003, 10:27 PM     #7 (permalink)
Banned
 
qball's Avatar
 
Join Date: Oct 2001
Posts: 447
Quote:
but i dont know how to write the computer's moves? how can i make him intelligent?

well, you actually write the code/logic to do this. The program only as intelligent as the code/logic that defines the program.

simple answer:
get really good a ttt. never lose, win OR tie.
then write down what moves you make based upon other player's move(s).
you now have a good logic based rules system to play ttt.

harder answer:
take good logic based rules system and convert to code

basically any programming language can handle the logic.
qball is offline   Reply With Quote
Old March 21st, 2003, 04:12 AM     #8 (permalink)
Member
 
Join Date: Mar 2002
Location: BYU - Provo
Posts: 43
Send a message via AIM to Fractile81 Send a message via Yahoo to Fractile81
I think it was stated before, but something as to this sort:

Computer First:
1) Perhaps randomly choose a place (might be more fair)

2) Let player make a move ( jump to here if the player plays first)

3a) Check if the computer can win, and place accordingly
3b) If not, check if the player might win their next move (really hairy way would be to check all rows, cols, and then the two diags just to make sure, using a for-loop or the like... again, hairy ), and block if needed
3c) Last resort: try to build off of previous moves, weighting moves by their ability to block the player from making a complete line

4) Jump back to step 2

This is a more dynamic algorithm than you would ever really need. It could probably just be replaced by a lot of if-statements. So, I guess that becomes your question: you want a static AI ( lots of if's) that is very "narrow-minded" or a dynamic AI ( the hairy part above) which, while still predictable, will act "intelligently"?

I know I'm stating the obvious, but it's certainly the first approach I'd take... plus, now you have a bare-bones algorithm
__________________
-Fractile81
Fractile81 is offline   Reply With Quote
Old March 21st, 2003, 12:52 PM     #9 (permalink)
Go back to sleep
 
Creatures's Avatar
 
Join Date: Jul 2002
Location: Switzerland
Posts: 7,385
Send a message via ICQ to Creatures
thanks fractile awsome, but the computer will never loose this way =) but i can put in a random which let him think or just make a not calculated move!

Creatures
Creatures is offline   Reply With Quote
Old March 21st, 2003, 01:05 PM     #10 (permalink)
Member
 
quux's Avatar
 
Join Date: Nov 2002
Location: Hamburg
Posts: 244
Quote:
Originally posted by Whir
Hah, LISP would be a great way to program that.
...

YEAH ! ...

... do a google on heuristic programming + <the game in focus> .

You might want to extend into REVERSI which lends itself pretty well to the effort.

CC.
__________________
*** all that we C or Scheme is
but a dream within a dream ***
quux is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (2850)
Obama the Muslim (13)
Why is Khalid Sheikh Mohammed even .. (9)
Is the PSU I received dead? (10)
windows vista security holes (8)
Foreign voltage (10)
HIS HD5770 graphic card question (15)
Install XP pro and a Vista laptop ?.. (9)
Print spooler problem (12)
Dept. of HS: NSA 'Helped' Develop V.. (15)
A good PSU? (10)
New Computer wont recognize XP disc (7)
Ideal cheap graph card for PC-Gamin.. (15)
EVGA 9800 gtx help with finding a g.. (8)
Recent Discussions
Help getting around port 80 for camer.. (2)
Display shows 3x5 inch in middle of s.. (3)
windows vista security holes (8)
monitor will not turn on at all, (1)
Print spooler problem (12)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (33)
World's largest Monopoly Game using G.. (331)
Foreign voltage (10)
FiOS modem/router interfering with ne.. (7)
Browsers wont load websites (2)
Virus Doctor Popup? (1)
Dept. of HS: NSA 'Helped' Develop Vis.. (15)
Install XP pro and a Vista laptop ?? (9)
EVGA 9800 gtx help with finding a goo.. (8)
Modern Warfare For the PC (32)
Problem with speed step/turbo boost? (1)
Modern Warfare 2: Who Bought It? (61)
SIS 740 and Widescreen (8)
Baffling Problem with my CPU/MoBo's. .. (0)
HIS HD5770 graphic card question (15)
Best file format to play on Windows H.. (0)
PSP Go bought in Japan (0)
Asus P4G8X Mobo (3)
Need hard disk drivers (4)
windows 7 internet problem (4)


All times are GMT -4. The time now is 08:16 PM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28