# Thread: Help - maxLength method for 2D Array

1. Member
Join Date
Sep 2009
Posts
4
Rep Power
0

## Help - maxLength method for 2D Array

Hey guys I have been working on this game for over a week now and have managed to get everything working except the maxLength(int row, int col); method. this is a Gomoku game and what the method has to do is:

SOLVED
Last edited by Hardo; 09-15-2009 at 01:13 AM.

2. Senior Member
Join Date
Aug 2009
Posts
2,388
Rep Power
7
You didn't explain what the problem with the method is.
Do you get a compilation error, run time exception, wrong results?

3. Member
Join Date
Sep 2009
Posts
4
Rep Power
0
it compiles and runs but when i put in say the position 12, 9 it sees that there is nothing there so it returns a line length of 0, that works. but if there is say a B (black) toke at 12, 9 the method maxLength is supposed to look in each vertical, horizontal and both diagonals to find out of those directions what is the length of the longest line of B (black) tokens. instead atm it only returns a value of 1 if there is a value at the co-ords eventhough there is a B(black) token next to it making it a line of 2 tokens so it should return 2. but its not.

4. Member
Join Date
Sep 2009
Posts
4
Rep Power
0
Now i have that working but what isnt working is the line check that does the diagonal that goes south west and north east of co-ords. Now i think i have to set rinc and cinc to 0 and the opposite is -0 . this isnt working its not returning the correct value. what value can i set rinc and cinc to check in those directions?? or is there another way?

SOLVED
Last edited by Hardo; 09-15-2009 at 01:13 AM.

5. Senior Member
Join Date
Aug 2009
Posts
2,388
Rep Power
7
You are going to have to think out and write down your algorithm and then verify it before you even get close to the compiler.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•