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

Thread: HELP ME PLEASE

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default HELP ME PLEASE

    4. Fortify!

    Write a program to simulate a simplified board game called Fortify. The simplified game of Fortify is a two-player game played on a 10 x 10 game board, which is broken into 4 regions each of size 5 x 5. The objective of the game is to control as many as of the regions as possible to win through fortification. The winner is the player who has control over the most number of regions. This modified version of Fortify will be simulated using two computer players.

    No user input is required for this game. The 10 x 10 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:
    • “Infantry” piece – represents one infantry
    • “Artillery” piece – represents one artillery
    • “Cavalry” piece – represents one cavalry

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

    Type of Piece Quantity
    Infantry 40
    Artillery 10
    Cavalry 15

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

    • At each turn, the current state of the game board should be displayed, clearly identifying the 4 regions;
    • 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 for placing an item on the game board are as follows:
    o If the dice value is between 1 and 2, inclusive, and there are infantry pieces available, place it at [x][y] position on the game board;
    o If the dice value is 3 and 4, inclusive, and there are “artillery” pieces available, place an “artillery” piece at [x][y] position on the game board
    o If the dice value is 5 or 6 and there are “cavalry” pieces available, place a “cavalry” piece at [x][y] position on the game board
    • During each placing of an item any of the following may happen and the game board should be updated:

    Scenario Outcome
    The current piece may be adjacent to at least one infantry piece The current piece is removed and returned to the stock
    The current piece may be adjacent to at least two artillery pieces The current piece is removed and returned to the stock

    • 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 10 x 10 2D game board can contain any of the following:
    • E → empty space
    • I → infantry
    • A → artillery
    • C → cavalry

    Your program also needs to track which computer player owns which piece on the game board by region. Display the winner when the game ends.

    The game ends when the following condition is satisfied:
    • When there are no more remaining pieces to place on the game board OR
    • After a cumulative of 80 turns.

    At this point, your program should go through the game board and identify how many regions each player has fortified based on any of the following rules:

    How to win a Region ( in order of priority)
    The sum of the infantry and cavalry pieces occupies more than 50% of that region
    One player has 25% more of the artillery pieces in comparison to the other player
    One player has a row of 5 artillery in a region

    • The program should print a “Tie” if both computer players end up with the same number of regions fortified.

    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.
    iii. computeWinner, which will take as input the 2D array and display the winner.

    Your program also needs to track and print the following:
    • The total number of pieces belonging to each computer player by region
    • The total number of infantry pieces belonging to each computer player by region
    • The total number of artillery pieces belonging to each computer player by region
    • The total number of cavalry pieces belonging to each computer player by region

  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: HELP ME PLEASE

    Thread closed as homework dump with no effort.