Jump to content

What can you suggest me on creating games like tic tac toe?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
G33k

G33k

    Newbie

  • Members
  • PipPip
  • 19 posts
I'm trying to create tic tac toe program which never would lose to player, but I'm doing very bad... Can you suggest me what should I do? Just any ideas (no code needed, want to write code by my own). Thanks.

#2
tate

tate

    Learning Programmer

  • Members
  • PipPipPip
  • 90 posts
There are only so many ways a tic-tac-toe game can go. If you don't want it to lose, look into the ways to win and force a stale-mate. You will need two different strategies based on whether the player gets to go first or not. If you go first all you need to do is pick the middle and then counter every move to force a stale-mate. There are only two strategies that i know off the top of my head that can force a win but they are very situational (i'll let you figure them out) so as long as you know what not to do, you can make your program attempt the force win and then if the correct situation does not occur, just counter to force a stale-mate.
twas brillig

#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Do you know the standard strategy to never lose tic-tac-toe? Can you always not-lose when playing against a person? You just need to reimplement that logic.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog