954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

tic tac toe using minimax

i am new to minimax algorithm. while searching in google i could roughly understand the basics of minimax. i do have a doubt in using it for tic tac toe. at each stage max will choose the node with maximum value in its child. but how do we evaluate the leaf nodes? i cant guess any function for that.

shiv0013
Light Poster
27 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

Is the leaf node a final state? If so, then it has +verymuch if a win, -verymuch if a loss and (whatever you deem appropriate) if it a draw.

Look in the right column of this page, near the top. See all the related DaniWeb posts? Some of them may be quite useful.

griswolf
Veteran Poster
1,165 posts since Apr 2010
Reputation Points: 344
Solved Threads: 256
 

I did a tictactoe program that has a artificial intelligence for pc move. But I don't use known/common way. Just I did myself.

If you ask what I did. I 'll explain.

In tictactoe there are these states that are important for the game.

a "A" state.

X 2 X let's call this as " danger "
O 5 6
7 8 9

a "B" state. " " "two danger"
X 2 X
O 5 6
X 8 O


A- if a danger exist in a state the next player must move to 2 according to upper state.
B- if there are two danger at same time so the player will lose.

You must look for these states.

You must make the pc play on a virtual tictactoe table. and if the state "A" exist you must make the player play there(the space that left) and continue the look for these states.

and if state is "B" so, you should't play the "move" that brings you this state. and the user can trap you with a A state .The user make a "danger" and you must play to the space. Then he can make a "B" state than.

I don't know how I tell you my algorithm. But this can help you to make a function you want.

Whatever I think I have full source code that I found it on intenret for tictactoe that is using minimax algorithm If I can find I will add it here.

fenerista
Light Poster
42 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You