Java - Push and Pop Game (deadline 24/4 15:00 HKT UTC+8h)
- or -
Post a project like this$40
- Posted:
- Proposals: 2
- Remote
- #754312
- Expired
Description
Experience Level: Intermediate
Push and Pop Game
In this assignment, you are required to write a game called "Push and Pop" which is a single player game with a 3 x 3 game board (in basic version). The game board consists of 3 x 3 stacks of size 5, which are numbered as follow:
0 1 2
3 4 5
6 7 8
Game Play
During the game, only the top element of the stack is shown to the player. If the stack is empty, '-' is shown. For ease of playing, the size of the stack will be displayed too. The expected output of the game should look somewhat like this:
D:\PPG>java PushPopGame q1.txt
--------------------------------------
QUESTION: [0 1 2] SCORE: 0
--------------------------------------
Game Size
---- ----
- - - | 0 0 0
- - - | 0 0 0
- - - | 0 0 0
Please enter the position (-1 to quit):
As you can see from the screen capture above, a question preview of size 3 is provided. Player is asked to push the first number in the question preview to one of nine stacks (if it is not full) by the numbering mentioned in the first paragraph.
Question List
At the start of each game, a question list is read from a file (e.g. ql.txt) which contains a set of number (range from 0 - 9) in space delimited format. The list repeats from start again if all numbers are placed to the board. A question preview of size 3 is provided which perform like a sliding window after each move. For example
Question List
0 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1
Game preview when the game starts
[0 1 2] 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1
After player placed 0 to the game board, game preview slides to the next element
0 [1 2 3] 4 5 6 7 8 9 8 7 6 5 4 3 2 1
Your Java program should be able to handle the inputs for the question list file (e.g. q1.txt) through command line input as follows:
java PushPopGame ql.txt
Scoring
Player's score is starting from 0 and increases when any of the following patterns is found horizontal, vertical or diagonal row
1. same number (+10)
2. sequential number in either increasing or decreasing manner (+30)
Note that, multiple rows may take into account in one single move, as see in the example below
5 5 5
- 4 7
2 2 3
If 5 is placed at position 0, 10 marks is obtained by pattern (5,5,5) found in position [0,1,2] and 30 marks is obtained by pattern (5,4,3) found in position [0,4,8], therefore 40 marks will be added to total, and involved elements will be popped. And the new state of the game board is formed, for example:
- 9 -
- - 7
2 2 2
The new state of the game board will be considered again as combo. For example, a 10 marks pattern is found in position [6, 7, 8] and the score obtained in the new state will be multiplied by the combo count. In this case, 10 x 2 = 20 and added to total score, in other words 40 + 20 marks in this single push. The process repeat until the state become stable, i.e. no pattern is found and no element is needed to be popped.
Game Over
The game over when all stacks are full.
Quit Game
The game will quit when user input the position -1
Advanced Version
Support different size (3x3, 4x4, 5x5, 6x6)
Support undo
In this assignment, you are required to write a game called "Push and Pop" which is a single player game with a 3 x 3 game board (in basic version). The game board consists of 3 x 3 stacks of size 5, which are numbered as follow:
0 1 2
3 4 5
6 7 8
Game Play
During the game, only the top element of the stack is shown to the player. If the stack is empty, '-' is shown. For ease of playing, the size of the stack will be displayed too. The expected output of the game should look somewhat like this:
D:\PPG>java PushPopGame q1.txt
--------------------------------------
QUESTION: [0 1 2] SCORE: 0
--------------------------------------
Game Size
---- ----
- - - | 0 0 0
- - - | 0 0 0
- - - | 0 0 0
Please enter the position (-1 to quit):
As you can see from the screen capture above, a question preview of size 3 is provided. Player is asked to push the first number in the question preview to one of nine stacks (if it is not full) by the numbering mentioned in the first paragraph.
Question List
At the start of each game, a question list is read from a file (e.g. ql.txt) which contains a set of number (range from 0 - 9) in space delimited format. The list repeats from start again if all numbers are placed to the board. A question preview of size 3 is provided which perform like a sliding window after each move. For example
Question List
0 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1
Game preview when the game starts
[0 1 2] 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1
After player placed 0 to the game board, game preview slides to the next element
0 [1 2 3] 4 5 6 7 8 9 8 7 6 5 4 3 2 1
Your Java program should be able to handle the inputs for the question list file (e.g. q1.txt) through command line input as follows:
java PushPopGame ql.txt
Scoring
Player's score is starting from 0 and increases when any of the following patterns is found horizontal, vertical or diagonal row
1. same number (+10)
2. sequential number in either increasing or decreasing manner (+30)
Note that, multiple rows may take into account in one single move, as see in the example below
5 5 5
- 4 7
2 2 3
If 5 is placed at position 0, 10 marks is obtained by pattern (5,5,5) found in position [0,1,2] and 30 marks is obtained by pattern (5,4,3) found in position [0,4,8], therefore 40 marks will be added to total, and involved elements will be popped. And the new state of the game board is formed, for example:
- 9 -
- - 7
2 2 2
The new state of the game board will be considered again as combo. For example, a 10 marks pattern is found in position [6, 7, 8] and the score obtained in the new state will be multiplied by the combo count. In this case, 10 x 2 = 20 and added to total score, in other words 40 + 20 marks in this single push. The process repeat until the state become stable, i.e. no pattern is found and no element is needed to be popped.
Game Over
The game over when all stacks are full.
Quit Game
The game will quit when user input the position -1
Advanced Version
Support different size (3x3, 4x4, 5x5, 6x6)
Support undo
Ho K.
0% (0)Projects Completed
-
Freelancers worked with
-
Projects awarded
0%
Last project
15 Dec 2024
Hong Kong
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies