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: 1402
Discussions: 200,507, Posts: 2,374,395, Members: 245,831
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,360
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,360
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,360
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,386
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,360
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? (1635)
FT HOOD attack: 7 killed 12 injured (66)
Review My Build (5)
HELP!!! What do you think of this s.. (16)
Looking for a graphic card that wil.. (30)
Assosiations (21496)
My 1st pc build (40)
Aero in Vista (7)
PC Modern Warfare 2: it's much wors.. (12)
core i7 extreme 975, nvidia 9400gt (9)
How to Ship a PC (16)
Building my first computer (13)
slaving laptop drive (7)
[F@H SPAM 11/1/09]New month . . . n.. (33)
Recent Discussions
how to convert mod to wmv/avi/mp4/mov.. (0)
FAT32 to NTFS file system in Win2kpro (3)
Motherboards and my curse... (25)
Review My Build (5)
HELP!!! What do you think of this sys.. (16)
New Processor, Monitor will not turn .. (2)
2009 Build (4)
Internet very slow since updating AVG.. (7)
My 1st pc build (40)
Freezing During Music/Movies (1)
Windows Experience Index is screwed u.. (2)
ext. sound card laptop to stereo syst.. (2)
Remote Desktop via SSH and error mess.. (2)
Help and Support disappeared from my .. (0)
[F@H SPAM 11/1/09]New month . . . new.. (33)
Basic applications needed for "r.. (1)
core i7 extreme 975, nvidia 9400gt (9)
hard drive problem (2)
Win7 TrustedInstaller Permissions (2)
Speed up Win 7 boot time a bit (1)
Hard Drive test program (2)
wireless westell versalink model 327w (1)
New build 10 second reboot cycle! Won.. (3)
New Linksys Routers (2)
sometime power/Amber light (0)


All times are GMT -4. The time now is 04:48 AM.
TechIMO Copyright 2008 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