Tic Tac Toe AI??  | | |
March 20th, 2003, 05:49 PM
|
#1 (permalink)
| | Go back to sleep
Join Date: Jul 2002 Location: Switzerland
Posts: 7,385
| 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 |
| |
March 20th, 2003, 05:54 PM
|
#2 (permalink)
| | Member
Join Date: Nov 2002 Location: Kent England
Posts: 395
|
wouldnt it be helpful to us to know what yr coding in ????????? |
| |
March 20th, 2003, 05:56 PM
|
#3 (permalink)
| | Go back to sleep
Join Date: Jul 2002 Location: Switzerland
Posts: 7,385
|
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 |
| |
March 20th, 2003, 06:02 PM
|
#4 (permalink)
| | Member
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 |
| |
March 20th, 2003, 06:05 PM
|
#5 (permalink)
| | Go back to sleep
Join Date: Jul 2002 Location: Switzerland
Posts: 7,385
| 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 |
| |
March 20th, 2003, 06:39 PM
|
#6 (permalink)
| | ph34r t3h g04t
Join Date: Oct 2001 Location: Kingsford, MI
Posts: 19,531
|
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. |
| |
March 20th, 2003, 10:27 PM
|
#7 (permalink)
| | Banned
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. |
| |
March 21st, 2003, 04:12 AM
|
#8 (permalink)
| | Member
Join Date: Mar 2002 Location: BYU - Provo
Posts: 43
|
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
|
| |
March 21st, 2003, 12:52 PM
|
#9 (permalink)
| | Go back to sleep
Join Date: Jul 2002 Location: Switzerland
Posts: 7,385
|
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 |
| |
March 21st, 2003, 01:05 PM
|
#10 (permalink)
| | Member
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 ***
|
| | | Thread Tools | Search this Thread | | | | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |