File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Game Development and the fly likes Plot4(Difficultiyes in legal move generation). Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Game Development
Bookmark "Plot4(Difficultiyes in legal move generation)." Watch "Plot4(Difficultiyes in legal move generation)." New topic
Author

Plot4(Difficultiyes in legal move generation).

Ashish Schottky
Ranch Hand

Joined: Dec 29, 2009
Posts: 93
Plot4 also known as Captains Mistress and connect four.
I am facing difficulties in legal move generation.
I have googled, put on other help forums but the explanations were not so easy to implement.
Hope I get help here.
I have gone through the discussion on developing the tic-tac-toe(Though his board representation can only be used for square boards.) in the same forum, named 'Turn Based Strategy Games'.
(please refer to this discussion as there is lot info which is not practicable to put here.)
This helped me a lot while I made the GUI.
I am now faced with the task of making a set of legal move generation.
this would be the array which will be then passed to the negamax().
I have almost used the code from Fred Hamilton. but have few questions.
Is programing games in strings a good idea as compared to bitmaps and normal integer arrays?

Here I have a pseudo code.
int count=0;
for(i=0;i<posn.length;i++)
if there is a legal move, then list[count++]=new move(i,0)
but then all the empty spaces are not legal moves.

So what should be done here?

Now let us come to the evaluation function.
Take a look at the following code .


When I wrote this evaluation, the game play became very slow at depth of 4. It took approx 60 seconds in critical positions.
Does the array representation make it faster?

if yes, then i will convert this into 2d-char array and use the two for loops to compare.

The eval() using array is not a big problem but the legal move generation is .


Ashish Schottky
Ranch Hand

Joined: Dec 29, 2009
Posts: 93
Here is what I came up with but it is not correct. See the code.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Plot4(Difficultiyes in legal move generation).