Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 12 of 12

Thread: Line of Action Game Help plz

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Line of Action Game Help plz

    Lines of Action is a two player strategy board game where each player aims to connect all his/her checkers
    into one group. The board is a standard 88 chessboard. The game starts with each player having 12
    checkers. The black checkers are placed horizontally on the two rows along the top and bottom of the
    board, while the white checkers are placed vertically on the two columns at the left and right of the
    board. The 2 players alternate at moving their checkers in the three lines of action: vertical, horizontal
    and diagonal. The first player to get all her/his checkers into a single connected group wins.
    rules of game
    1. Players alternate turns. The white moves rst.
    2. Checkers move in the 3 lines of action: horizontally, vertically, or diagonally.
    3. The number of squares moved by a checker must be exaclty the same as the number of checkers
    (belonging to both players) in that line of action.
    4. A checker belonging to a player may jump over other checkers belonging to that player, but it may
    not jump over checkers belonging to the opponent.
    5. A checker captures an opponent's checker by landing on it.
    **game over
    The first player to connect all her/his checkers into a single group is the winner.
    2. If one player is reduced by captures to a single piece, that is a win for the captured player.
    3. If a move lead to both players being winners, the player who made that move is the winner.

    --- Update ---

    i have problem with the method GameOver i used recrusion method but it doesn't work on the tests
    recrusion method to check the 8 directions around the given point on the 2D array
    any idea

    --- Update ---

    Norm can you help me


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Line of Action Game Help plz

    it doesn't work
    Please explain what happens and what the problem is.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Line of Action Game Help plz

    Please edit the code and format it so that nested statements are indented 3-4 spaces. Statements should NOT all start in the first column.

    Make a small complete program that compiles and executes for testing. Hardcode whatever arrays,etc are needed for testing the method and call the method for testing.

    The posted code is useless for testing. There needs to be code that compiles and executes.
    If you don't understand my answer, don't ignore it, ask a question.

  4. #4
    Junior Member
    Join Date
    Mar 2013
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Line of Action Game Help plz

    in method isGameOver i made a loop on boolean array to catch the first piece count around region in 8 direction . can you tell me another idea to count the around region to count the connected checker

    --- Update ---

    ??

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Line of Action Game Help plz

    Is the code supposed to check the 8 squares that surround a square in the middle of a 2 dim array?
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Junior Member
    Join Date
    Mar 2013
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Line of Action Game Help plz

    No it supposed to check the 8 squares everywhere in 2D array not only in the middle

    --- Update ---

    ??

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Line of Action Game Help plz

    If the square is at an edge, will there be 8 squares to check?
    If you don't understand my answer, don't ignore it, ask a question.

  8. #8
    Junior Member
    Join Date
    Mar 2013
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Line of Action Game Help plz

    no will be 4 squares but the game Board is constant 8*8 my problem with the recursion method can you check it . i made another boolean array to check if this piece is counted turn it into true. ??!!

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Line of Action Game Help plz

    problem with the recursion method
    Is there a small, complete program you can post that can be compiled and executed for testing?

    When you post code, be sure to properly format it. The code in post#3 needs formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  10. #10
    Junior Member
    Join Date
    Mar 2013
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Line of Action Game Help plz

    sorry how can i post my code formatting
    and what code can i posted the testing or my code

  11. #11
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Line of Action Game Help plz

    Formatting conventions: Code Conventions for the Java Programming Language: Contents

    Look at other threads with code on this forum. Many have code that is properly formatted.

    Here's a sample:
       public ExtractBoards(String inFile, String folder, String pfx) {
          if(inFile.endsWith(HTML_Ext)) {
             readHtmlFile(inFile);
     
          }else if(inFile.endsWith(LIN_Ext)){
             readLinFile(inFile);
     
          }else {
             JOptionPane.showMessageDialog(null, "Unknown file type: "+inFile, 
                                               "Error", JOptionPane.ERROR_MESSAGE);	
    	  return;
          }
     
          if(boards.size() < 1) {
             System.out.println("No boards found");
             return;     //  exit now
          }
     
          // Show some
          for(int i=0; i < Math.min(boards.size(),MaxBoards); i++) {
             System.out.println(boards.get(i));
          }


    what code can i posted the testing or my code
    Make a class with the minimum variable definitions needed to execute the method. Call the method to be tested from the testing class's constructor.
    If you don't understand my answer, don't ignore it, ask a question.

  12. #12
    Junior Member
    Join Date
    Mar 2013
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Line of Action Game Help plz

    can you tell me a another way to check the winner with connected checkers and i make in the move method if your destination is the opponent decrement the number of checkers of the opponent

Similar Threads

  1. Replies: 10
    Last Post: September 16th, 2011, 07:49 PM
  2. Reading a file line by line using the Scanner class
    By JavaPF in forum File Input/Output Tutorials
    Replies: 0
    Last Post: April 17th, 2009, 07:34 AM
  3. Reading a file line by line using the Scanner class
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 0
    Last Post: April 17th, 2009, 07:34 AM
  4. How to Read a file line by line using BufferedReader?
    By JavaPF in forum File Input/Output Tutorials
    Replies: 0
    Last Post: May 19th, 2008, 06:32 AM
  5. How to Read a file line by line using BufferedReader?
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 0
    Last Post: May 19th, 2008, 06:32 AM