Results 1 to 6 of 6

Thread: Bishops moves

  1. #1
    michail is offline Member
    Join Date
    Dec 2009
    Posts
    31
    Rep Power
    0

    Default Bishops moves

    can someone tell me what this means?
    the drow-1, dcol-1, why -1

    Java Code:
     boolean goDiagonal(int srow, int scol, int drow, int dcol, boolean theEnd)
                {
                    if ((drow - srow) == (dcol - scol))//right and down
                    {
                        if (dcol - scol >0) //right down
                        { //move rightdown
                        return goDiagonal(srow, scol, drow-1, dcol-1,true); //if it meets one piece then stop
                        }
                        else
                            {//move rightup
                            return goDiagonal(srow, scol, drow +1, dcol +1,true);
                            }
    Last edited by michail; 01-28-2010 at 08:14 PM.
    For a world of science and reason

  2. #2
    Boxxybabee's Avatar
    Boxxybabee is offline Member
    Join Date
    Jan 2010
    Posts
    3
    Rep Power
    0

    Default

    I think its saying that if the int drow minus the int srow equals int dcol minus the int scol, then the the block of code inside the if statment.

  3. #3
    michail is offline Member
    Join Date
    Dec 2009
    Posts
    31
    Rep Power
    0

    Default

    sorry, let me rephrase that.
    i meant what the -1 in here means:
    Java Code:
    return goDiagonal(srow, scol, drow-1, dcol-1,true)
    For a world of science and reason

  4. #4
    sathishsengg is offline Member
    Join Date
    Jan 2010
    Posts
    10
    Rep Power
    0

    Default

    Is goDiagonal is the Recursive method...?

    can u post the code of goDiagonal().

  5. #5
    michail is offline Member
    Join Date
    Dec 2009
    Posts
    31
    Rep Power
    0

    Default

    I updated the code. That was the goDiagonal. What do you mean recursive? It.s for the bishop does that have anything to do with it?
    For a world of science and reason

  6. #6
    sathishsengg is offline Member
    Join Date
    Jan 2010
    Posts
    10
    Rep Power
    0

    Default

    The method calls itself is recursive method..

    Now you edited the code as recursive method,
    In your code, "goDiagonal" method calls "goDiagonal" itself is recursive....

    hard to explain the recursive method here, better refer it,

    what the code does is....
    code checking from scol to dcol and srow to drow, whether it meets any other piece or not.
    example : scol =1 srow=1 dcol=4 drow=4 (Source is (1,1) and Destination (4,4))


    then it Checks whether it meets any other piece from (2,2),(3,3) and finally (4,4) positions, "goDiagonal(srow, scol, drow-1, dcol-1,true)" recursive method doing this only...

Similar Threads

  1. Replies: 1
    Last Post: 02-16-2008, 11:22 PM

Posting Permissions

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