Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Java in General and the fly likes Help in connect four Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Help in connect four" Watch "Help in connect four" New topic
Author

Help in connect four

Kabir Shah
Ranch Hand

Joined: Aug 04, 2009
Posts: 125
I have already posted few messages in this forum, should mention that members here are quiet helpful in nature(though my problem was not solved, at least it was discussed at a length).

I have written a connect four program but it plays random unless it gets to see 4 in row for the depth it is searching. To make it better I wanted to apply alpha-beta pruning but I was not successful in doing so.Hence I tried to write a method which will determine connect in 3 for itself as well as for the opponent.

As I wrote this code and compiled it, It only looks for connect in 3 rather than blocking or going for win. It doesnot give priority to connect 4 as to connect 3 even though I have given higher value for connect four.

This is my code for checking the connect 3:.



And here is the minmax code:


Please help.
-Thank you.
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Hi Gurudas, sorry I did not get back to you. I looked at your code a few times, and the descriptions, but was unable to unlock the secrets. It's hard enough for me to figure out my own recursions.

I am interested in game programming, at some point I will probably take a stab at writing a connect 4, and I'll share the results with you.

In the meantime, you may benefit from this website, which has an entire page devoted to programming a recursive connect4 algorithm.

Let us know if it helps.

http://erwnerve.tripod.com/prog/recursion/

p.s. the connect 4 chapter is followe by a chapter on alphabeta pruning
Kabir Shah
Ranch Hand

Joined: Aug 04, 2009
Posts: 125
@Fred
I got the minmax algorithm from there only.. that was my first step( later on I found nega max).
But alpha beta pruning was of no help.
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
ok well good luck. maybe give the sun forums a try, they have a special forum on algorithms. If you don't get a solution here that is.

also there is Google groups, they have all sorts of forums on programming. I've had success with recursion topics in this forum, not sure if they will debug java code though.

http://groups.google.ca/group/comp.programming/topics?hl=en&lnk
 
Consider Paul's rocket mass heater.
 
subject: Help in connect four
 
Similar Threads
Converting a two dimensional int array into a byte array
Alpha beta pruning with negamax
array out of bounds
Finding the color of a pixel
How to add gutter space after each column in JTextpane?