• Post Reply Bookmark Topic Watch Topic
  • New Topic
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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Help in connect four

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 686
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@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
Posts: 686
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Happily living in the valley of the dried frogs with a few tiny ads.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic