Python代写 | CSSE1001/CSSE7030 Assignment 2

End of Dayz

Assignment 2 Semester 1, 2021 CSSE1001/CSSE7030

Due date: 20:00 (AEST), 23 April, 2021

In this assignment, you will implement a text-based zombie survival game, End of DayZ. In End of DayZ, the player has to successfully evade zombies to reach the hospital and win the game.

This assignment is divided into three tasks of increasing difficulty. Each task builds on the previous task. It is recommended that you implement one task at a time. After you finish implementing a task ensure that you thoroughly test your implementation before moving onto the next task.

The game is played within a square grid. The contents of the grid (i.e. zombies, the player, the hospital, etc.) are loaded from a map file. Map files are text files which store a grid, map files are explained in Section 4.

2 Getting Started

To start, download from Blackboard and extract the contents. The archive contains all the necessary files to start this assignment.

Within the archive you will find the following:

file that you will submit for this assignment, do not make changes to any other files.

In the context of this assignment:

4 Map Encoding

A map is encoded as a text file. The map file specifies the position of every entity in the grid. Each line of the file represents a row of the grid. Each square in the row is represented by a single character. Space characters represent a tile that does not contain an entity and non-space characters represent the type of entity in that position. Table 1 shows which character is used to encode each of the entity subclasses.

Character Entity

P Player H Hospital Z Zombie

Table 1: Characters used to encode each Entity subclass

Figure 1 is an example map encoding. Spaces in this map encoding are made explicit in this task sheet by ␣ , however they should just appear as a space in the actual map files. The player is in the position (2, 0). The hospital is located in the position (1, 2). The zombie is located in the position (3, 3).

Figure 1: Map encoding of a 4 by 4 grid that contains a player, hospital and one zombie.

5 Gameplay

A game is started by prompting the user for a map file. The prompt should say ‘Map:␣’ and wait for the user to enter the name of a file that contains a map encoding. The application requires the user to enter the relative path of the map file (e.g. maps/basic.txt). You are not expected to handle the situation where the file contains an invalid map encoding, or where the user enters an invalid path to a map file.

Once the map encoding is loaded, the grid should be printed. The grid should be surrounded by ‘#’ characters on the top, bottom and sides. The ‘#’ character represents the border of a grid. An example of a 4 by 4 grid is shown below.

###### #P# ## #H# # Z# ######

Figure 2: Grid representing the map from Figure 1 displayed as it should be printed to the user.
The game loop includes the following steps, which are executed repeatedly until a step causes the game to

1. Prompt the user for an action. The prompt should say “Enter your next action:␣”.

2. Processing the action entered by the user:1

of bounds, move the player in that direction.

3. After the step event:
• If the game is over and the player has won, print “You win!”.

• If the game is over and the player has lost, print “You lose!”.
• If the game is not over, print the grid and repeat the game loop from the first step.