Shoutbox

Need Help In Programming - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Need Help In Programming (/showthread.php?tid=72423)

Need Help In Programming by albert on 03-07-2007 at 08:15 PM

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]
RE: Need Help In Programming by CookieRevised on 03-07-2007 at 08:38 PM

http://www.radagast.se/othello/howto.html
http://www.radagast.se/othello/zebra.html
http://www.site-constructor.com/othello/
http://samsoft.org.uk/reversi/strategy.htm

^^ best I've found to explain and explore the algorithms involved (and efficiency).


RE: Need Help In Programming by foaly on 03-07-2007 at 08:47 PM

quote:
Originally posted by alby
Now you don't need to know Java in order to be able to help, simply programming.
Well there are different kind off programming languages...
In prolog the idea would be completely different...
btw. reversi/othello is that the same as go?

RE: Need Help In Programming by CookieRevised on 03-07-2007 at 08:54 PM

quote:
Originally posted by foaly
Well there are different kind off programming languages...
I think it doesn't matter though, since he is asking for logical routines; a methodology to program effeciently the logic behind it. This could be done with even pseudocode or whatever. Aka: how do you make it efficient, not what is the syntax of the code to do it.

quote:
Originally posted by foaly
btw. reversi/othello is that the same as go?
it's similar, but not quite the same... all have their own twist in the rules

;)