# Connect 4 Minimax

• 07-05-2007
appleGuy
Connect 4 Minimax
Hi,

Trying to understand the minimax algorithm for a connect 4 game:
http://ai-depot.com/articles/minimax-explained/

Would you create a tree for each of the columns on the connect 4 board. so a board with 4 columns will have 4 trees created?

If so, the root will be the selected column?...yes? the second level will be the possible opponent choices...yes? and so on?

Thanks For your help, im pretty new to all this

Cheers
-Alex
• 07-05-2007
You will have one tree. The values in the tree wil be a rating of the board. For example, if a particular move will make you lose then the value would be zero. If the move will make you win then the value would be the highest possible. The minimax algorithm picks the route that the computer wants to take by picking trying the moves that will yield the highest state for the computer. It then assumes that the human will pick the move that minimizes the computer's state.
• 07-06-2007
appleGuy
Hi,

So for simplicity its a computer vs human match. Obviously the algorithm is for a computer move decision. So when the computer has to play its move, is the root of the tree (MAX) the humans last move (a thus current game depth) ?

-Alex
• 07-06-2007
The root is the current state. The branches coming off of it are possible moves and the numbers that you see are the rating of the states that result from each move.
• 07-06-2007
appleGuy
Quote:

The root is the current state. The branches coming off of it are possible moves and the numbers that you see are the rating of the states that result from each move.

So in connect 4, each node including the root is an 2D ARRAY ?

Also its not just the computers moves for every level of the tree..its also the humans possible moves.

so for a 7 column grid. there is a root node then 7 nodes coming of??.. are these the computers possible move or the humans possible moves?

Cheers
-Alex
• 07-06-2007
The root is a single number. Pretend you are rating the board on a scale from 0 to 10 based on how sure you are that you will win. That rating for the current board is the root. All the following numbers are ratings.
• 02-16-2011
std10093
Hi there...The only language i know is C .Am 18 years old so now i started to learn.I have to make minimax function for othello(reversi). I have understand the way it works,but i can not make it.Code many times is more helpful than words :-)
• 02-17-2011
iMalc