Page 2 of 2 FirstFirst 12
Results 21 to 31 of 31
  1. #21
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,318
    Rep Power
    25

    Default Re: I really need your help with my Chess game @school

    Take what you have now and try to write code to find the valid squares to move to.
    Put those in a list and print out the list

  2. #22
    znerken is offline Member
    Join Date
    Dec 2011
    Posts
    19
    Rep Power
    0

    Default Re: I really need your help with my Chess game @school

    Quote Originally Posted by Norm View Post
    Take what you have now and try to write code to find the valid squares to move to.
    Put those in a list and print out the list

    Do I have to use Chain of responsibility back to square or how do I find those valid squares?

  3. #23
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,318
    Rep Power
    25

    Default Re: I really need your help with my Chess game @school

    how do I find those valid squares?
    Do you play chess? There are rules for how each piece moves. You need to look at the chess rules to determine what moves are valid.

    Do I have to use Chain of responsibility back to square
    I guess you either look at the code or you ask the person who wrote the code.

  4. #24
    znerken is offline Member
    Join Date
    Dec 2011
    Posts
    19
    Rep Power
    0

    Default Re: I really need your help with my Chess game @school

    Sorry to be asking so nooby questions..but our teacher teaches us in a strange way..Ofcourse I wrote the code.

    I dont want to program rules for the whole game, its just the highlight function I need

  5. #25
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,318
    Rep Power
    25

    Default Re: I really need your help with my Chess game @school

    You need the rules for the piece(s) you want to show the possible moves for.

  6. #26
    znerken is offline Member
    Join Date
    Dec 2011
    Posts
    19
    Rep Power
    0

    Default Re: I really need your help with my Chess game @school

    Ok so I have tried abit but need more help. When I click on a piece, I get it to mark the field the piece is placed on, now I need to get it to mark the field colon +1.

    I need a method that finds the field infront of me, in short words

  7. #27
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,318
    Rep Power
    25

    Default Re: I really need your help with my Chess game @school

    When I click on a piece, I get it to mark the field the piece is placed on
    That must mean you know where the piece is located and what type of piece it is.
    Given those two pieces of information, you should be able to compute what the legal moves are.

  8. #28
    znerken is offline Member
    Join Date
    Dec 2011
    Posts
    19
    Rep Power
    0

    Default Re: I really need your help with my Chess game @school

    I do not need to make rules, I only need the field infront of the pawn to lighten up

  9. #29
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,318
    Rep Power
    25

    Default Re: I really need your help with my Chess game @school

    First you need to find the pawn's location.
    Are the pieces' locations given by row and column?
    Do the row numbers start at 0 or at 1?
    Which is the first row? The one at the bottom or the one at the top of the board?
    Answer the same questions for the columns.

    Once you have the location of the piece on the 64 square board and know which piece it is and which side of the board is the starting side for that piece then you can compute the piece's legal moves.

    Define all of the above and then you will be able to compute the legal moves for a piece.

    To visualize this problem, pick a pawn to talk about. Write down its current location and write down the locations it can move to.

  10. #30
    znerken is offline Member
    Join Date
    Dec 2011
    Posts
    19
    Rep Power
    0

    Default Re: I really need your help with my Chess game @school

    First you need to find the pawn's location.
    Are the pieces' locations given by row and column? Yes they are, they are placed on with a double array, but they are placed on top of Square.

    here is the code:

    public SquareMatrix() {
    setLayout(new GridLayout(8, 0));
    for (int i = 0; i < 64; i++)
    add(new Square(i));

    }

    Do the row numbers start at 0 or at 1?
    Which is the first row? The one at the bottom or the one at the top of the board?
    The one at top I guess
    Answer the same questions for the columns.

    Once you have the location of the piece on the 64 square board and know which piece it is and which side of the board is the starting side for that piece then you can compute the piece's legal moves.

    Define all of the above and then you will be able to compute the legal moves for a piece.

    To visualize this problem, pick a pawn to talk about. Write down its current location and write down the locations it can move to

    But look at my code, I have a mouseclick, on that mouseclick i launch a method that paints a square..But I want that method to be painting for example the square in front...


    This is driving me nuts !!!!!

  11. #31
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,318
    Rep Power
    25

    Default Re: I really need your help with my Chess game @school

    You need an algorithm that given a square (0-63) it will give you the row and column for that square.
    Then when you have the row and column for that square and the information about the piece that is on that square you will be able to compute the legal moves for that piece from that square.
    For example: Say these numbers are some of the squares:
    Java Code:
     16 17 18 19 20 21 22  23
      8  9  10 11 12 13 14 15 
      0  1   2  3  4   5   6  7
    if the pawn is on row 2, column 2 (square 9) then one of its legal moves are to row 3 and column2 (square 17)

Page 2 of 2 FirstFirst 12

Similar Threads

  1. chess game! plz help!
    By mofaghih in forum AWT / Swing
    Replies: 2
    Last Post: 07-11-2011, 07:46 AM
  2. Chess Game - Movement
    By danborgir in forum Advanced Java
    Replies: 1
    Last Post: 03-14-2011, 11:45 AM
  3. chess game
    By michail in forum New To Java
    Replies: 13
    Last Post: 01-12-2010, 07:24 AM
  4. Chess game
    By michail in forum New To Java
    Replies: 4
    Last Post: 12-23-2009, 06:51 PM
  5. New Chess-Like game
    By jSarK0Y in forum Reviews / Advertising
    Replies: 3
    Last Post: 06-10-2009, 03:28 AM

Posting Permissions

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