Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Bear Bibeault
• Ron McLeod
• Jeanne Boyarsky
• Paul Clapham
Sheriffs:
• Tim Cooke
• Liutauras Vilda
• Junilu Lacar
Saloon Keepers:
• Tim Moores
• Stephan van Hulst
• Tim Holloway
• fred rosenberger
• salvin francis
Bartenders:
• Piet Souris
• Frits Walraven
• Carey Brown

# Connect-four

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.

Ranch Hand
Posts: 275
2
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.