What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Need Help In Programming

Need Help In Programming
Author: Message:
albert
Veteran Member
*****

Avatar

Posts: 2247
Reputation: 42
– / Male / Flag
Joined: Feb 2005
O.P. Need Help In Programming
Hey.. I'm currently trying to code an Othello (aka reversi) game in Java, and I have a problem with my algorithm.

Now you don't need to know Java in order to be able to help, simply programming.

What I'm trying to do is to find all the possibilities and put them in an array afterwards.

I made a paint picture that shows all the possibilities in a white spot.

My current algorithm works this way.
* = black
+ = white
` = nothing

code:
counter = 1 ;
possibilitesCounter = 0 ;

for ( counterRows = 0 ; counterRows < 8 ; counterRows ++ )
    for (counterCols = 0 ; counterCols < 8 ; counterCols ++ )
    {
       case = array [counterRow][counterCols];
       if ( case.equals ('*') )
        {
            case 2 = array[counterRow][counterCols-1] ;
            while ( case2.equals('+'))
                {
                   counter++ ;
                   case1 = case2 ;
                   case2 = array[counterRow][counterCols-counter]
                 }
             if ( case2.equals('`') )
                {
                array[possibilitesCounter] = counterRow + "" + counterCols ;
                possibilitesCounter ++ ;
                }
        }
    }


Of course that code only applies for the checking if there's anything on the left. I have to do the same for right, up, down and 4 diagonals.

I was wondering if there was a mor efficient and shorter way to do it.
Thanks for the help everyone.

Here is a pic that shows all the possible moves ( you can see the possibilites in white )

[Image: attachment.php?pid=796479]

.jpg File Attachment: help.JPG (46.25 KB)
This file has been downloaded 247 time(s).

This post was edited on 03-07-2007 at 08:15 PM by albert.
03-07-2007 08:15 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Need Help In Programming - by albert on 03-07-2007 at 08:15 PM
RE: Need Help In Programming - by CookieRevised on 03-07-2007 at 08:38 PM
RE: Need Help In Programming - by foaly on 03-07-2007 at 08:47 PM
RE: Need Help In Programming - by CookieRevised on 03-07-2007 at 08:54 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On