Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Ekim_Gram

Tic Tac Toe AI

This topic is 5428 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
go through every single move the computer can do and at every move go through every possiblity that the opponent can do. If any of the opponents moves make you loose don''t do them. then do the same thing backwards and see if there is any move that the computer can do that will force the computer to win no matter what. Look like two moves ahead and you will be fine.

sorry I don''t have much time to explain now, did any of that make sense to you?



I must''ve told you a million times, don''t over-exaggerate.

Share this post


Link to post
Share on other sites
Heh, if you do that it''ll be impossible for the player to win. I did a TicTacToe game with AI just a few weeks ago. Its harder than it seems

Share this post


Link to post
Share on other sites
quote:
Original post by DarkWhoppy
Heh, if you do that it''ll be impossible for the player to win. I did a TicTacToe game with AI just a few weeks ago. Its harder than it seems


Can you explain to me what you did? Or at least post a piece of your source?




There''s no town drunk here, we all take turns.
Velocity Gaming Force

Share this post


Link to post
Share on other sites
Ekim_Gram:
I'm guessing the logic for a game like Tic-Tac-Toe (aka knots and crosses for them brits ) will take quite a few if statements, or comparisons between arrays to enforce the AI rules.

However, you should be able to cut back on the repition of things with a few recursive calls.

Anyway, try googling about for some examples of how to do the AI. (I'd suggest how to do it but I gave up on that one along time ago, found something more interesting to work on at the time )



[edited by - Kevlar-X on August 13, 2003 12:40:15 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
there are many ways to program an AI for tic tac toe.
One way is to have a list of all possible board positions and then associate with each one the correct next move for each. This is good but not fun to write. (of course there is a lot of symmetry to tic tac toe so many variations are just the same but with the board rotated)

You can do a recursive tree structure that automatically puts a numerical value for each level based on the chances of a win... its cool to accomplish if you are interested in AI in and of itself.

You could also just go through each square at a time and then afterwards randomly fill the board in many times. Use a stat for each square and the one with the highest amount of wins for the computer gets selected.

whatever floats your boat.

Share this post


Link to post
Share on other sites
[threadjacking]Yeah, those brits! So like can I be british if I grew up in a british commonwealth country? Even only if until I was 10?[/threadjacking]

Share this post


Link to post
Share on other sites
I made a tic tact toe game once except it was in VB and it had a very stupid AI. it''s on Vbcode.com. search for it. They have a few cool tic-tac-toe games.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!