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 231 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
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Need Help In Programming
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).

This post was edited on 03-07-2007 at 09:11 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
03-07-2007 08:38 PM
Profile PM Find Quote Report
foaly
Senior Member
****

Avatar

Posts: 718
Reputation: 20
38 / Male / Flag
Joined: Jul 2006
RE: Need Help In Programming
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?

This post was edited on 03-07-2007 at 08:48 PM by foaly.
03-07-2007 08:47 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Need Help In Programming
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

;)

This post was edited on 03-07-2007 at 11:55 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
03-07-2007 08:54 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


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