Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Tic Tac Toe AI help

Author
Message
RangerEllis
13
Years of Service
User Offline
Joined: 15th Jan 2011
Location: Terrestrial Productions Current Project:
Posted: 31st Jan 2011 02:41
I am currently programming a tic tac toe game, but I need help with making an AI for the computer. Are there any suggestions, or help I could have?
n008
17
Years of Service
User Offline
Joined: 18th Apr 2007
Location: Chernarus
Posted: 31st Jan 2011 02:57
Think up a good algorithm for solving a tic-tac-toe puzzle move-by-move, and then put it into code.

"I have faith, that I shall win the race, even though I have no legs, and am tied to a tree." ~Mark75
RangerEllis
13
Years of Service
User Offline
Joined: 15th Jan 2011
Location: Terrestrial Productions Current Project:
Posted: 31st Jan 2011 05:07
You mean a whole bunch of "if" and "else if" type of situation?
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 1st Feb 2011 02:51
I would make a few starting scenarios with some if's, but after the initial move, it should be a blocking game unless there is a winning play. Something like this:
if the computer is first - I would put it in the center square
then if the player puts his in a corner, randomly place the computer's in any of the squares that would not be blocked by the player move. Repeat this each time taking into account all the player's moves.

if the player is first - there's no strategy but to block. Randomly place the computer's first move anywhere there's an open spot. When the player makes his next move, check the line for the spot to block.

Each move, check for a line for the win.... It's a simple game, but is a good logic starter to hone your skills on.

The fastest code is the code never written.
TechLord
21
Years of Service
User Offline
Joined: 19th Dec 2002
Location: TheGameDevStore.com
Posted: 1st Feb 2011 12:08
Quote: "It would REALLY help if someone joined who knew how to make a Tic Tac Toe AI. "
Code it yourself with a Tic-Tac-Toe A.I. WalkThrough.

C++ Conversion

VB
C++


VB
C++


VB
C++


VB
C++


Login to post a reply

Server time is: 2024-11-19 14:48:24
Your offset time is: 2024-11-19 14:48:24