This week's book giveaway is in the Cloud/Virtualizaton forum.We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!

# Connect-four

Kabir Shah
Ranch Hand
Posts: 125

This is the solution for your test problem.
I was happy with the evals that it gave me.
it sees a win in more than one way.
but it returns 1 for square 6(0-8 notation) on first search, I cannot find how is this winning blocking straight at 2.
rest all solution is correct. at depth of 2, it return 0 for all squares on first move.
Also after this I played many games against online AI computer programs and it resulted either win or draw, but no loss.

Mich Robinson
Ranch Hand
Posts: 260
1
So you're saying the code is correct now???

You make your debug hard to read because your positions go from 0-8 rather than the expected 1-9. The format of the output means it has to be formatted by hand to print it. Worst of all though you don't appear to be even looking at the debug output and attempting to understand what it means ie in the first example it played initially in the corner and these were the score returned for a 6 ply search for the 2nd move by the 2nd player.

# Player2
# Eval= -1 played at 1
# Eval= -1 played at 2
# Eval= -1 played at 3
# Eval= 0 played at 4
# Eval= 0 played at 5
# Eval= 0 played at 6
# Eval= 0 played at 7
# Eval= 0 played at 8

However all moves other than in the centre result in a loss within 6 ply ie 0,7,4,8,6,3,2 or perhaps 0,6,8,4,2,1,5 etc etc. Each of these wins is forced yet your program returns a draw.

Mike

012
345
678

Kabir Shah
Ranch Hand
Posts: 125
@Mich

I guess one small change that caused huge change in evals.
was using beta cutoff as
alpha>=beta
You make your debug hard to read because your positions go from 0-8 rather than the expected 1-9.

Well now you can see it from 1-9.
Worst of all though you don't appear to be even looking at the debug output and attempting to understand what it means ie in the first example it played initially in the corner and these were the score returned for a 6 ply search for the 2nd move by the 2nd player.

# Player2
# Eval= -1 played at 1
# Eval= -1 played at 2
# Eval= -1 played at 3
# Eval= 0 played at 4
# Eval= 0 played at 5
# Eval= 0 played at 6
# Eval= 0 played at 7
# Eval= 0 played at 8

However all moves other than in the centre result in a loss within 6 ply ie 0,7,4,8,6,3,2 or perhaps 0,6,8,4,2,1,5 etc etc. Each of these wins is forced yet your program returns a draw

This was due to the way I implemented beta cutoff . I referred the code atwww.hamedahmadi.com
I put there alpha>=beta(On site, it said that it will speed up the search a bit, so I thought the evals of -1 changed to 0 was part of the algorithm) Now I changed it to alpha>beta and its giving proper evaluations.

For your test case.

Here is the complete game set played at 6plys.

Board format:
123
456
789