Moonlander
Overview
The aim of the game is to collect some target amount of cheese and make it back to the lander to export the moon cheese back to Earth! Movement has an oxygen cost and to collect the cheese we may have to navigate around rocks and avoid running out of oxygen completely (a player can drop off cheese and refill their oxygen tank at the lander).
We will begin by setting up the board, then add the ability to move around it to play the game and in the final few stages we will also implement moonquakes and some more interesting methods of travel but we will leave that as a surprise for the moment...
Getting Started
- Create a new folder for your assignment. Here is an example:
mkdir ass1 cd ass1
- Fetch the starter code using the command below. Alternatively download the starter code here.
1511 fetch-activity cs_moonlander
- Check that everything works by running the autotest.
1511 autotest cs_moonlander
(These should fail initially. If you want to exit running the autotest midway,
press [ctrl-c]
)
Initial Code and Data Structures
The starter code for this assignment includes some functions and defined types:
- A
print_board()
function:- This prints out the current state of the board, which ensures that your board printing matches the autotest exactly for a given board.
- An
init_board()
function:- This stores a default value in each of the tiles in the provided board.
- A
struct tile
struct:- Each square of the board (i.e. the 2D array) holds a
struct tile
, containing the information about what that tile contains. - The player's row and col values are stored seperately to the contents of the board
- Each square of the board (i.e. the 2D array) holds a
- An
enum entity
enum:- This is used in the
struct tile
struct to represent what is on each tile.
- This is used in the
Let us look at an example output from the print_board()
function.
+---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| |^^^| |<(]| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |0.0| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |\O/| |~~~| |~~~| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+
Here, we have tiles containing:
- the lander
/|\
- a rock
^^^
- a cheese
<(]
- a hole down
\O/
- two portals
~~~
- the player
0.0
Where do we store the player?
The player is not stored in the board
, instead the print_board()
function
takes the player's row and column as arguments whenever we print the board.
- for the above example:
print_board(board, 4, 6);
.
So you can store the player however you like! (e.g. variables for the row/col, or perhaps a struct that contains both the row and the col!)
Reference Implementation
To help you understand how the assignment works, we have written a reference implementation for you to run. You can run it via the command 1511 cs_moonlander
.
1511 cs_moonlander ...
Try the following input in the reference implementation:
4 4 R 2 3 2 6 r 0 1 c 3 4 q 8 10 5 5 s a a p a p q
FAQ
Q: Can I edit the given starter code functions/structs/enums?
Yes. You can edit any of the functions/structs/enums given in the starter code. You can delete the whole starter code and start from scratch if you really want to (not recommended).
Some later stages might require you to edit the tile
struct.
Q: Can I use pointers
The assignment can be done without pointers, but you can use them if you wish.
Q: Can I use X other C feature
A: For everything not taught in the course, check the style guide. If it says "Avoid", then we may take style marks off if its not used correctly. If it says "Don't Use" then we will take style marks off (see the style marking rubric).
Stages
We have broken the assignment spec down into incremental stages:
- Stage 1: Place the lander, add cheese & rocks to the board.
- Stage 2: Setup the player, add player movement, pick up and drop off cheese, keep oxygen levels correctly updated, refill oxygen at the lander.
- Stage 3: Check for a win or lose condition, add a command to quit the program early, add moonquake mechanics.
- Stage 4: Make the board 3D, add commands to create holes and jump between levels, add portals, implement travelling through portals.
- Extension (no marks): Add a graphical user interface.
Your Tasks
This assignment consists of four stages. Each stage builds on the work of the previous stage, and each stage has a higher complexity than its predecessor. You should complete the stages in order.
A video explanation to help you get started with the assignment can here found here:
Stage 1
In stage 1, you will scan and store values to set up the map, including the lander, rock obstacles, and collectible cheese.
There is a reference implementation that you can play by running the command 1511 cs_moonlander
in the terminal.
Here is an example of input for a finished stage 1 that you can try within the reference implementation.
1511 cs_moonlander 1 5 c 1 2 c 3 1 r 3 5 r 3 7 R 5 4 8 6 [ctrl+d]
Stage 1.1: Placing the Lander
We will begin by scanning in and storing some values from the terminal. We will also need to assert that the values are valid.
In this substage, you will need to do the following:
- Print the prompt
Please enter the [row] [col] of the lander:
. - Scan in the lander's position as
row
andcol
. - Check that the row and col values correspond to a valid tile:
- If the requested tile is not on the board, place the lander at
board[4][4]
. - Otherwise, add the lander to the board at the requested tile.
- If the requested tile is not on the board, place the lander at
- Call the provided
print_board()
function with these arguments:INVALID_INDEX
as the arguments forplayer_row
andplayer_col
.BASE_OXY_RATE
as the argument foroxy_rate
.0
or0.0
for all other arguments.
Clarifications
- The lander row and col will always be ints.
Examples:
Input:
6 6
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander Please enter the [row] [col] of the lander: 6 6 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |/|\| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+
Input:
-3 8
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander Please enter the [row] [col] of the lander: -3 8 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |/|\| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+
Autotest
Stage 1.2: Add cheese and rocks
So far we have only added the lander to the board, that is pretty boring so let us add some moon cheese collectibles and rock obstacles to spice it up!
To do this we will create a setup loop that scans in commands to let the user add CHEESE
and ROCK
s to the board.
Allow the user to add CHEESE
using the command in the form c int int
and add a ROCK
using the command in the form r int int
until [ctrl+d]
is pressed.
In this substage, you will need to do the following:
- Print the prompt
Please enter cheese and rock locations:\n
. - Allow the user to input commands in a loop until
[ctrl+d]
is pressed. - Given the command:
c [row] [col]
, add aCHEESE
to that tile. - Given the command:
r [row] [col]
, add aROCK
to that tile. - After the user enters
[ctrl+d]
, call the providedprint_board()
function with these arguments:- INVALID_INDEX as the arguments for
player_row
andplayer_col
. - BASE_OXY_RATE as the argument for
oxy_rate
. 0
or0.0
for all other arguments.
- INVALID_INDEX as the arguments for
Clarifications
- Each command provided will be of the form
char int int
. - You can not assume that only the
c
orr
commands will be entered.
Examples
Input:
4 3 c 3 7 [ctrl+d]
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander Please enter the [row] [col] of the lander: 4 3 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |/|\| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter cheese and rock locations: c 3 7 [ctrl+d] +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |<(]| | | +---+---+---+---+---+---+---+---+---+---+ | | | |/|\| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+
Input:
4 8 c 3 7 r 4 2 c 6 3 r 6 9 [ctrl+d]
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander Please enter the [row] [col] of the lander: 4 8 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |/|\| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter cheese and rock locations: c 3 7 r 4 2 c 6 3 r 6 9 [ctrl+d] +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |<(]| | | +---+---+---+---+---+---+---+---+---+---+ | | |^^^| | | | | |/|\| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |<(]| | | | | |^^^| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+
Autotest
Stage 1.3: Add Large Rocks and Check Scan Positioning
Adding rocks one by one can get quite repetitive, so here we will introduce the new R
command to our handy setup loop from stage 1.2. This will allow us to add large rectangular rocks to the board.
We will also print an error message if the cheese and rocks we scan in would be placed on a square that already contains something.
In this substage, you will need to do the following:
- For our cheese input from stage 1.2, if the requested tile is occupied or not on the board, instead of adding the cheese to the board print
That is not a valid cheese placement!\n
. - For our single rock input from stage 1.2, if the requested tile is occupied or not on the board, instead of adding the rock to the board print
That is not a valid rock placement!\n
. - Given the command
R [start_row] [start_col] [end_row] [end_col]
, place a large rock with top left corner at[start_row] [start_col]
and bottom right corner at[end_row] [end_col]
. A large rock is represented by placing aROCK
on every tile in it's area.- If any of the following error conditons are true, print
That is not a valid rock placement!\n
and do not add the large rock to the board.- Any tile enclosed in the requested rectangle does not lie on the board.
- Any tile enclosed in the requested rectangle is occupied.
start_row
is greater thanend_row
, orstart_col
is greater thanend_col
.
- If any of the following error conditons are true, print
Clarifications
- A tile is occupied if its
entity
field is notEMPTY
.
Examples:
Input:
3 8 c -1 3 r -1 3 c 3 -1 r 3 -1 c 10 2 r 10 2 c 1 39 r 1 39 [ctrl+d]
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander Please enter the [row] [col] of the lander: 3 8 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |/|\| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter the cheese and rock locations: c -1 3 That is not a valid cheese placement! r -1 3 That is not a valid rock placement! c 3 -1 That is not a valid cheese placement! r 3 -1 That is not a valid rock placement! c 10 2 That is not a valid cheese placement! r 10 2 That is not a valid rock placement! c 1 39 That is not a valid cheese placement! r 1 39 That is not a valid rock placement! [ctrl+d] +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |/|\| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+
Input:
2 2 R 4 4 6 6 R 8 2 9 3 [ctrl+d]
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander Please enter the [row] [col] of the lander: 2 2 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter the cheese and rock locations: R 4 4 6 6 R 8 2 9 3 [ctrl+d] +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^^^|^^^|^^^| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^^^|^^^|^^^| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^^^|^^^|^^^| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |^^^|^^^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |^^^|^^^| | | | | | | +---+---+---+---+---+---+---+---+---+---+
Input:
2 2 R 1 2 3 4 R 1 -2 -3 4 R 1 23 3 10 R 8 8 6 6 R 6 6 8 8 [ctrl+d]
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander Please enter the [row] [col] of the lander: 2 2 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter the cheese and rock locations: R 1 2 3 4 That is not a valid rock placement! R 1 -2 -3 4 That is not a valid rock placement! R 1 23 3 10 That is not a valid rock placement! R 8 8 6 6 That is not a valid rock placement! R 6 6 8 8 [ctrl+d] +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |^^^|^^^|^^^| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |^^^|^^^|^^^| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |^^^|^^^|^^^| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+
Autotest
Testing and Submission
Are you finished with this stage? If so, you should make sure to do the following:
- Run
1511 style
, and clean up any issues a human may have reading your code. Don't forget -- 20% of your mark in the assignment is based on style! - Autotest for this stage of the assignment by running the
autotest-stage
command as shown below. - Remember -- give early, and give often. Only your last submission counts, but why not be safe and submit right now?
1511 style cs_moonlander.c 1511 autotest-stage 01 cs_moonlander give cs1511 ass1_cs_moonlander cs_moonlander.c
Stage 2
In stage 2, you will setup the player, implement player movement, the oxygen consumption (turn) system and picking up and dropping off cheese at the lander.
We implement the beginnings of the turn system in this stage. When the player moves, they use up a certain amount of oxygen, decreasing their tank level by that much. That amount starts as 1.0 but may change in later stages. If a player attempts an action that would decrease their oxygen amount, but they cannot complete that action, no oxygen decrement occurs for that turn (i.e. attempting to move onto a rock).
When we implement winning or losing the game and lander interactions (refill oxygen, drop off cheese), the order of operations for any single turn becomes important. They are as follows, in order:
- Any preconditions for the action are checked
- If the action cannot be performed (i.e. moving onto a rock), it does not count as a turn and nothing else happens this turn except printing the board.
- The action is taken and any effects are carried out
- I.e. player moves, picks up cheese and decreases oxygen level
- Check for and execute lander interactions if available
- Lander interactions happen when the player is on one of the 8 tiles that surround the lander
- Lander interactions will consist of refilling the oxygen level, repairing suit leaks and dropping off held cheese
- Check for win/lose conditions
- Including printing win/lose message and exiting the program (stage 3.1)
- If the command was not recognised you should print
Command not recognised!\n
(stage 2.2), otherwise call theprint_board()
function.
Here is an example of input for a finished stage 2 that you can try on the reference implementation.
3 3 c 3 4 c 2 8 q 3 20 2 9 x a a a s a a a [ctrl+d]
Stage 2.1: Setting up the player
The last bit of initialisation is to scan in the target amount of cheese, the player's oxygen tank capacity, and the player's starting tile.
In this substage, you will need to do the following:
- Edit the setup command loop to end when
COMMAND_QUIT
is entered, rather than[ctrl+d]
. This means that after the player has placed all the cheese and rocks, they will have to enterCOMMAND_QUIT
in order to enter the player setup phase below.- The reason for this change is that once
[ctrl+d]
is entered, C will not scan any further inputs, meaning we can not play the game.
- The reason for this change is that once
- Ask for a target quantity of cheese.
- Use the prompt
Please enter the target qty of cheese:
. - Scan in the target quantity of cheese to collect as an int.
- If the target quantity of cheese is less than 0, print
The target qty of cheese must be >= 0!\n
and scan again, repeating until a valid input is entered.
- Use the prompt
- Ask for the oxygen tank capacity of the player.
- Use the prompt
Please enter the player's oxygen tank capacity:
. - Scan in the player's tank capacity as a double.
- If the scanned tank capacity is less than 0, print
The oxygen tank capacity must be >= 0!\n
and scan again, repeating until a valid input is entered.
- Use the prompt
- Ask for the player's starting position.
- Use the prompt
Please enter the [row] [col] of the player:
. - Scan in the
[row] [col]
of the player as ints. - If the requested tile is not in bounds of the map or is occupied, print
That is not a valid player placement!\n
, repeating until a valid starting position is entered.
- Use the prompt
- Print the message
<-> STARTING MOONLANDER <->\n
. - Print the board using the provided
print_board()
function.- From now on, instead of using default values in the
print_board()
function, use the current values of:- the player's row and column
- amount of cheese the player and lander hold (starts at
0
) - oxygen capacity
- oxygen level (starts at capacity)
- oxygen rate (starts as
BASE_OXY_RATE
)
- From now on, instead of using default values in the
Clarifications
- The target quantity of cheese, player row and col, will always be ints.
- The tank capacity will always be a double.
- When using the reference solution, after the board prints, enter
[ctrl+d]
to match what your program should do.
Examples
Input:
3 8 q 2 10 4 9 [ctrl+d]
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander Please enter the [row] [col] of the lander: 3 8 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |/|\| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter cheese and rock locations: q +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |/|\| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter the target qty of cheese: 2 Please enter the player's oxygen tank capacity: 10 Please enter the [row] [col] of the player: 4 9 <-> STARTING MOONLANDER <-> +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |/|\| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | |0.0| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 10.00 / 10.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+
Input:
1 5 r 4 4 c 5 6 q 2 10 -1 3 1 -7 10 7 8 32 1 5 4 4 5 6 6 6 [ctrl+d]
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander Please enter the [row] [col] of the lander: 1 5 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |/|\| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter cheese and rock locations: r 4 4 c 5 6 q +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |/|\| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^^^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |<(]| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter the target qty of cheese: 2 Please enter the player's oxygen tank capacity: 10 Please enter the [row] [col] of the player: -1 3 That is not a valid player placement! 1 -7 That is not a valid player placement! 10 7 That is not a valid player placement! 8 32 That is not a valid player placement! 1 5 That is not a valid player placement! 4 4 That is not a valid player placement! 5 6 That is not a valid player placement! 6 6 <-> STARTING MOONLANDER <-> +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |/|\| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^^^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |<(]| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |0.0| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 10.00 / 10.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+
Input:
1 5 q -1 1 -3 5.2 6 6 [ctrl+d]
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander 1 5 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |/|\| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter cheese and rock locations: q +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |/|\| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ -1 The target qty of cheese must be >= 0! 1 Please enter the player's oxygen tank capacity: -3 The oxygen tank capacity must be >= 0! 5.2 Please enter the [row] [col] of the player: 6 6 <-> STARTING MOONLANDER <-> +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |/|\| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |0.0| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 5.20 / 5.20 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+
Autotest
Stage 2.2: Command loop, Player movement
This substage sets up the gameplay command loop for the rest of the game, after this most of what we will be doing is extending it to cover more user commands.
We will also implement the first set of commands here, those used to move the player around the board.
In this substage, you will need to do the following:
- Construct a main command loop that scans commands (
char
followed by optional other inputs depending on the command) and executes them.- When a unknown command character is entered, print
Command not recognised!\n
- When a unknown command character is entered, print
- When the commands
w
,a
,s
,d
are entered, move the player onto the square above, left, below or right respectively, of their current position.- Call the
print_board()
function after each command - Each time the player moves, their oxygen level should be decreased by the oxygen rate (starts at
BASE_OXY_RATE
)
- Call the
- When
[ctrl+d]
is pressed, exit the program without any further scanning or printing
Clarifications
- The first input of every command will be either
[ctrl+d]
or achar
Examples:
Input:
0 1 q 2 10 0 5 d s a w [ctrl+d]
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander Please enter the [row] [col] of the lander: 0 1 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | |/|\| | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter cheese and rock locations: q +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | |/|\| | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ 2 10 0 5 <-> STARTING MOONLANDER <-> +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | |/|\| | | |0.0| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 10.00 / 10.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ d +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | |/|\| | | | |0.0| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 9.00 / 10.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ s +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | |/|\| | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |0.0| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 8.00 / 10.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ a +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | |/|\| | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |0.0| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 7.00 / 10.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ w +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | |/|\| | | |0.0| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 6.00 / 10.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+
Input:
0 1 q 4 10.2 0 5 x [ctrl+d]
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander Please enter the [row] [col] of the lander: 0 1 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | |/|\| | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter cheese and rock locations: q +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | |/|\| | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter the target qty of cheese: 4 Please enter the player's oxygen tank capacity: 10.2 Please enter the [row] [col] of the player: 0 5 <-> STARTING MOONLANDER <-> +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | |/|\| | | |0.0| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 10.20 / 10.20 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ x Command not recognised!
Autotest
Stage 2.3: Movement Collision and Refilling Oxygen
Now when we move the player, we will have to assert that the target tile can be moved onto. A tile can be moved onto if it is on the board and there is not a rock or the lander on it already.
We will also add the ability to refill the player's oxygen level back to the full tank capacity at the lander. The tank is refilled if the player ends their turn in one of the 8 tiles adjacent to the lander.
In this substage, you will need to do the following:
- Check whether the tile in the corresponding direction is free to walk on before moving.
- Tiles off the board, tiles containing the lander or tiles with rocks cannot be moved onto.
- If they can, the player moves to the target tile.
- If the player moved, decrement their oxygen tank level by the current oxygen rate (starts at
BASE_OXY_RATE
). - If the player is within 1 tile of the lander in both the vertical and horizontal directions (i.e. in one of the eight tiles directly surrounding the lander), their oxygen level is refilled to the tank capacity.
Clarifications
- We will handle the case when the player has no oxygen in stage 3.1 when win/lose conditions are implemented, this case will not be tested until then.
Examples:
Input:
2 2 r 0 3 q 3 100 0 0 w a d d d s s [ctrl+d]
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander Please enter the [row] [col] of the lander: 2 2 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter cheese and rock locations: r 0 3 q +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | |^^^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter the target qty of cheese: 3 Please enter the player's oxygen tank capacity: 100 Please enter the [row] [col] of the player: 0 0 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ |0.0| | |^^^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 100.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ w +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ |0.0| | |^^^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 100.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ a +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ |0.0| | |^^^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 100.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ d +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | |0.0| |^^^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 99.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ d +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | |0.0|^^^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 98.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ d +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | |0.0|^^^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 98.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ s +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | |^^^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |0.0| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 100.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ s +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | |^^^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |0.0| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 100.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+
Autotest
Stage 2.4: Pick up and drop off cheese
In this substage, you will need to do the following:
- Whenever the player moves onto a tile containing a piece of cheese:
- Add a unit of cheese to the player's total.
- Remove the cheese from the tile.
- If the player is in one of the eight tiles directly surrounding the lander, transfer all cheese they are holding onto the lander (at the same time as refilling their oxygen).
Examples
Input:
7 7 c 6 6 c 5 6 c 5 5 c 5 4 c 4 4 q 8 20 4 3 d s d d s [ctrl+d]
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander Please enter the [row] [col] of the lander: 7 7 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |/|\| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter cheese and rock locations: c 6 6 c 5 6 c 5 5 c 5 4 c 4 4 q +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |<(]| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |<(]|<(]|<(]| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |<(]| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |/|\| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter the target qty of cheese: 8 Please enter the player's oxygen tank capacity: 20 Please enter the [row] [col] of the player: 4 3 <-> STARTING MOONLANDER <-> +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |0.0|<(]| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |<(]|<(]|<(]| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |<(]| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |/|\| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 20.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ d +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |0.0| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |<(]|<(]|<(]| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |<(]| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |/|\| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 1 Lander Cheese: 0 Oxy: 19.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ s +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |0.0|<(]|<(]| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |<(]| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |/|\| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 2 Lander Cheese: 0 Oxy: 18.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ d +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |0.0|<(]| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |<(]| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |/|\| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 3 Lander Cheese: 0 Oxy: 17.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ d +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |0.0| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |<(]| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |/|\| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 4 Lander Cheese: 0 Oxy: 16.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ s +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |0.0| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |/|\| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 5 Oxy: 20.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+
Autotest
Testing and Submission
Are you finished with this stage? If so, you should make sure to do the following:
- Run
1511 style
, and clean up any issues a human may have reading your code. Don't forget -- 20% of your mark in the assignment is based on style! - Autotest for this stage of the assignment by running the
autotest-stage
command as shown below. - Remember -- give early, and give often. Only your last submission counts, but why not be safe and submit right now?
1511 style cs_moonlander.c 1511 autotest-stage 02 cs_moonlander give cs1511 ass1_cs_moonlander cs_moonlander.c
Stage 3
In stage 3, you will check for win and lose conditions, allow the user to quit early and implement moonquake mechanics.
Stage 3.1: Win and Lose, Quit Early
Our game is starting to come together, we can control the player, pick up and drop off collectibles and manage our oxygen resources.
There is one thing missing though, there is no way to win! The next thing we will do is rectify this by checking and acting upon winning and losing conditions after each player action.
In this substage, you will need to do the following:
- If the player ends their turn within range of the lander (in any of the 8 tiles adjacent to the lander):
- After transferring the cheese to the lander, if the amount of cheese on the lander meets or exceeds the target value we scanned back in substage 2.1, print
Congratulations, you won!\n
and return from the program.
- After transferring the cheese to the lander, if the amount of cheese on the lander meets or exceeds the target value we scanned back in substage 2.1, print
- If the player ends their turn with less than or equal to
0.0
oxygen they lose.- If the player uses their last unit of oxygen to get into range of the lander they should end their turn with a full tank and not lose.
- When the player loses, print
Sorry, you ran out of oxygen and lost!\n
and return from the program.
- Add a new command
COMMAND_QUIT
to the main command loop.- When entered, exit the program without printing anything.
- Note, you should still be able to exit the command loop with
ctrl+d
.
Clarifications
- You should not print the board after a win or loss message.
Examples:
Input:
4 4 c 2 4 q 1 6 1 4 s s
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander Please enter the [row] [col] of the lander: 4 4 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |/|\| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter cheese and rock locations: c 2 4 q +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |<(]| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |/|\| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter the target qty of cheese: 1 Please enter the player's oxygen tank capacity: 6 Please enter the [row] [col] of the player: 1 4 <-> STARTING MOONLANDER <-> +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |0.0| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |<(]| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |/|\| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 6.00 / 6.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ s +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |0.0| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |/|\| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 1 Lander Cheese: 0 Oxy: 5.00 / 6.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ s +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |0.0| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |/|\| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 1 Oxy: 6.00 / 6.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Congratulations, you won!
Input:
4 4 c 2 4 q 1 6 1 4 q
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander Please enter the [row] [col] of the lander: 4 4 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |/|\| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter cheese and rock locations: c 2 4 q +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |<(]| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |/|\| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter the target qty of cheese: 1 Please enter the player's oxygen tank capacity: 6 Please enter the [row] [col] of the player: 1 4 <-> STARTING MOONLANDER <-> +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |0.0| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |<(]| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |/|\| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 6.00 / 6.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ q
Autotest
Stage 3.2: Moonquakes
Now we will implement moonquakes, via the m
command in the main command loop. Moonquakes rotate the entire board clockwise by 90 degrees each time the command is input.
There are also some detrimental effects to the players stats that can be rectified by visiting the lander again.
In this substage, you will need to do the following:
- Add the
m
command to the command loop. - Implement the rotation.
- Board rotated 90 degrees clockwise each
m
command. - The player also rotates so that their relative distance to all objects on the board does not change.
- Board rotated 90 degrees clockwise each
- Implement player state changes.
- Moonquakes decrement the player's current oxygen tank level by 20% of the tank's maximum capacity.
- Moonquakes cause the players suit to leak by multiplying whatever the current oxygen rate is by 1.2. This effect stacks, so after 2 moonquakes the rate will be 1.0 * 1.2 * 1.2 = 1.44.
- Implement player suit leak repair.
- Similar to the move command, if the player ends their turn within range of the lander, they refill their oxygen and drop off all held cheese
- In addition to dropping off their cheese and refilling their oxygen tanks when near the lander, a player will also have their suit repaired, resetting their oxygen rate to
BASE_OXY_RATE
.
- After all the previous effects have been completed, print the board.
Examples:
Input:
0 0 r 0 9 c 9 0 q 4 100 3 4 m m m m a q
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander Please enter the [row] [col] of the lander: 0 0 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ |/|\| | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter cheese and rock locations: r 0 9 c 9 0 q +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ |/|\| | | | | | | | |^^^| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |<(]| | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter the target qty of cheese: 4 Please enter the player's oxygen tank capacity: 100 Please enter the [row] [col] of the player: 3 4 <-> STARTING MOONLANDER <-> +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ |/|\| | | | | | | | |^^^| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |0.0| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |<(]| | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 100.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ m +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ |<(]| | | | | | | | |/|\| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |0.0| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | |^^^| +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 80.00 / 100.00 @ 1.200000 / move +---+---+---+---+---+---+---+---+---+---+ m +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | |<(]| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |0.0| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |^^^| | | | | | | | |/|\| +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 60.00 / 100.00 @ 1.440000 / move +---+---+---+---+---+---+---+---+---+---+ m +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ |^^^| | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |0.0| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |/|\| | | | | | | | |<(]| +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 40.00 / 100.00 @ 1.728000 / move +---+---+---+---+---+---+---+---+---+---+ m +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ |/|\| | | | | | | | |^^^| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |0.0| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |<(]| | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 20.00 / 100.00 @ 2.073600 / move +---+---+---+---+---+---+---+---+---+---+ a +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ |/|\| | | | | | | | |^^^| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |0.0| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |<(]| | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 17.93 / 100.00 @ 2.073600 / move +---+---+---+---+---+---+---+---+---+---+ q
Input:
0 0 r 0 9 c 2 2 q 4 100 3 2 m m m m w a w q
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander Please enter the [row] [col] of the lander: 0 0 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ |/|\| | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter cheese and rock locations: r 0 9 c 2 2 q +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ |/|\| | | | | | | | |^^^| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |<(]| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter the target qty of cheese: 4 Please enter the player's oxygen tank capacity: 100 Please enter the [row] [col] of the player: 3 2 <-> STARTING MOONLANDER <-> +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ |/|\| | | | | | | | |^^^| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |<(]| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |0.0| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 100.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ m +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | |/|\| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |0.0|<(]| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | |^^^| +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 80.00 / 100.00 @ 1.200000 / move +---+---+---+---+---+---+---+---+---+---+ m +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |0.0| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |<(]| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |^^^| | | | | | | | |/|\| +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 60.00 / 100.00 @ 1.440000 / move +---+---+---+---+---+---+---+---+---+---+ m +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ |^^^| | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |<(]|0.0| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |/|\| | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 40.00 / 100.00 @ 1.728000 / move +---+---+---+---+---+---+---+---+---+---+ m +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ |/|\| | | | | | | | |^^^| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |<(]| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |0.0| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 20.00 / 100.00 @ 2.073600 / move +---+---+---+---+---+---+---+---+---+---+ w +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ |/|\| | | | | | | | |^^^| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |0.0| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 1 Lander Cheese: 0 Oxy: 17.93 / 100.00 @ 2.073600 / move +---+---+---+---+---+---+---+---+---+---+ a +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ |/|\| | | | | | | | |^^^| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | |0.0| | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 1 Lander Cheese: 0 Oxy: 15.85 / 100.00 @ 2.073600 / move +---+---+---+---+---+---+---+---+---+---+ w +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ |/|\| | | | | | | | |^^^| +---+---+---+---+---+---+---+---+---+---+ | |0.0| | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 1 Oxy: 100.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ q
Input:
0 0 q 4 100 0 1 m q
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander Please enter the [row] [col] of the lander: 0 0 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ |/|\| | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter cheese and rock locations: q +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ |/|\| | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter the target qty of cheese: 4 Please enter the player's oxygen tank capacity: 100 Please enter the [row] [col] of the player: 0 1 <-> STARTING MOONLANDER <-> +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ |/|\|0.0| | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 100.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ m +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | |/|\| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | |0.0| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 100.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ q
Autotest
Testing and Submission
Are you finished with this stage? If so, you should make sure to do the following:
- Run
1511 style
, and clean up any issues a human may have reading your code. Don't forget -- 20% of your mark in the assignment is based on style! - Autotest for this stage of the assignment by running the
autotest-stage
command as shown below. - Remember -- give early, and give often. Only your last submission counts, but why not be safe and submit right now?
1511 style cs_moonlander.c 1511 autotest-stage 03 cs_moonlander give cs1511 ass1_cs_moonlander cs_moonlander.c
Stage 4
In Stage 4, you will make the board 3-dimensional, implementing digging holes, making and travelling between portals.
Stage 4.1: Digging
Up until now we have only explored the surface of the moon. As we well know, much like an onion (mmmmm, cheese and onion), the moon is constructed of many layers, with rich veins of mooncheese running through them. Let us take advantage of this!
The first thing to do is add the ability to dig holes to travel to lower layers of the moon.
In this substage, you will need to do the following:
- Transform the board state to keep track of 32 levels with the same dimensions as the original board.
- When the user scans in the rocks and cheese at the start of each game, each rock and cheese appears at the same
[row] [col]
on each layer. - The lander only appears on the surface layer (layer 0).
- The player starts on the surface layer (layer 0).
- When the user scans in the rocks and cheese at the start of each game, each rock and cheese appears at the same
- Add the command
h [direction]
to the command loop.- Adds a hole
HOLE_DOWN
in the current layer and correspondingHOLE_UP
at the same position in the layer below. direction
must be eitherw
,a
,s
ord
and corresponds to the tile surrounding the player that the hole is placed.- Holes can only be placed on tiles that have an
EMPTY
field for both theHOLE_UP
andHOLE_DOWN
tiles. - The player is allowed to move onto a tile with a hole on it.
- Adding a hole counts as a turn, the player should lose oxygen if the hole is placed successfully.
- If the player is standing on the lowest level of the moon, attempting to dig a hole does nothing.
- After the command, whether successful or not, print the board.
- Adds a hole
- Add the command
j
to the command loop.- If the tile the player is standing on is
HOLE_UP
, jump up one level, if it is aHOLE_DOWN
, jump down one level, else no change. - Jumping counts as a turn, the player should lose oxygen if and only if the jump was successful (player level changed).
- After the command, whether successful or not, print the board.
- If the tile the player is standing on is
Clarifications
- Holes should move as other objects on the board do during moonquakes.
- Moonquakes now affect all layers of the moon.
- The top layer (containing the lander) has a depth of 0, the one below 1, etc.
Examples:
Input:
2 5 r 8 3 c 3 3 q 1 20 4 3 w h a a j j d d
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander Please enter the [row] [col] of the lander: 2 5 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |/|\| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter cheese and rock locations: r 8 3 c 3 3 q +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |/|\| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |<(]| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |^^^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter the target qty of cheese: 1 Please enter the player's oxygen tank capacity: 20 Please enter the [row] [col] of the player: 4 3 <-> STARTING MOONLANDER <-> +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |/|\| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |<(]| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |0.0| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |^^^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 20.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ w +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |/|\| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |0.0| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |^^^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 1 Lander Cheese: 0 Oxy: 19.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ h a +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |/|\| | | | | +---+---+---+---+---+---+---+---+---+---+ | | |\O/|0.0| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |^^^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 1 Lander Cheese: 0 Oxy: 18.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ a +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |/|\| | | | | +---+---+---+---+---+---+---+---+---+---+ | | |0.0| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |^^^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 1 Lander Cheese: 0 Oxy: 17.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ j +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |0.0|<(]| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |^^^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 1 Lander Cheese: 0 Oxy: 16.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ j +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |/|\| | | | | +---+---+---+---+---+---+---+---+---+---+ | | |0.0| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |^^^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 1 Lander Cheese: 0 Oxy: 15.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ d +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |/|\| | | | | +---+---+---+---+---+---+---+---+---+---+ | | |\O/|0.0| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |^^^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 1 Lander Cheese: 0 Oxy: 14.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ d +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |/|\| | | | | +---+---+---+---+---+---+---+---+---+---+ | | |\O/| |0.0| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |^^^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 1 Oxy: 20.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Congratulations, you won!
Input:
2 4 c 4 4 c 4 5 q 4 20 3 3 h s s d d h d d j a a a j d w
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander Please enter the [row] [col] of the lander: 2 4 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |/|\| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter cheese and rock locations: c 4 4 c 4 5 q +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |/|\| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |<(]|<(]| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter the target qty of cheese: 4 Please enter the player's oxygen tank capacity: 20 Please enter the [row] [col] of the player: 3 3 <-> STARTING MOONLANDER <-> +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |/|\| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |0.0| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |<(]|<(]| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 20.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ h s +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |/|\| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |0.0| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |\O/|<(]|<(]| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 20.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ s +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |/|\| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |0.0|<(]|<(]| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 19.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ d +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |/|\| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |\O/|0.0|<(]| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 1 Lander Cheese: 0 Oxy: 18.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ d +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |/|\| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |\O/| |0.0| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 2 Lander Cheese: 0 Oxy: 17.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ h d +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |/|\| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |\O/| |0.0|\O/| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 2 Lander Cheese: 0 Oxy: 16.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ d +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |/|\| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |\O/| | |0.0| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 2 Lander Cheese: 0 Oxy: 15.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ j +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |/O\|<(]|<(]|0.0| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 2 Lander Cheese: 0 Oxy: 14.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ a +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |/O\|<(]|0.0|/O\| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 3 Lander Cheese: 0 Oxy: 13.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ a +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |/O\|0.0| |/O\| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 4 Lander Cheese: 0 Oxy: 12.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ a +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |0.0| | |/O\| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 4 Lander Cheese: 0 Oxy: 11.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ j +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |/|\| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |0.0| | |\O/| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 4 Lander Cheese: 0 Oxy: 10.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ d +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |/|\| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |\O/|0.0| |\O/| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 4 Lander Cheese: 0 Oxy: 9.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ w +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |/|\| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |0.0| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |\O/| | |\O/| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 4 Oxy: 20.00 / 20.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Congratulations, you won!
Autotest
Stage 4.2: Portals
Moving and jumping are all good, but sometimes we need to move faster than that to collect enough cheese with our oxygen constraints.
Cue portals, we can now create portals between any two (valid) tiles on the board. Stepping onto one side of a portal results in stepping out of the other side of the linked portal in the same direction the player stepped in.
Portal travel works in both directions, stepping into a portal and then directly back with the move command should land the player in their starting position with twice the oxygen rate less oxygen then they started with.
In this substage, you will need to do the following:
- Add the portal command
t [direction] [level] [row] [col]
to the command loop.- Creates a portal between the tile in
direction
directly next to the player and the tile referenced bylevel
,row
,col
. - Direction is one of
w
,a
,s
,d
, corresponding to the tile directly up, left, down or right of the player's current position respectively. - For a portal to be placed, both target tiles cannot be the same tile and must both be on the board and not occupied by a lander, rock, cheese, portal, hole or the player.
- Placing a portal counts as a turn, the player loses their oxygen rate from their tank after placing the portal (only if it was successfully placed).
- Tiles with portals on them should have their entity field set to
PORTAL
. - There is a limit of
MAX_PORTALS
at any one time.
- Creates a portal between the tile in
- Update the move commands (
w
,a
,s
,d
) so that if the player steps onto a portal, they come out the opposite side of the other portal.- If the square the player would end up on is not on the board, or has a rock or the lander on it, then the player should remain in their current position and no oxygen should be consumed.
- Moving still has the same oxygen cost. I.e. one times the current oxygen rate if successful, else no cost.
- If moving through a portal would leave the player standing on a second portal, they travel through that portal also and so on. In this case, each portal traversed costs one oxygen but the player does not stop to do lander interactions until they land on a tile, they can however run out of oxygen and lose while in this state (if the player does run out of oxygen, place them on the final square in the portal chain before printing the board and exiting with the no oxygen losing message).
Clarifications
- Portals will move with moonquakes (
m
command) - Holes cannot be dug if either the tile for the
HOLE_DOWN
orHOLE_UP
has a portal.
Examples:
Input:
3 8 q 1 100 3 1 t d 0 5 7 d q
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander Please enter the [row] [col] of the lander: 3 8 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |/|\| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter cheese and rock locations: q +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |/|\| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter the target qty of cheese: 1 Please enter the player's oxygen tank capacity: 100 Please enter the [row] [col] of the player: 3 1 <-> STARTING MOONLANDER <-> +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | |0.0| | | | | | |/|\| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 100.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ t d 0 5 7 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | |0.0|~~~| | | | | |/|\| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |~~~| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 99.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ d +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |~~~| | | | | |/|\| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |~~~|0.0| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 98.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ q
Input:
7 2 c 3 2 q 1 100 5 6 h w t s 1 2 2 s q
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander Please enter the [row] [col] of the lander: 7 2 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter cheese and rock locations: c 3 2 q +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |<(]| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter the target qty of cheese: 1 Please enter the player's oxygen tank capacity: 100 Please enter the [row] [col] of the player: 5 6 <-> STARTING MOONLANDER <-> +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |<(]| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |0.0| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 100.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ h w +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |<(]| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |\O/| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |0.0| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 99.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ t s 1 2 2 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |<(]| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |\O/| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |0.0| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |~~~| | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 98.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ s +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |~~~| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |0.0| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |/O\| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 1 Lander Cheese: 0 Oxy: 97.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ q
Input:
6 2 q 1 100 4 4 t a 0 0 9 t w 0 1 9 w q
Input and Output:
dcc cs_moonlander.c -o cs_moonlander ./cs_moonlander Please enter the [row] [col] of the lander: 6 2 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter cheese and rock locations: q +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 0.00 / 0.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ Please enter the target qty of cheese: 1 Please enter the player's oxygen tank capacity: 100 Please enter the [row] [col] of the player: 4 4 <-> STARTING MOONLANDER <-> +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |0.0| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 100.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ t a 0 0 9 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | |~~~| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |~~~|0.0| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 99.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ t w 0 1 9 +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | |~~~| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | |~~~| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |~~~| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |~~~|0.0| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 98.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ w +---+---+---+---+---+---+---+---+---+---+ | C S M O O N L A N D E R | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | |~~~| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | |~~~| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |0.0|~~~| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |~~~| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |/|\| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Player Cheese: 0 Lander Cheese: 0 Oxy: 96.00 / 100.00 @ 1.000000 / move +---+---+---+---+---+---+---+---+---+---+ q
Autotest
Testing and Submission
Are you finished with this stage? If so, you should make sure to do the following:
- Run
1511 style
, and clean up any issues a human may have reading your code. Don't forget -- 20% of your mark in the assignment is based on style! - Autotest for this stage of the assignment by running the
autotest-stage
command as shown below. - Remember -- give early, and give often. Only your last submission counts, but why not be safe and submit right now?
1511 style cs_moonlander.c 1511 autotest-stage 04 cs_moonlander give cs1511 ass1_cs_moonlander cs_moonlander.c
Extension
As an extension, we have set up a starting point to add a texture pack to your game via splashkit.
Extension activities are not work any marks, nor are there any autotests.
Installing Splashkit
To install splashkit, run the following command
1511 setup-splashkit cs_moonlander
Check that Splashkit Works
Lets check that splashkit works by running a test file. It should display a white square with a grid inside.
The previous command should have added splashkit_example.c
to your current
directory. If you can't find it, run: cp -n /web/cs1511/24T3/activities/cs_moonlander/splashkit_example.c .
.
skm clang++ splashkit_example.c -o splashkit_example ./splashkit_example
Running your code with splashkit
The last two commands are a bit like your new dcc cs_moonlander.c -o cs_moonlander
and ./cs_moonlander
but for splashkit. So it will look a bit like:
skm clang++ cs_moonlander.c -o cs_moonlander ./cs_moonlander
Starting Points for Splashkit
Have a look inside of splashkit_example.c
to see what they have added. A
couple things to note are:
#include "splashkit.h"
is needed at the top of the file.- Line 48,
window w = open_window("Splashkit Example", 600, 400);
needs to be run when you decide to open your viewable window. - The loop in
main
allows us to update the screen according to any user events, and refreshes the screen after anything is drawn on the frame.
CS Moonlander assets
If you wish to use assets similar to the demo project run cp -rn /web/cs1511/24T3/activities/cs_moonlander/splashkit_assets .
Tools
Creating Levels in Separate Files
If you are getting sick of typing in your inputs for a level every single time you run moonlander, you might want to store your input in a separate file. This allows you to see the result of the setup phase or to play your level straight away.
1. Create a file for your input.
First, let's create a file to store in the input for a level that you have created. This isn't a .c
file, its just a regular plain text file, the file extension .in
works nicely for this!
Let's put it in the same directory as your cs_moonlander.c code.
ls cs_moonlander.c cs_moonlander my_level.in
2. Add your input to the file
Inside of this file, add the input for the level. Don't add in any of the 'wasd' movement commands as those will come from the terminal (after stage 2.2).
Your file could look a bit like this:
4 8 c 3 7 r 4 2 c 6 3 r 6 9
3. Run the code with your file
Next, instead of just running ./cs_moonlander
, lets tell the computer to first read from the file we created.
If you have completed stage 2.2 then use the following:
cat my_level.in - | ./cs_moonlander
Otherwise, use the following:
cat my_level.in | ./cs_moonlander
The dash tells your program that you want to enter more input after what's in the file, allowing you to play the level!
Community Levels
If you want to create your own levels, we encourage you to share them on edstem! Prefix it with the stage required, and post it on EdStem here !
Assessment
Assignment Conditions
Joint work is not permitted on this assignment.
This is an individual assignment.
The work you submit must be entirely your own work. Submission of any work even partly written by any other person is not permitted.
Except, you may use small amounts (< 10 lines) of general purpose code (not specific to the assignment) obtained from a site such as Stack Overflow or other publicly available resources. You should attribute clearly the source of this code in an accompanying comment.
Assignment submissions will be examined, both automatically and manually for work written by others.
Do not request help from anyone other than the teaching staff of COMP1511, e.g. in the course forum & help sessions.
Do not post your assignment code to the course forum - the teaching staff can view assignment code you have recently autotested or submitted with give.
Rationale: this assignment is designed to develop the individual skills needed to produce an entire working program. Using code written by or taken from other people will stop you learning these skills. Other CSE courses focus on the skill needed for work in a team.
The use of code-synthesis tools, such as GitHub Copilot, is not permitted on this assignment.
The use of Generative AI to generate code solutions is not permitted on this assignment.
Rationale: this assignment is intended to develop your understanding of basic concepts. Using synthesis tools will stop you learning these fundamental concepts.
Sharing, publishing, distributing your assignment work is not permitted.
Do not provide or show your assignment work to any other person other than the teaching staff of COMP1511. For example, do not message your work to friends.
Do not publish your assignment code via the internet. For example, do not place your assignment in a public GitHub repository.
Rationale: by publishing or sharing your work you are facilitating other students using your work which is not permitted. If they submit your work, you may become involved in an academic integrity investigation.
Sharing, publishing, distributing your assignment work after the completion of COMP1511 is not permitted.
For example, do not place your assignment in a public GitHub repository after COMP1511 is over.
Rationale: COMP1511 sometimes reuses assignment themes using similar concepts and content. Students in future terms find your code and use it which is not permitted and you may become involved in an academic integrity investigation.
Violation of the above conditions may result in an academic integrity investigation with possible penalties, up to and including a mark of 0 in COMP1511 and exclusion from UNSW.
Relevant scholarship authorities will be informed if students holding scholarships are involved in an incident of plagiarism or other misconduct. If you knowingly provide or show your assignment work to another person for any reason, and work derived from it is submitted you may be penalised, even if the work was submitted without your knowledge or consent. This may apply even if your work is submitted by a third party unknown to you.
Note, you will not be penalised if your work is taken without your consent or knowledge.
For more information, read the UNSW Student Code, or contact the course account. The following penalties apply to your total mark for plagiarism:
0 for the assignment | Knowingly providing your work to anyone and it is subsequently submitted (by anyone). |
0 for the assignment | Submitting any other person's work. This includes joint work. |
0 FL for COMP1511 | Paying another person to complete work. Submitting another person's work without their consent. |
Submission of Work
You should submit intermediate versions of your assignment. Every time you autotest or submit, a copy will be saved as a backup. You can find those backups here, by logging in, and choosing the yellow button next to 'cs_moonlander.c'.
Every time you work on the assignment and make some progress you
should copy your work to your CSE account and submit it using the give
command below.
It is fine if intermediate versions do not compile or otherwise fail submission tests.
Only the final submitted version of your assignment will be marked.
You submit your work like this:
give cs1511 ass1_cs_moonlander cs_moonlander.c
Assessment Scheme
This assignment will contribute 20% to your final mark.
80% of the marks for this assignment will be based on the performance
of the code you write in cs_moonlander.c
20% of the marks for this assignment will come from manual marking of the readability of the C you have written. The manual marking will involve checking your code for clarity, and readability, which includes the use of functions and efficient use of loops and if statements.
Marks for your performance will be allocated roughly according to the below scheme.
100% for Performance | Completely Working Implementation, which exactly follows the spec (Stage 1, 2, 3 and 4). |
85% for Performance | Completely working implementation of Stage 1, 2 and 3. |
65% for Performance | Completely working implementation of Stage 1 and Stage 2. |
35% for Performance | Completely working implementation of Stage 1. |
The Challenge stage of the assignment is NOT worth any marks, but is something fun for you to work on getting to know a new library and building something more visual!
Style Marking Rubric
0 | 1 | 2 | 3 | 4 | |
Formatting (/5) | |||||
Indentation (/2) - Should use a consistent indentation scheme. | Multiple instances throughout code of inconsistent/bad indentation | Code is mostly correctly indented | Code is consistently indented throughout the program | ||
Whitespace (/1) - Should use consistent whitespace (for example, 3 + 3 not 3+ 3) | Many whitespace errors | No whitespace errors | |||
Vertical Whitespace (/1) - Should use consistent whitespace (for example, vertical whitespace between sections of code) | Code has no consideration for use of vertical whitespace | Code consistently uses reasonable vertical whitespace | |||
Line Length (/1) - Lines should be max. 80 characters long | Many lines over 80 characters | No lines over 80 characters | |||
Documentation (/5) | |||||
Comments (incl. header comment) (/3) - Comments have been used throughout the code above code sections and functions to explain their purpose. A header comment (with name, zID and a program description) has been included | No comments provided throughout code | Few comments provided throughout code | Comments are provided as needed, but some details or explanations may be missing causing the code to be difficult to follow | Comments have been used throughout the code above code sections and functions to explain their purpose. A header comment (with name, zID and a program description) has been included | |
Function/variable/constant naming (/2) - Functions/variables/constants names all follow naming conventions in style guide and help in understanding the code | Functions/variables/constants names do not follow naming conventions in style guide and help in understanding the code | Functions/variables/constants names somewhat follow naming conventions in style guide and help in understanding the code | Functions/variables/constants names all follow naming conventions in style guide and help in understanding the code | ||
Organisation (/5) | |||||
Function Usage (/4) - Code has been decomposed into appropriate functions separating functionalities | No functions are present, code is one main function | Some code has been moved to functions | Some code has been moved to sensible/thought out functions, and/or many functions exceed 50 lines (incl. main function) | Most code has been moved to sensible/thought out functions, and/or some functions exceed 50 lines (incl. main function) | All code has been meaningfully decomposed into functions of a maximum of 50 lines (incl. The main function) |
Function Prototypes (/1) - Function Prototypes have been used to declare functions above main | Functions are used but have not been prototyped | All functions have a prototype above the main function or no functions are used | |||
Elegance (/5) | |||||
Overdeep nesting (/2) - You should not have too many levels of nesting in your code (nesting which is 5 or more levels deep) | Many instances of overdeep nesting | <= 3 instances of overdeep nesting | No instances of overdeep nesting | ||
Code Repetition (/2) - Potential repetition of code has been dealt with via the use of functions or loops | Many instances of repeated code sections | <= 3 instances of repeated code sections | Potential repetition of code has been dealt with via the use of functions or loops | ||
Constant Usage (/1) - Any magic numbers are #defined | None of the constants used throughout program are #defined | All constants used are #defined and are used consistently in the code | |||
Illegal elements | |||||
Illegal elements - Presence of any illegal elements indicated in the style guide | CAP MARK AT 16/20 |
Allowed C Features
In this assignment, there are no restrictions on C Features, except for those in the style guide. If you choose to disregard this advice, you must still follow the style guide.
You also may be unable to get help from course staff if you use features not taught in COMP1511. Features that the Style Guide identifies as illegal will result in a penalty during marking. You can find the style marking rubric above.
Due Date
This assignment is due 21 October 2024 17:00:00. For each day after that time, the maximum mark it can achieve will be reduced by 5% (off the ceiling).- For instance, at 1 day past the due date, the maximum mark you can get is 95%.
- For instance, at 3 days past the due date, the maximum mark you can get is 85%.
- For instance, at 5 days past the due date, the maximum mark you can get is 75%. No submissions will be accepted after 5 days late, unless you have special provisions in place.
-
Version 1.0
(2024-09-30 13:00) -
- Assignment Released
-
Version 1.1
(2024-09-30 19:12) -
- Updated clarification for stage 1.2
-
Version 1.2
(2024-10-04 21:40) -
- Added function prototypes for print_player_stats and print_board_header to the starter code.
-
Version 1.3
(2024-10-15 23:40) -
- Corrected player cheese input in 3.2.2 example.
-
Version 1.4
(2024-10-15 23:00) -
- Add note about behaviour for ending command loop in 3.1.