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 7 of 7

Thread: Extremely challenging and lengthy java question..

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    7
    My Mood
    Amused
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Extremely challenging and lengthy java question..

    Write a program to simulate a simplified board game called Settlers. Settlers is a two player game played on a 10x10 game board, where the objective is to create as many settlements as possible in the land to win. The winner is the player who has the highest scores in terms of their settlements. This modified version of Settlers will be simulated using two computer players.

    No user input is required for this game. The 10x10 board will be simulated using a 10 x 10 2D array. At the start, the game must randomly decide which computer player (1 or 2) will go first. This game will include the following pieces:
    • “Settler” piece – represents a single settler in the land
    • “Castle” piece – represents a settlement
    • “Tower” piece – represents a tower to protect the settlement
    • “Mine” piece – represents a mine for the settlers to do mining

    The following are the initial number of pieces for the entire game:

    Piece Quantity
    Settler 20
    Castle 5
    Tower 10
    Mine 10

    Then, the program should simulate the game play as follows:

    • At each turn, the current state of the game board should be displayed
    • At each turn, each computer player rolls a dice. Then, the program must also generate two random numbers that represent the x and y position in the 2D array.
    • The rules to follow for placing an item on the game board is as follows:
    o If the dice value is between 1 and 3, inclusive, and there are “settler” pieces available, place a “settler” piece at [x][y] position on the game board
    o If the dice value is 4 and there are “castle” pieces available, place a “castle” piece at [x][y] position on the game board
    o If the dice value is 5 and there are “tower” pieces available, place a “tower” piece at [x][y] position on the game board
    o If the dice value is 6 and there are “mine” pieces available, place a “mine” piece at [x][y] position on the game board
    • If the [x][y] position on the game board is occupied, the computer player skips its turn.

    Overall, each position (or slot) in the displayed 10x10 2D game board can contain any of the following:
    • E = empty space
    • S = settler
    • C = castle
    • T = tower
    • M = mine

    Your program also needs to track which computer player owns which piece on the game board.

    The game ends when the following condition is satisfied:
    • When there are no more remaining pieces to place on the game board. At this point, your program should go through the game board and add up the scores for each computer player according to the following table:

    Rule Number of points
    For every “settler” piece 1
    For every “castle” piece 5
    For every “tower” piece 3
    For every “mine” piece 3
    For every “settler” piece
    that is surrounded
    by a castle* 15 points for each surrounding castle
    For every “mine”
    piece that is adjacent
    (left or right only)
    to a “settler” piece 10 points for each adjacent mine

    *Surrounded means there is a piece on one of the 8 neighbouring positions around position [x][y] on the game board.

    In the computation of the scores you can assume that there will be double-counting for certain pieces based on the rules above.

    Your program must, at least, include the following methods/functions with the correct input parameters and output type:

    i. initializeGameBoard, which will take as input the player’s 2D array and assign empty slots containing E.
    ii. placeItem, which will take as input the 2D array and place an item onto the game board depending on the above stated rules.

    Your program also needs to track and print the following:
    • The total number of pieces dropped onto the game board by computer player 1
    • The total number of pieces dropped onto the game board by computer player 2

    Please help me with this.


  2. #2
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    609
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: Extremely challenging and lengthy java question..


  3. #3
    Junior Member
    Join Date
    Jul 2013
    Posts
    7
    My Mood
    Amused
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Extremely challenging and lengthy java question..

    Thanks for replying. I don't really know how to begin this question. Perhaps you can give me some tips?

  4. #4
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    609
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: Extremely challenging and lengthy java question..

    What do you think are those two links in my reply for?

  5. #5
    Junior Member
    Join Date
    Jul 2013
    Posts
    7
    My Mood
    Amused
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Extremely challenging and lengthy java question..

    Please give me some advice, anyone.

  6. #6
    Junior Member
    Join Date
    Jul 2013
    Posts
    7
    My Mood
    Amused
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Extremely challenging and lengthy java question..

    bump

  7. #7
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Extremely challenging and lengthy java question..

    Quote Originally Posted by phosphenes View Post
    bump
    Please do not bump your post on this forum, there is no need for it.
    Your question was answered in post #2, if you have a question remaining, then ask it, but if you have nothing to add then please do not bump

Similar Threads

  1. challenging question to find out complexity of the given code.
    By navxxxx in forum Java Theory & Questions
    Replies: 1
    Last Post: April 18th, 2013, 01:15 PM
  2. Challenging Problems..!
    By rahul12321 in forum Java Theory & Questions
    Replies: 4
    Last Post: August 27th, 2012, 02:55 PM
  3. Challenging Problems..!
    By rahul12321 in forum Java IDEs
    Replies: 2
    Last Post: August 27th, 2012, 02:45 PM
  4. Challenging Java Question: Test your Java skill by grouping these terms
    By karthickk3 in forum Java Theory & Questions
    Replies: 3
    Last Post: July 18th, 2012, 10:10 PM
  5. Update GUI before lengthy task
    By hafunui in forum Java Theory & Questions
    Replies: 2
    Last Post: October 17th, 2011, 11:24 AM