Blox Game Implementation

Verified

Added on  2019/09/18

|9
|2796
|529
Practical Assignment
AI Summary
This practical assignment focuses on the implementation of a Blox game. Students are tasked with completing the design and implementation of the game, building upon a previous assignment. The assignment requires the implementation of specific methods: `playGame`, `getMove`, and `movePlayer`, each with detailed specifications. The game rules, including player movement, block manipulation, winning and losing conditions, are clearly defined. A marking scheme outlines the assessment criteria, covering presentation, correctness, comments, and algorithm design. Bonus marks are available for additional features such as a zoom option, scaling difficulty, pushing multiple blocks, and creative additions. A sample output demonstrates the expected gameplay and user interaction. The assignment provides a comprehensive guide for students to develop and refine their programming skills in game development and algorithm design.
Document Page
Assignment #10 – Part 2
Problem Description
You are to complete the design and implementation of the Blox game. No
additional files will be provided, as your work will consist of completing the project you
began in the previous assignment.
You must now implement the rules as presented below (same as before), with a
demonstration of such rules provided in an extensive sample run of the program below
that. Your implementation must contain the methods declared below and function as
expected, but you may create additional methods at your discretion to further divide the
task at hand.
playGame: This method should take as parameters the map, player location, and
the number of blox in the current game. It should be called from within main instead of
printing the map, and should contain the core logic to control the play of a single map. If
your main method was developed as expected, it is likely that the only required change
to that method would be to replace the printMap call with a playGame call.
getMove: This method should be very similar to your getDifficulty method, except
that it prompts for movement within the game rather than the difficulty with which to set
up a new game. While it is important that it ensure that the input was a movement
action, it does not need to determine if that movement is currently allowed.
movePlayer: This method should take as parameters the map, player location,
and the move just entered by the player. It should return an integer constant
corresponding to the status of the move made by the player. There are three possible
meaningfully different outcomes from a given player move; 1) the move is blocked, 2)
the move is not blocked, or 3) the move is not blocked AND pushes a block into a hole.
The return value from this method should indicate which of these is the case, as the
playGame method will need this information. However, before returning that value, the
method must determine which of them is the case and update the map/player location as
appropriate.
Game Rules
ï‚· The player is represented by a 'P'. The player can interact with the game by
moving in one of four directions; up, down, left, and right.
ï‚· The blox are represented by '*' and the holes by 'O'. The goal of the game is to
push the blox around until each block has filled one of the available holes. The
player pushes blox by standing beside them and moving towards them. If the far
side of the block is clear (or a hole), both the player and the block will move.
ï‚· If the player pushes one of the blox into a hole, both the block and the hole
disappear (the block filled the hole).
ï‚· The map is surrounded by a border which is impassable to both the player and
blox.
ï‚· The player wins the game once every block has been pushed into a hole.
ï‚· The player loses the game if they quit or walk into a hole that has not been filled.
1
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Marking Scheme
[2 marks] Presentation/Style: Organization, readability, descriptive identifiers,
meaningful constants, indentation, and bracket placement.
[15 marks] Correctness: Program works without bugs. Implementation of all
assigned methods. Submission implements game rules as explained above.
[2 marks] Comments: Header and internal.
[1 mark] Algorithm: Provide an algorithm for the movePlayer method, and any
method called by it. You may want to write this first to assist with
developing your program.
Bonus Marks
All of the following must be implemented efficiently in order to qualify for marks,
but can be completely omitted from your submission at no penalty.
[5 marks] Part 1 completed correctly and on time.
[2 marks] Zoom option: Add an additional movement option to the player that scales
the size of everything printed by the map, including the player, empty spaces,
and the border.
[3 marks] Scaling difficulty: Implement a numeric difficulty setting that ranges from 1
upwards (decide on a large range that is useful to you). Each time the player
completes a game increment the difficulty of the next game by 1, instead of
prompting for a new difficulty. This should actually impact gameplay in a
non-trivial manner (don't just use it directly as the size and number of blox).
[3 marks] Push multiple blocks: Allow the player to push multiple blox arranged in
series as long as the last block in the series has room to move.
[2 marks] Creative additions: Come up with something interesting of your own
devising and be sure to document it so that your marker is aware of it. No
promises, but maybe it will be worth some extra credit.
Sample Output
This should explain the game...
Please select a difficulty - [E]ASY, [M]EDIUM, [H]ARD, or [Q]UIT: e
XXXXXXX
X X
X O * X
X P X
X X
XXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): d
XXXXXXX
X X
X O * X
X PX
X X
XXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): w
2
Document Page
XXXXXXX
X X
X O *PX
X X
X X
XXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): a
XXXXXXX
X X
X O*P X
X X
X X
XXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): a
XXXXXXX
X X
X P X
X X
X X
XXXXXXX
You won!
Please select a difficulty - [E]ASY, [M]EDIUM, [H]ARD, or [Q]UIT: m
XXXXXXXXXX
X X
X O O X
X O X
X ** P* X
X X
XXXXXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): d
XXXXXXXXXX
X X
X O O X
X O X
X ** P* X
X X
XXXXXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): s
XXXXXXXXXX
X X
X O O X
X O X
X ** * X
X P X
XXXXXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): d
XXXXXXXXXX
X X
3
Document Page
X O O X
X O X
X ** * X
X P X
XXXXXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): w
XXXXXXXXXX
X X
X O O X
X X
X ** P X
X X
XXXXXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): a
XXXXXXXXXX
X X
X O O X
X X
X ** P X
X X
XXXXXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): a
XXXXXXXXXX
X X
X O O X
X X
X ** P X
X X
XXXXXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): a
XXXXXXXXXX
X X
X O O X
X X
X **P X
X X
XXXXXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): a
You cannot go that way.
XXXXXXXXXX
X X
X O O X
X X
X **P X
X X
XXXXXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): s
XXXXXXXXXX
4
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
X X
X O O X
X X
X ** X
X P X
XXXXXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): a
XXXXXXXXXX
X X
X O O X
X X
X ** X
X P X
XXXXXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): w
XXXXXXXXXX
X X
X O O X
X * X
X *P X
X X
XXXXXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): w
XXXXXXXXXX
X X
X O*O X
X P X
X * X
X X
XXXXXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): s
XXXXXXXXXX
X X
X O*O X
X X
X *P X
X X
XXXXXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): s
XXXXXXXXXX
X X
X O*O X
X X
X * X
X P X
XXXXXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): a
XXXXXXXXXX
X X
5
Document Page
X O*O X
X X
X * X
X P X
XXXXXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): w
XXXXXXXXXX
X X
X O*O X
X * X
X P X
X X
XXXXXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): w
XXXXXXXXXX
X X
X *O X
X P X
X X
X X
XXXXXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): w
XXXXXXXXXX
X X
X P*O X
X X
X X
X X
XXXXXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): d
XXXXXXXXXX
X X
X P X
X X
X X
X X
XXXXXXXXXX
You won!
Please select a difficulty - [E]ASY, [M]EDIUM, [H]ARD, or [Q]UIT: h
XXXXXXXXXXXX
X X
X O O * O X
X * P X
X OO ** X
X ** O X
X *O * O X
X O*O* X
X X
XXXXXXXXXXXX
6
Document Page
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): a
XXXXXXXXXXXX
X X
X O O * O X
X * P X
X OO ** X
X ** O X
X *O * O X
X O*O* X
X X
XXXXXXXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): s
XXXXXXXXXXXX
X X
X O O * O X
X * X
X OO P* X
X ** X
X *O * O X
X O*O* X
X X
XXXXXXXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): s
XXXXXXXXXXXX
X X
X O O * O X
X * X
X OO * X
X ** P X
X *O * O X
X O*O* X
X X
XXXXXXXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): s
XXXXXXXXXXXX
X X
X O O * O X
X * X
X OO * X
X ** X
X *O * P X
X O*O* X
X X
XXXXXXXXXXXX
You died!
Please select a difficulty - [E]ASY, [M]EDIUM, [H]ARD, or [Q]UIT: e
XXXXXXX
X X
X *O X
X P X
X X
7
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
XXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): d
XXXXXXX
X X
X *O X
X PX
X X
XXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): d
You cannot go that way.
XXXXXXX
X X
X *O X
X PX
X X
XXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): a
XXXXXXX
X X
X *O X
X P X
X X
XXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): a
XXXXXXX
X X
X *O X
X P X
X X
XXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): w
XXXXXXX
X * X
X PO X
X X
X X
XXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): w
You cannot go that way.
XXXXXXX
X * X
X PO X
X X
X X
XXXXXXX
Please enter a move - UP (W), DOWN (S), LEFT (A), RIGHT (D), or QUIT (Q): d
8
Document Page
XXXXXXX
X * X
X P X
X X
X X
XXXXXXX
You died!
Please select a difficulty - [E]ASY, [M]EDIUM, [H]ARD, or [Q]UIT: q
>Exit code: 0
9
chevron_up_icon
1 out of 9
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]