CS Chicken
Overview
CS Chicken re-imagines the popular mobile game Crossy Road, where the player will try to collect coins while avoiding cars. This historic arcade game can be played here (all trademarks are the property of their respective owners).
We will set up the board, then move on to core playability, and in the final stages, finish with more complex mechanics.
Getting Started
- Create a new folder for your assignment:
mkdir ass1 cd ass1
- Fetch the starter code using the command below.
1511 fetch-activity cs_chicken
You should now have a file named cs_chicken.c in your ass1 directory.
- Check that everything works by running the autotest:
1511 autotest cs_chicken
If you want to stop running the autotest before it finishes, press [Ctrl-C].
Program Structure
This is a summary of the program structure. It's included as an introduction to aid your overall understanding of the assignment. Detailed instructions will be included in later sections of the specification.
The program consists of two phases: a Setup Phase, and a Gameplay Phase.
Setup Phase
When the program starts, the Setup Phase begins, and a new game is created:
- An empty game board is initialised.
- The player's starting position is set.
- Features (trees, roads, boulders, cars, kangaroos, wombat tunnels) are added to the board.
Gameplay Phase
When the Setup Phase is complete, the Gameplay Phase begins. In this phase, the player can:
- Walk up the board.
- Collect coins to get points.
- Dodge cars.
- Use kangaroos to jump around.
- Rest in wombat tunnels.
The Gameplay Phase is organised as a series of rounds. Each round begins with a Player Turn, followed by a Car Turn, and then an Other Mechanics Turn. Understanding this sequence will help you interpret the assignment specification and help guide how your program should behave.
Reference Implementation
To help you understand the game, we've written a complete reference implementation which you can run in any CSE terminal with the command 1511 cs_chicken. It implements every stage of the assignment. You can use this to test how your program should behave.
Try the following input in the reference implementation:
1511 cs_chicken 5 5 t 6 3 r 5 v 5 7 r s w w w w s
These inputs will:
- Spawn the player at board position
[5][5]. - Add a tree at
[6][3], a road on row[5], and a car on the road at[5][7], facing in the direction[r](right). - Start the game with
[s](scrolling mode). - Move the player around the board.
You don't need to fully understand these inputs yet; they're only provided as a preview.
Starter Code and Data Structures
Starter code has been provided to help you get up and running. It contains a range of useful constants, structs, enums, and functions.
If you haven't done so already, test the 1511 cs_chicken reference solution, then open the provided cs_chicken.c and follow along with this introduction.
The main() Function
A sample main() function has been provided to get you started.
int main(void) {
print_welcome();
struct tile board[ROWS][COLS];
initialise_board(board);
print_board(board, INVALID_ROW, INVALID_COL, INITIAL_POINTS,
DEFAULT_POINT_TARGET);
return 0;
}
Printing a Welcome Message
The first statement prints a welcome message followed by a blank line:
void print_welcome(void) {
printf(
"_________________________________________ \n"
" \\\\ \\\\ \n"
" (o> !! Welcome to !! (o> \n"
"\\\\_//) CS CHICKEN \\\\_//) \n"
" \\_/_) \\_/_) \n"
" _|_ _|_ \n"
"_________________________________________ \n\n");
}
Declaring the board Array
The next statement declares the game board.
struct tile board[ROWS][COLS];
This means that board is a two-dimensional ROWS-by-COLS array, where each element is a struct tile.
struct tile {
enum entity entity;
};
Each struct tile currently contains one member, an enum entity. This allows each element of the board array to store a game feature (for example, a coin, tree, or car).
enum entity {
EMPTY,
COIN,
TREE,
ROAD,
CAR_FACING_RIGHT,
CAR_FACING_LEFT,
HEADLIGHTS,
KANGAROO,
WOMBAT_TUNNEL,
BABY_CHICKEN
};
Each entity corresponds to a feature and a symbol that appears when the board is printed to the terminal:
| Feature | Entity | Symbol |
|---|---|---|
| Empty | EMPTY |
|
| Coin | COIN |
c |
| Tree | TREE |
T |
| Road | ROAD |
___ |
| Car | CAR_FACING_RIGHT |
[_0 |
| Car | CAR_FACING_LEFT |
0_] |
| Headlights | HEADLIGHTS |
### |
| Kangaroo | KANGAROO |
_b^ |
| Wombat Tunnel | WOMBAT_TUNNEL |
(1) |
| Baby Chicken (Default) | BABY_CHICKEN |
^.^ |
| Baby Chicken (Shocked) | BABY_CHICKEN_SHOCKED |
o.o |
Using the board Array
We can use row and column indexes to access board elements.
For example:
board[1][2]accesses thestruct tileat row 1 and column 2.board[1][2].entityaccesses theenum entityof thisstruct tile.
Similarly:
board[6][7]accesses thestruct tileat row 6 and column 7.board[6][7].entityaccesses theenum entityof thisstruct tile.
Figure 1 demonstrates how row and column indexes can be used to access elements on the game board.
Initialising the board Array
At this point, we have a board array, but it hasn't been initialised with any values. The next statement passes the newly-declared board array to the provided initialise_board() function. This gives every tile entity an initial value of EMPTY:
initialise_board(board);
Printing the Game
Before exiting, main() prints the board in the terminal:
+---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 10
It does this with the provided print_board() function.
void print_board(
struct tile board[ROWS][COLS],
int player_row,
int player_col,
int curr_score,
int target_score
);
The print_board() function takes the following arguments:
- The
boardarray. - The row position of the player. Since the player has not yet been placed on the board, we use the
#definedconstantINVALID_ROW. - The column position of the player. Since the player has not yet been placed on the board, we use the
#definedconstantINVALID_COL. - The current number of points. Since the game has not started, we use the
#definedconstantINITIAL_POINTS. - The number of points needed to win the game. By default, we use the
#definedDEFAULT_POINT_TARGET.
You will need to know how to use print_board() with different values. For example:
print_board(board, 2, 9, 1, 11)displays the board with the player at the row 2, column 9 with 1 point while the target number of points is 11.print_board(board, 0, 5, 8, 20)displays the board with the player at the row 0, column 5 with 8 points while the target number of points is 20.
print_board() checks the enum entity of each struct tile to determine which feature to print. You don't need to understand how it works before starting the assignment.
Other Provided Functions
There are five more provided functions:
print_board_line()is a helper function called byprint_board(). You will not need to use it in your code.print_board_header()is a helper function called byprint_board(). You will not need to use it in your code.print_game_statistics()is a helper function to help you print statistics in Stage 2.3. You will need to use it in your code.print_game_won()is a helper function to print a win message for Stage 2.4. You will need to use it in your code.print_game_lost()is a helper function to print a loss message for Stage 3.1. You will need to use it in your code.
FAQ
Q: Can I edit the provided code?
Yes! Feel free to modify/replace/discard any of the provided:
#defineconstants,- enums,
- structs, and
- functions.
For example, you may wish to add fields to the provided struct tile definition.
You are also encouraged to create your own constants, enums, structs, and helper functions.
Q: Can I use pointers?
Yes! You can use pointers. Although, they're not required. It's possible to complete every stage of the assignment without using pointers.
Q: Can I use X other C feature?
For everything not taught in the course, check the Style Guide:
- If the guide says "avoid", it may incur a style mark penalty if not used correctly.
- If the guide says "illegal" or "do not use", it will result in a style mark penalty (see the Style Marking Rubric).
These rules exist to ensure that everyone develops the required foundational knowledge and to maintain a level playing field for all students.
Stages
The assignment has been divided into incremental stages.
Stage 1: Setup Phase
- Stage 1.1 - Spawn Player.
- Stage 1.2 - Validate PLayer Spawn.
- Stage 1.3 - Add Simple Features.
- Stage 1.4 - Add Harder Features.
- Stage 1.5 - Validate Feature Spawns.
Stage 2: Gameplay Phase (Player Turn)
- Stage 2.1 - Player Movement.
- Stage 2.2 - Validate Player Movement.
- Stage 2.3 - Collect Coins and Print Statistics.
- Stage 2.4 - Winning The Game.
Stage 3: Gameplay Phase (Car Turn + Scroll Mechanics)
- Stage 3.1 - Losing the Game
- Stage 3.2 - Driving Game Mode.
- Stage 3.3 - Scrolling Game Mode.
- Stage 3.4 - Wombat Tunnels.
Stage 4: Gameplay Phase (Extra Mechanics)
- Stage 4.1 - Riding Kangaroos.
- Stage 4.2 - Opening a Daycare.
Extension (not for marks)
- SplashKit - Create and Share 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 implement the Setup Phase of CS Chicken. This milestone has been divided into five substages:
- Stage 1.1 - Spawn Player.
- Stage 1.2 - Validate Player Spawn.
- Stage 1.3 - Add Simple Features.
- Stage 1.4 - Add Harder Features.
- Stage 1.5 - Validate Feature Spawns.
By the end of this stage the board will be set up and ready for gameplay!
Stage 1.1 - Spawn Player
Task
The first step of the Setup Phase is to spawn Penny the Chicken. By the end of this substage your program will prompt the user for Penny the Chicken's starting position, and then display Penny the Chicken on the game board.
The starter code:
- Prints the welcome banner.
- Declares the
boardarray. - Initialises the
boardarray toEMPTY. - Prints the
boardwithout showing Penny the Chicken.
A description of the starter code can be found in Starter Code and Data Structures.
Description
In this substage, you will modify the starter code to:
-
Print a heading indicating the start of the Setup Phase:
"============== Setup Phase ==============\n". -
Prompt the user:
"Enter the starting position: ". -
Scan in two integers
[row] [col]as Penny the Chicken's starting position. -
Use the provided
print_board()function to display the game board with Penny the Chicken's position and the current points (Penny the Chicken begins with0points). -
Exit the program by returning
0frommain().
For example, if the starting position entered is (5, 6), Penny the Chicken should appear on the board like so:
Examples
Input:
5 6
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 5 6 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |^_^| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20
Assumptions / Restrictions / Clarifications
When your code is tested in this substage:
- Only valid array indexes will be used. No out-of-bounds values will be entered for
roworcol.
For this substage and all future substages:
- The
[row]and[col]entered will always be integers.
Autotest
Stage 1.2 - Validate Player Spawn
Task
In the previous substage, your program allowed Penny the Chicken to spawn anywhere on the game board. But what happens if the user attempts to spawn Penny the Chicken outside of the board boundaries?
Give it a try! Test your program with row and column inputs such as 8 15, or -1 6. Should the program allow this?
Description
In this substage, you will modify your Stage 1.1 implementation to handle invalid inputs:
- A valid spawn position is one that is within the board boundaries.
- An invalid spawn position is one that is outside the board boundaries.
You will need to:
- Create a loop to repeatedly prompt the user for Penny the Chicken's starting position until a valid position is entered.
- If the position entered is invalid:
- Print
"Penny the Chicken cannot start here!\n". - Prompt the user for another starting position.
- Print
- Otherwise, if the position is valid:
- End the loop.
- Use the provided
print_board()function to display the board. - Exit the program by returning
0from themain()function.
Examples
Input:
0 -1 8 15 -1 6 3 4
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 0 -1 Penny the Chicken cannot start here! Enter the starting position: 8 15 Penny the Chicken cannot start here! Enter the starting position: -1 6 Penny the Chicken cannot start here! Enter the starting position: 3 4 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20
Autotest
Stage 1.3 - Add Simple Features
Task
In the previous substage, your program spawned Penny the Chicken on the board and checked that the position of Penny the Chicken was within the bounds of the board. In this substage, the program should now continue with the Setup Phase by adding features (entities) such as coins and trees to the board.
Commands
c [row] [col]
t [row] [col]
Description
In this substage, you will extend your program to:
- Prompt the user:
"Enter setup commands:\n". - Implement a Setup Loop to repeatedly read-in commands and add features to the board until
[CTRL+D]is pressed:- Given the command
c [row] [col], add aCOINto that tile. - Given the command
t [row] [col], add aTREEto that tile.
- Given the command
- When the user enters
[CTRL+D]:- The Setup Loop should end.
- The board should be displayed with the provided
print_board()function. - The program should exit.
For example, if:
- the starting position entered is
(9, 3), - coins are added at position
(1, 6)and(9, 9), and - and a tree is added at position
(3, 2),
the board should appear as follows:
Examples
Input:
3 4 t 9 9 [CTRL+D]
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 3 4 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: t 9 9 [CTRL+D] +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | T | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20
Input:
3 4 c 1 4 t 2 1 t 7 7 c 9 0 [CTRL+D]
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 3 4 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: c 1 4 t 2 1 t 7 7 c 9 0 [CTRL+D] +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | c | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | T | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | T | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | c | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20
Assumptions / Restrictions / Clarifications
When your code is tested in this substage:
- All features will be placed within the map boundaries.
- No feature will be placed at the same location as another feature.
- No feature will be placed on the same tile as Penny the Chicken.
For this substage and all future substages:
- Invalid commands will not be tested. For example, a command
Zwill never be entered. - Incomplete commands will not be tested. For example, when a
cis entered, it will always be followed by a[row]and[col]. - Commands will always be given arguments of the correct type. For example,
[row]and[col]will always be integers.
Autotest
Stage 1.4 - Add Harder Features
Task
You have created the Setup Loop and it supports simple features. In this substage, the Setup Phase should extend to support more complicated features (entities) such as adding roads and cars to the board.
Commands
r [row]
v [row] [col] [direction]
Description
In this substage, you will extend your Setup Loop to handle two new commands:
- Given the command
r [row], add aROADto every tile in that row. - Given the command
v [row] [col] [direction], add aCARto that tile with the correspondingdirection. In addition to the car, the tile adjacent to the car in the direction it is facing should now be aHEADLIGHTSentity.- Cars given the direction
rare the entityCAR_FACING_RIGHT, and the tile to its right should be aHEADLIGHTSentity. - Cars given the direction
lare the entityCAR_FACING_LEFT, and the tile to its left should be aHEADLIGHTSentity.
- Cars given the direction
Consistent with the previous stage, when the user enters [CTRL+D]:
- The Setup Loop should end.
- The board should be displayed with the provided
print_board()function. - The program should exit.
For example, if:
- the starting position entered is
(2, 8), - roads are added in rows
3and8, - a right-facing car is added at
(3, 3), and - a left-facing car is added at
(3, 8),
the board should appear as follows:
Examples
Input:
3 4 r 8 [CTRL+D]
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 3 4 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: r 8 [CTRL+D] +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20
Input:
3 4 r 2 v 2 7 l [CTRL+D]
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 3 4 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: r 2 v 2 7 l [CTRL+D] +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|###|0_]|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20
Assumptions / Restrictions / Clarifications
When your code is tested in this substage:
- All features will be placed within the map boundaries.
- You may assume that cars will not be placed in such a way that their headlights are out of bounds.
- Cars will only be placed on roads or headlights.
- No feature will be placed on the same tile as Penny the Chicken.
Autotest
Stage 1.5 - Validate Feature Spawns
During the previous substages, your program added features to the board. However, much like checking that Penny the Chicken's location is valid, how should the program handle placing a feature in an invalid position?
Task
In this substage, you will update your implementation of Stage 1.3 and 1.4 to ensure that features are only added in valid locations.
A tile is occupied if any of the following are true:
- Penny the Chicken is located at the same position as the tile.
- The tile's entity member is not
EMPTY.
Now apply these new rules to your setup phase:
- If the user attempts to place a
COINor aTREEon an occupied tile:- Print
"Invalid location: tile is occupied!\n". - Continue reading the next command without adding the feature.
- Print
- If the user attempts to place a feature in a position that's not on the board:
- Print
"Invalid location: position is not on map!\n". - Continue reading the next command without adding the feature.
- Print
- If the user attempts to place a
ROADand it overlaps with at least oneTREEfeature and nothing else other thanEMPTY:- Print
"Deforesting.\n"once. - Add the feature and then continue reading the next command.
- Print
- If the user attempts to place a
ROADand it overlaps with anything other thanTREEfeatures:- Print
"Invalid location: road cannot be built.\n". - Continue reading the next command without adding the feature.
- Print
- If the user attempts to place a
CARon a tile that isn't aROADorHEADLIGHTS:- Print
"Invalid location: car must be on a road.\n". - Continue reading the next command without adding the feature.
- Print
Examples
Input:
3 4 t 4 -3 c -1 190 r -5 v 1 -1 l [CTRL+D]
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 3 4 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: t 4 -3 Invalid location: position is not on map! c -1 190 Invalid location: position is not on map! r -5 Invalid location: position is not on map! v 1 -1 l Invalid location: position is not on map! [CTRL+D] +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20
Input:
3 4 t 6 7 c 6 7 t 3 4 [CTRL+D]
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 3 4 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: t 6 7 c 6 7 Invalid location: tile is occupied! t 3 4 Invalid location: tile is occupied! [CTRL+D] +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | T | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20
Input:
3 4 r 4 v 3 4 r v 3 4 l [CTRL+D]
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 3 4 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: r 4 v 3 4 r Invalid location: car must be on a road. v 3 4 l Invalid location: car must be on a road. [CTRL+D] +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20
Assumptions / Restrictions / Clarifications
- At most, only one error message should be printed for each command. If multiple messages need to be printed, print the first one in the order of the rules mentioned above.
- It is valid for cars to be placed on
HEADLIGHTS. If a car is being placed onHEADLIGHTS, the tile’s entity should be replaced withCAR_FACING_LEFTorCAR_FACING_RIGHT. - If a
CAR_FACING_RIGHTis placed on a tile adjacent and to the left of aCAR_FACING_LEFT([_00_]), neither car will haveHEADLIGHTS.
Autotest
Testing & 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-stagecommand 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_chicken.c 1511 autotest-stage 01 cs_chicken give cs1511 ass1_cs_chicken cs_chicken.c
Stage 2
In Stage 2, you will begin implementing the Gameplay Phase of CS Chicken. This milestone has been divided into four substages:
- Stage 2.1 - Player Movement.
- Stage 2.2 - Validate Player Movement.
- Stage 2.3 - Collect Coins and Print Statistics.
- Stage 2.4 - Winning The Game.
The focus of these substages is to implement Penny the Chicken's turn of the Gameplay Phase. The Car Turn and Other Mechanics Turn will be introduced in Stages 3 and 4.
By the end of this stage, your program will have grown into a partially complete, yet entirely playable, version of the game. Let's hit the road !
Stage 2.1 - Player Movement
What use is CS Chicken if Penny the Chicken cannot cross the road? The first step of the Gameplay Phase is to introduce player movements. By the end of this substage, your program will allow Penny the Chicken to move around the game board.
Task
In this substage you will implement the following commands:
e- to end Setup Phase.q- to quit the Gameplay Phase.w- to move Penny the Chicken up.a- to move Penny the Chicken left.s- to move Penny the Chicken down.d- to move Penny the Chicken right.R- to end Penny the Chicken's turn without moving.
Description
In this substage, you will need to:
-
Start the Gameplay Phase:
- Currently, the Setup Loop from Stage 1.3 ends when the user enters
[CTRL+D]. Modify the Setup Loop to end when the user entersefor "end setup". - Once
eis pressed:- Print the game board using the provided
print_board()function. - Print
"============ Gameplay Phase =============\n". This indicates that the Setup Phase is complete, and the user can now start playing the game. - For future reference, exiting with
ewill enter the Static Game Mode. Stages 3.2 and Stage 3.3 will implement different exit commands to initiate different game modes.
- Print the game board using the provided
- Currently, the Setup Loop from Stage 1.3 ends when the user enters
-
Create a Gameplay Loop to repeatedly read-in and handle user commands:
- The first command to add to the Gameplay Loop is
qto quit the game. - When the
qcommand is entered by the user, the program should immediately:- Print
"============= Quitting Game =============\n". - Exit the program immediately, with no further output.
- Print
- The first command to add to the Gameplay Loop is
-
Begin the Player Turn in the Gameplay Loop:
- The next Gameplay Loop commands are player movements:
wmoves Penny the Chicken up.amoves Penny the Chicken left.smoves Penny the Chicken down.dmoves Penny the Chicken right.
- The Gameplay Loop should also handle a rest command:
Rends Penny the Chicken's turn without moving Penny the Chicken.
- The next Gameplay Loop commands are player movements:
-
End the Player Turn:
- After Penny the Chicken's movement, Penny the Chicken's turn ends.
- Display the board with the provided
print_board()function. This completes the round. - Reminder: this is a Gameplay Loop. After each command is processed/handled, the program should continue to read and handle the next user command until
qis pressed.
Examples
Input:
0 0 e q
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 0 0 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ |^_^| | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: e +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ |^_^| | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 ============ Gameplay Phase ============= q ============= Quitting Game =============
Input:
0 5 e s s q
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 0 5 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^_^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: e +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^_^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 ============ Gameplay Phase ============= s +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^_^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 s +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^_^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 q ============= Quitting Game =============
Input:
8 8 e d s a R R w q
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 8 8 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |^_^| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: e +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |^_^| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 ============ Gameplay Phase ============= d +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | |^_^| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 s +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | |^_^| +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 a +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |^_^| | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 R +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |^_^| | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 R +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |^_^| | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |^_^| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 q ============= Quitting Game =============
Assumptions / Restrictions / Clarifications
For this substage:
- No movement command will attempt to move Penny the Chicken off the board.
- No movement command will attempt to move Penny the Chicken onto any feature added in Stage 1, such as roads.
For this substage and all future substages up to (and including) Stage 3.2:
- No movement command will result in Penny the Chicken moving onto a tile with entity
CAR_FACING_LEFTorCAR_FACING_RIGHT. This case will be handled in Stage 3.2.
Autotest
Stage 2.2 - Validate Player Movement
In the previous substage, your program allowed the user to control Penny the Chicken’s movements. But what should happen if Penny the Chicken tries to move into a tree or off the edge of the board?
Task
In this substage, you will modify your implementation of Stage 2.1 to handle attempts to move Penny the Chicken to an invalid destination.
Description
For the purpose of this substage, a destination is considered invalid if it meets any of the following conditions:
- The tile is a position that is not on the board.
- The tile contains a
TREE.
If Penny the Chicken attempts to move to an invalid destination:
- Penny the Chicken should not move.
- End Penny the Chicken's turn and call
print_board(). - Wait for the user's next command, continuing the Gameplay Loop.
Otherwise, move Penny the Chicken as defined in Stage 2.1.
Examples
Input:
0 0 t 0 1 e d s q
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 0 0 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ |^_^| | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: t 0 1 e +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ |^_^| T | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 ============ Gameplay Phase ============= d +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ |^_^| T | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 s +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | T | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |^_^| | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 q ============= Quitting Game =============
Input:
8 8 e d d s s q
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 8 8 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |^_^| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: e +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |^_^| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 ============ Gameplay Phase ============= d +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | |^_^| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 d +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | |^_^| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 s +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | |^_^| +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 s +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | |^_^| +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 q ============= Quitting Game =============
Input:
0 4 r 1 r 2 e s s s q
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 0 4 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: r 1 r 2 e +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 ============ Gameplay Phase ============= s +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|^_^|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 s +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|^_^|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 s +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 q ============= Quitting Game =============
Assumptions / Restrictions / Clarifications
When your code is tested in this substage:
- No movement command will result in Penny the Chicken moving onto a tile with entity
COIN,CAR_FACING_LEFT,CAR_FACING_RIGHTorHEADLIGHTS. These will be implemented in Stage 2.3 and Stage 3.1.
Autotest
Stage 2.3 - Collect Coins and Print Statistics
In the previous substage, your program prevented Penny the Chicken from moving onto trees and from stepping off the board.
Task
By the end of this substage, Penny the Chicken will be able to collect coins and gain points!
Commands
c
p
Description
Coin Collection
Implement the Coin Collection mechanic to collect coins from the board. If Penny the Chicken moves onto a tile with the entity COIN:
- Remove the
COINfrom the tile by setting the entity toEMPTY. - Add 5 points to Penny the Chicken's points.
- Penny the Chicken's points should be displayed on the board by passing it in as an argument to
print_board()at the end of Penny the Chicken's turn.
Statistics
Modify the Gameplay Loop to handle a new p command that prints Penny the Chicken's statistics. Your program will need to calculate and print:
- The total number of Player Turns so far.
- The total number of steps taken.
- The total number of coins collected.
- Penny the Chicken's current points.
You should call the provided helper function print_game_statistics() with the values you calculated to display this information.
Examples
Input:
5 5 c 5 7 c 6 7 e d d s s q
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 5 5 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^_^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: c 5 7 c 6 7 e +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^_^| | c | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | c | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 ============ Gameplay Phase ============= d +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |^_^| c | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | c | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 d +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |^_^| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | c | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 5 Target: 20 s +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |^_^| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 10 Target: 20 s +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |^_^| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 10 Target: 20 q ============= Quitting Game =============
Input:
3 3 e s s r p q
Input and Output:
dcc cs_chicken.c -o cs_chicken
./cs_chicken
_________________________________________
\\ \\
(o> !! Welcome to !! (o>
\\_//) CS CHICKEN \\_//)
\_/_) \_/_)
_|_ _|_
_________________________________________
============== Setup Phase ==============
Enter the starting position: 3 3
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | |^_^| | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
Enter setup commands:
e
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | |^_^| | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
============ Gameplay Phase =============
s
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | |^_^| | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
s
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | |^_^| | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
r
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | |^_^| | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
p
============ Game Statistics ============
Turns taken: 3
Step count: 2
Coins Collected: 0
Score: 0
q
============= Quitting Game =============
Input:
3 3 c 4 3 e s s s p q
Input and Output:
dcc cs_chicken.c -o cs_chicken
./cs_chicken
_________________________________________
\\ \\
(o> !! Welcome to !! (o>
\\_//) CS CHICKEN \\_//)
\_/_) \_/_)
_|_ _|_
_________________________________________
============== Setup Phase ==============
Enter the starting position: 3 3
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | |^_^| | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
Enter setup commands:
c 4 3
e
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | |^_^| | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | c | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
============ Gameplay Phase =============
s
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | |^_^| | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 5 Target: 20
s
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | |^_^| | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 5 Target: 20
s
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | |^_^| | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 5 Target: 20
p
============ Game Statistics ============
Turns taken: 3
Step count: 3
Coins Collected: 1
Score: 5
q
============= Quitting Game =============
Input:
5 5 t 5 7 e d d d d p q
Input and Output:
dcc cs_chicken.c -o cs_chicken
./cs_chicken
_________________________________________
\\ \\
(o> !! Welcome to !! (o>
\\_//) CS CHICKEN \\_//)
\_/_) \_/_)
_|_ _|_
_________________________________________
============== Setup Phase ==============
Enter the starting position: 5 5
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | |^_^| | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
Enter setup commands:
t 5 7
e
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | |^_^| | T | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
============ Gameplay Phase =============
d
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | |^_^| T | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
d
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | |^_^| T | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
d
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | |^_^| T | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
d
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | |^_^| T | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
p
============ Game Statistics ============
Turns taken: 4
Step count: 1
Coins Collected: 0
Score: 0
q
============= Quitting Game =============
Assumptions / Restrictions / Clarifications
- Collecting more than 3 coins will not be tested until Stage 2.4 when the winning condition is added.
- The
pcommand does not count as a Player Turn, meaning the board should not be printed after the user entersp.
When your code is tested in this substage:
- The total number of steps taken only counts successful moves made using
w,a,s, ord.- If a rest move (
R) is made, the steps taken do not increase. - If a move is blocked or invalid and Penny the Chicken stays on the same tile, the steps taken do not increase.
- If a rest move (
- No movement command will result in Penny the Chicken moving onto a tile with entity
CAR_FACING_LEFTorCAR_FACING_RIGHTorHEADLIGHTS. This will be implemented in Stage 3.1.
Autotest
Stage 2.4 - Winning the Game
Throughout the last three substages, you introduced foundational elements of the Gameplay Loop. Now it’s time for the fun part: winning the game!
Task
By the end of this stage, the game should support a Game Win mechanic that allows Penny the Chicken to complete the game.
Description
Win Mechanics
The Game Win mechanic should occur immediately after Penny the Chicken's Player Turn, but before printing the board for that round. If Penny the Chicken reaches the target amount of points, the game is won. The default target is 20 points.
When the game is won, the program should immediately:
- Display the board using the provided
print_board()function. - Display Penny the Chicken's performance data using the provided
print_game_statistics()function. - Display the “Win” message by calling the provided
print_game_won()function. - End the program immediately with no further output.
Customising Target Points
x [points]
Modify the Setup Loop from Stage 1.3 to allow changing the target points before gameplay begins with the command x [points]. This command should set the target points required to win the game.
If [points] is less than 1 or greater than 99, the input is invalid and the target should not be changed. Instead the program should print:
"Target must be between 1 and 99 inclusive.\n".
Examples
Input:
5 5 c 5 6 c 5 7 c 6 7 c 6 8 e d d s d
Input and Output:
dcc cs_chicken.c -o cs_chicken
./cs_chicken
_________________________________________
\\ \\
(o> !! Welcome to !! (o>
\\_//) CS CHICKEN \\_//)
\_/_) \_/_)
_|_ _|_
_________________________________________
============== Setup Phase ==============
Enter the starting position: 5 5
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | |^_^| | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
Enter setup commands:
c 5 6
c 5 7
c 6 7
c 6 8
e
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | |^_^| c | c | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | c | c | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
============ Gameplay Phase =============
d
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | |^_^| c | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | c | c | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 5 Target: 20
d
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | |^_^| | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | c | c | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 10 Target: 20
s
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | |^_^| c | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 15 Target: 20
d
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | |^_^| |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 20 Target: 20
============ Game Statistics ============
Turns taken: 4
Step count: 4
Coins Collected: 4
Score: 20
_________________________________________
Penny the Chicken is happy!
\\ \\
(o> !! Thank you !! (o>
\\_//) for playing! \\_//)
\_/_) \_/_)
_|_ _|_
_________________________________________
Input:
2 2 x 15 c 3 2 c 4 2 c 4 3 e s s d
Input and Output:
dcc cs_chicken.c -o cs_chicken
./cs_chicken
_________________________________________
\\ \\
(o> !! Welcome to !! (o>
\\_//) CS CHICKEN \\_//)
\_/_) \_/_)
_|_ _|_
_________________________________________
============== Setup Phase ==============
Enter the starting position: 2 2
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | |^_^| | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
Enter setup commands:
x 15
c 3 2
c 4 2
c 4 3
e
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | |^_^| | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | c | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | c | c | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 15
============ Gameplay Phase =============
s
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | |^_^| | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | c | c | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 5 Target: 15
s
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | |^_^| c | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 10 Target: 15
d
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | |^_^| | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 15 Target: 15
============ Game Statistics ============
Turns taken: 3
Step count: 3
Coins Collected: 3
Score: 15
_________________________________________
Penny the Chicken is happy!
\\ \\
(o> !! Thank you !! (o>
\\_//) for playing! \\_//)
\_/_) \_/_)
_|_ _|_
_________________________________________
Autotest
Assumptions / Restrictions / Clarifications
- If the game is won by exceeding the target points, the game statistics should print the player’s final score, even if it is greater than the target score.
- You may assume
[points]will always be a valid integer. - The default target is 20 points. When your code is tested in this substage:
- No movement command will result in Penny the Chicken moving onto a tile with entity
CAR_FACING_LEFTorCAR_FACING_RIGHTorHEADLIGHTS. This will be implemented in Stage 3.1.
Testing & 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-stagecommand 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_chicken.c 1511 autotest-stage 02 cs_chicken give cs1511 ass1_cs_chicken cs_chicken.c
Stage 3
In Stage 3, you will continue implementing the Gameplay Phase of CS Chicken. This milestone has been divided into four substages:
- Stage 3.1 - Losing the Game
- Stage 3.2 - Driving Game Mode.
- Stage 3.3 - Scrolling Game Mode.
- Stage 3.4 - Wombat Tunnels.
This time, we are extending the Gameplay Phase by adding the Car Turn and Other Mechanics Turn.
You're about to bring CS Chicken to life! By the end of this stage, the game will be fully functional and ready to play. The foundations will be laid for even more features down the road.
Stage 3.1 - Losing the Game and Headlights
By the end of this substage, it will be possible to lose the game. Remember, road safety is important!
Task
At the end of this substage, if Penny the Chicken steps onto a HEADLIGHTS tile, they should enter a shocked chicken state.
From there, the game should handle collision detection between the Penny the Chicken and cars. If a collision occurs, Penny the Chicken immediately loses the game.
Description
Penny the Chicken can now move onto tiles containing HEADLIGHTS. When this occurs, they should be displayed as 0_0.
After Penny the Chicken's turn the program should check for collisions, which is when Penny the Chicken is on the same tile as a car (CAR_FACING_LEFT or CAR_FACING_RIGHT).
When there is a collision, the game is lost and the program should immediately:
- Display the board with the provided function,
print_board(). Here, Penny the Chicken should be displayed as0_0. - Display Penny the Chicken's performance data using the provided function,
print_game_statistics(). - Display the 'game lost' message by calling the provided function,
print_game_lost(). - Exit the game immediately, ending the program with no further output.
Examples
Input:
5 3 r 4 v 4 4 l e w d
Input and Output:
dcc cs_chicken.c -o cs_chicken
./cs_chicken
_________________________________________
\\ \\
(o> !! Welcome to !! (o>
\\_//) CS CHICKEN \\_//)
\_/_) \_/_)
_|_ _|_
_________________________________________
============== Setup Phase ==============
Enter the starting position: 5 3
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | |^_^| | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
Enter setup commands:
r 4
v 4 4 l
e
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
|___|___|___|###|0_]|___|___|___|___|___|
+---+---+---+---+---+---+---+---+---+---+
| | | |^_^| | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
============ Gameplay Phase =============
w
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
|___|___|___|0_0|0_]|___|___|___|___|___|
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
d
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
|___|___|___|###|0_0|___|___|___|___|___|
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
============ Game Statistics ============
Turns taken: 2
Step count: 2
Coins Collected: 0
Score: 0
_________________________________________
\\ \\
(x> !! Game !! (x>
\\_//) Over \\_//)
\_/_) \_/_)
_|_ _|_
_________________________________________
Input:
5 3 r 4 v 4 4 l e w w
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 5 3 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |^_^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: r 4 v 4 4 l e +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|###|0_]|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | |^_^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 ============ Gameplay Phase ============= w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|0_0|0_]|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |^_^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|###|0_]|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20
Assumptions / Restrictions / Clarifications
- As soon as Penny the Chicken moves off of a
HEADLIGHTStile and onto a standard tile (i.e.ROADorEMPTY), Penny the Chicken's display should return to^_^. - When Penny the Chicken is shocked
0_0, there is no additional behaviour and their movement remains the same.
Autotest
Stage 3.2 - Driving Game Mode
Task
At the end of this substage, the game should support a new Driving Game Mode where cars move across the board.
When this mode is active, each round of gameplay should include a Car Turn that occurs after Penny the Chicken's turn. During this turn, cars may drive forward or turn around depending on their surroundings.
If a car moves onto the same tile as Penny the Chicken, the Game Loss mechanic from Stage 3.1 should trigger.
Command
d
Description
Update the Setup Loop to recognise the d command, which activates Driving Game Mode.
This command should end the Setup Phase, similar to how the e command ends the Setup Phase and starts the Gameplay Loop with Static Game Mode.
Once d is entered the program should:
- Print the game board with the provided
print_board()function. - Print
"============ Gameplay Phase =============\n", indicating that the Setup Phase is complete, and the user can now start playing the game.
The Driving Game Mode includes all features from Static Game Mode, i.e. player movement, collecting coins, statistics and winning the game. However, cars are no longer stationary and will now move during gameplay.
After each Player Turn, the program should run a Car Turn.
During the Car Turn, each car will attempt to move one tile forward in the direction it is currently facing (left or right). For example, if a car is CAR_FACING_LEFT, its destination is the tile immediately to its left.
A destination is valid if:
- the position is within the game board (not out of bounds), and
- the tile contains
ROADorHEADLIGHTS.
If a car has a valid destination:
- the car should move to that destination tile, and
- the tile that previously contained the car should become
ROAD.
If a car has an invalid destination:
- the car should turn around by reversing its direction while remaining in the same position on the board.
- For example, if a
CAR_FACING_RIGHTis located at position (0, 9) and the tile to the right is out of bounds, the car should become aCAR_FACING_LEFTand remain at position (0, 9).
After all cars have moved, if Penny the Chicken occupies the same tile as a car, the Game Loss mechanic should be triggered.
For example, before the Car Turn is triggered, the board may look like this:
After the Car Turn executes, the board will look like this:
Examples
Input:
5 5 r 2 v 2 8 r d w r a q
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 5 5 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^_^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: r 2 v 2 8 r d +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|[_0|###| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^_^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 ============ Gameplay Phase ============= w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|[_0| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^_^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 r +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|###|0_]| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^_^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 a +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|###|0_]|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 q ============= Quitting Game =============
Input:
3 5 r 2 v 2 2 r d a w
Input and Output:
dcc cs_chicken.c -o cs_chicken
./cs_chicken
_________________________________________
\\ \\
(o> !! Welcome to !! (o>
\\_//) CS CHICKEN \\_//)
\_/_) \_/_)
_|_ _|_
_________________________________________
============== Setup Phase ==============
Enter the starting position: 3 5
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | |^_^| | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
Enter setup commands:
r 2
v 2 2 r
d
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
|___|___|[_0|###|___|___|___|___|___|___|
+---+---+---+---+---+---+---+---+---+---+
| | | | | |^_^| | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
============ Gameplay Phase =============
a
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
|___|___|___|[_0|###|___|___|___|___|___|
+---+---+---+---+---+---+---+---+---+---+
| | | | |^_^| | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
w
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
|___|___|___|___|0_0|###|___|___|___|___|
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
============ Game Statistics ============
Turns taken: 2
Step count: 2
Coins Collected: 0
Score: 0
_________________________________________
\\ \\
(x> !! Game !! (x>
\\_//) Over \\_//)
\_/_) \_/_)
_|_ _|_
_________________________________________
Input:
3 5 r 2 v 2 2 r d w r r
Input and Output:
dcc cs_chicken.c -o cs_chicken
./cs_chicken
_________________________________________
\\ \\
(o> !! Welcome to !! (o>
\\_//) CS CHICKEN \\_//)
\_/_) \_/_)
_|_ _|_
_________________________________________
============== Setup Phase ==============
Enter the starting position: 3 5
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | |^_^| | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
Enter setup commands:
r 2
v 2 2 r
d
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
|___|___|[_0|###|___|___|___|___|___|___|
+---+---+---+---+---+---+---+---+---+---+
| | | | | |^_^| | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
============ Gameplay Phase =============
w
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
|___|___|___|[_0|###|^_^|___|___|___|___|
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
r
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
|___|___|___|___|[_0|0_0|___|___|___|___|
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
r
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
|___|___|___|___|___|0_0|###|___|___|___|
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
============ Game Statistics ============
Turns taken: 3
Step count: 1
Coins Collected: 0
Score: 0
_________________________________________
\\ \\
(x> !! Game !! (x>
\\_//) Over \\_//)
\_/_) \_/_)
_|_ _|_
_________________________________________
Assumptions / Restrictions / Clarifications
- If two cars on adjacent tiles are facing each other (
[_00_]), both their destinations are invalid. Therefore, both cars should reverse their direction (0_][_0). - You may assume that two cars moving toward each other will never have the same destination tile, i.e. the scenario
[_0###0_]will not be assessed. - Some commands do not count as a Player Turn, and thus do not trigger the Car Turn. These commands include:
- Printing game statistics with
p. - Quitting the game with
q.
- Printing game statistics with
- The tile directly in front of a car (in the direction it is facing) should contain a
HEADLIGHTSentity, unless that tile already contains a car. - If a car moves, its headlights should also move such that they always remain one tile ahead of the car.
- If the movement in a Player Turn results in a game loss, the Car Turn should not be run.
- Car Movement mechanics do not occur during Static Game Mode.
- Once the game has entered the Driving Game mode, the mode of the game cannot be changed.
When testing for this substage and all future stages:
- Exiting the Setup Loop with
eshould still enter the Static Game Mode, implemented in Stage 2.1, where cars do not move.
Autotest
Stage 3.3 - Scrolling Game Mode
In the previous substage, we implemented cars driving around. But what happens if Penny the Chicken wants to explore even more of the world?
Task
At the end of this substage, the game should support a new Scrolling Game Mode where the board dynamically shifts upward as Penny the Chicken moves toward the top of the map.
When scrolling occurs, the bottom row of the board should move to the top and all other rows should shift down. This behaviour should occur during an Other Mechanics Turn, which runs after the Player Turn and Car Turn.
Command
s
Description
Update the Setup Loop to recognise the s command, which activates Scrolling Game Mode.
This command should end the Setup Phase, similar to how the d command ends the Setup Phase and starts the Gameplay Loop with Driving Game Mode.
Once s is entered the program should:
- Print the game board with the provided
print_board()function. - Print
"============ Gameplay Phase =============\n", indicating that the Setup Phase is complete, and the user can now start playing the game.
The Scrolling Game Mode adds scrolling mechanics and includes all features from Static Game Mode and Driving Game mode, i.e. car movement, player movement, collecting coins, statistics and winning the game. However, the board is no longer static and will now shift during gameplay.
Scroll Mechanic
The board scrolls only when Penny the Chicken moves upward while located in the top 7 rows of the board, i.e. rows 0 to 6.
- When the board scrolls, the bottom row (
row 9) moves to the top of the board (row 0) and all other rows move down by one position .- The row that moves to the top is referred to as the Scrolled Row for that turn.
- For example, the previous row
0becomes row1, row1becomes row2, and so on until the previous row8becomes row9.
Additionally, any coins that were previously collected on the Scrolled Row should reappear in their original position when the Scrolled Row returns to the top.
Scrolled Row Behaviour
If Penny the Chicken is on the top row (row 0) and attempts to move upward, the game will attempt to place Penny onto the Scrolled Row after the board scrolls. This movement is not resolved during Penny the Chicken's turn as it is an invalid move. Instead, it is handled during the Other Mechanics Turn, immediately after the scroll would occur.
Before scrolling, the program should determine whether Penny would be able to move onto the Scrolled Row once it appears at the top of the board.
4 4 w t 3 4 9 8 s w
- If the destination tile would be an invalid destination (such as a
TREE), the scroll does not occur and Penny remains in the same position. - If the destination tile would be valid, the board scrolls and Penny moves onto the Scrolled Row.
After Penny moves onto the Scrolled Row:
- If the tile contains a coin, the coin should be collected immediately.
- If the tile contains a car, the Game Loss mechanic should trigger.
For example, before the scroll is triggered, the board may look like this:
After the scroll executes, the board will look like this:
Examples
Input:
7 4 r 2 t 3 7 t 6 2 r 8 s w w w w q
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 7 4 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: r 2 t 3 7 t 6 2 r 8 s +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | T | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | T | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 ============ Gameplay Phase ============= w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | T | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | T | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | T | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | T | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | T | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | T | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | T | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | T | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 q ============= Quitting Game =============
Input:
6 4 c 6 5 r 7 s d w w w w w q
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 6 4 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: c 6 5 r 7 s +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| c | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 ============ Gameplay Phase ============= d +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^_^| | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 5 Target: 20 w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^_^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 5 Target: 20 w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^_^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ Score: 5 Target: 20 w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^_^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 5 Target: 20 w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | c | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^_^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 5 Target: 20 w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | c | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^_^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 5 Target: 20 q ============= Quitting Game =============
Input:
0 5 r 9 t 8 4 s w a w a w q
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 0 5 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^_^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: r 9 t 8 4 s +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^_^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | T | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 ============ Gameplay Phase ============= w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|^_^|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | T | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 a +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|^_^|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | T | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|^_^|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | T | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 a +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|^_^|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | T | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | |^_^| T | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|___|___|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 q ============= Quitting Game =============
Input:
0 5 r 8 v 8 3 r s w w
Input and Output:
dcc cs_chicken.c -o cs_chicken
./cs_chicken
_________________________________________
\\ \\
(o> !! Welcome to !! (o>
\\_//) CS CHICKEN \\_//)
\_/_) \_/_)
_|_ _|_
_________________________________________
============== Setup Phase ==============
Enter the starting position: 0 5
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | |^_^| | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
Enter setup commands:
r 8
v 8 3 r
s
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | |^_^| | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
|___|___|___|[_0|###|___|___|___|___|___|
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
============ Gameplay Phase =============
w
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | |^_^| | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
|___|___|___|___|[_0|###|___|___|___|___|
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
w
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
|___|___|___|___|___|0_0|###|___|___|___|
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
============ Game Statistics ============
Turns taken: 2
Step count: 2
Coins Collected: 0
Score: 0
_________________________________________
\\ \\
(x> !! Game !! (x>
\\_//) Over \\_//)
\_/_) \_/_)
_|_ _|_
_________________________________________
Assumptions / Restrictions / Clarifications
- All entities will move with their rows.
- If a loss occurs during the Car Turn, the game ends immediately. The Other Mechanics Turn should not run.
- The board should not scroll when:
- Penny moves upward while in the bottom three rows (
7to9). - Penny moves left, right, or down.
- Penny moves upward while in the bottom three rows (
- When testing for this sub-stage and all future stages, scrolling only occurs in Scrolling Game Mode:
- Exiting the Setup Loop with
eshould still enter the Static Game Mode, implemented in Stage 2.1, where cars do not move. - Exiting the Setup Loop with
dshould still enter the Driving Game Mode, implemented in Stage 3.2, where cars do move but the board does not.
- Exiting the Setup Loop with
Autotest
Stage 3.4 - Wombat Tunnels
Upon walking across Australia, Penny the Chicken has come across Wombat Tunnels?! Where do they lead?
By the end of this stage, your program will be able to add wombat tunnels during setup that can help Penny the Chicken move around.
Task
At the end of this substage, the program should support Wombat Tunnels, which can be placed during the Setup Phase and used during gameplay.
Each tunnel consists of pairs of openings connected together. When Penny walks onto either opening, they will be instantly transported to the other opening of the same tunnel.
Command
w t [row_1] [col_1] [row_2] [col_2]
Description
Placing Wombat Tunnels
Modify the Setup Loop to handle the wombat tunnel command above, which creates two tunnel openings at the given coordinates.
Each tunnel is assigned a unique ID, starting from 0 and increasing by 1 for every new tunnel created. Both openings of the tunnel should display the same ID in the format (n) where n is the ID of the tunnel.
For example, entering w t 0 0 5 5 creates the first tunnel pair with ID 0 and openings at position (0, 0) and (5, 5) on the board. Then if w t 1 1 6 6 is entered, this would create a second tunnel pair with ID 1 and openings at position (1, 1) and (6, 6) on the board.
- If either location for an opening is out of bounds or the tile is occupied, print
Invalid location: wombat couldn't dig a tunnel here!\nand do not add the tunnel pair.
A tile is considered occupied if:
- Penny the Chicken is on that tile, or
- the tile's entity is not
EMPTY.
If there are already 10 wombat tunnels on the map (20 openings), print "Invalid feature: too many tunnels!\n" and do not add the tunnel pair.
Wombat Tunnel Mechanic
When Penny walks onto a tile containing a tunnel opening, they should be instantly transported to the opposite opening with the same ID, landing on the tile adjacent to the opening in the direction of Penny's movement.
For example, if Penny enters the opening for tunnel (1) at position (1, 1), they will emerge adjacent to the other opening of tunnel (1) at position (6, 6) on the opposite side.
If the transportation destination:
- is out of bounds, or
- contains a
TREEthen the move should be treated the same as an invalid player move, and Penny the Chicken's turn should be skipped.
Examples
Input:
0 0 w t 1 1 8 8 e s d a q
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 0 0 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ |^_^| | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: w t 1 1 8 8 e +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ |^_^| | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | |(0)| | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |(0)| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 ============ Gameplay Phase ============= s +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |^_^|(0)| | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |(0)| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 d +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | |(0)| | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |(0)|^_^| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 a +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |^_^|(0)| | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |(0)| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 q ============= Quitting Game =============
Input:
7 1 w t 5 6 7 2 t 5 7 e d s d w a q
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 7 1 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | |^_^| | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: w t 5 6 7 2 t 5 7 e +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |(0)| T | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | |^_^|(0)| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 ============ Gameplay Phase ============= d +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |(0)| T | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | |^_^|(0)| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 s +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |(0)| T | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |(0)| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | |^_^| | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 d +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |(0)| T | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |(0)| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |^_^| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |^_^| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |(0)| T | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |(0)| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 a +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^_^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |(0)| T | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |(0)| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 q ============= Quitting Game =============
Input:
9 1 w t 8 1 1 8 s w w q
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 9 1 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | |^_^| | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: w t 8 1 1 8 s +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |(0)| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | |(0)| | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | |^_^| | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 ============ Gameplay Phase ============= w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |^_^| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |(0)| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | |(0)| | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | |(0)| | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |^_^| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | |(0)| | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 q ============= Quitting Game =============
Assumptions / Restrictions / Clarifications
- Only one error message should be printed. If multiple should be printed, print the first one in the order of the rules mentioned above.
- Any position outside the bounds of the game board is considered out of bounds for tunnelling (for example, positions above row
0, below row9, left of column0, or right of column9). - Wombat Tunnels should work in Static Game Mode, Driving Game Mode and Scrolling Game Mode.
- If the game is in Scrolling Game Mode, the board will scroll if Penny the Chicken is transported to a tunnel destination located in the top seven rows. This scroll is determined after Penny the Chicken has been transported, based on Penny the Chicken's final position.
- In this sub-stage and all future tests:
- A tunnel's destination will never lead directly into another tunnel.
[row_1],[col_1],[row_2]and[col_2]will always be integers.- Incomplete commands will not be tested. For example when a
w tis entered, it will always be followed by a[row_1] [col_1] [row_2] [col_2].
- Wombat tunnels will not be recursive. This is undefined behaviour and will not be tested.
- You may assume that in all tests and examples, moving into a wombat tunnel will not cause Penny the Chicken to land on another wombat tunnel.
Autotest
Testing & 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-stagecommand 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_chicken.c 1511 autotest-stage 03 cs_chicken give cs1511 ass1_cs_chicken cs_chicken.c
Stage 4
Welcome to Stage 4! In this stage you will extend the world of CS Chicken even further with some advanced thematic features! This milestone consists of two substages:
- Stage 4.1 - Riding Kangaroos.
- Stage 4.2 - Opening a Daycare.
Stage 4.1 - Riding Kangaroos
In the previous substage, Penny the Chicken explored the Australian terrain and found wombat tunnels. This time we'll look at the wildlife! By the end of this substage, Penny the Chicken will be able to place kangaroos and hop in their pouches to ride them as they jump around the board!
Task
At the end of this substage, the program should support the KANGAROO entity and include kangaroos that the player can ride.
When Penny the Chicken moves onto a tile containing a kangaroo, they will ride inside its pouch. While riding, Penny the Chicken’s movements will follow the kangaroo's jumping mechanic that alternates between different jump distances.
If a kangaroo attempts an invalid jump, Penny the Chicken will dismount and the kangaroo will be removed from the board.
Command
k [row] [col]
Description
Update the Setup Loop to recognise the k command, which places a KANGAROO on the board at the given coordinates. Kangaroos should be displayed on the board as _b^.
If the provided coordinates are invalid, the program should print:
Invalid location: kangaroos can't be here!\n
If the location is invalid, nothing should be added to the board and the program should continue reading setup commands. A location is considered invalid if:
- the position is outside the game board, or
- the tile is already occupied by another entity.
During gameplay, if Penny the Chicken moves onto a tile containing a KANGAROO, they will jump into its pouch and begin riding the kangaroo.
While riding the kangaroo:
- Penny the Chicken should be displayed as
_B^. - All movement commands (
w,a,s,d) will perform jumps instead of normal movement.
Kangaroo Jumping
A jump moves Penny the Chicken multiple tiles in the chosen direction.
Jumps follow a strict alternating sequence:
- The first jump moves 2 tiles.
- The second jump moves 3 tiles.
- The third jump moves 2 tiles.
- The pattern continues alternating between 2 and 3 tiles.
For example a kangaroo may take the following jump sequence:
This jump sequence continues across all kangaroo rides.
If a jump attempt is invalid and results in Penny the Chicken dismounting, the jump sequence should still advance. For example, if Penny the Chicken attempts a 3 tile jump that is invalid and causes a dismount, the next time they ride a kangaroo the first jump will be 2 tiles.
During a jump:
- Penny the Chicken leaps over intermediate tiles, meaning she does not interact with any entities between her starting position and destination.
- Only the destination tile determines the outcome of the jump.
Dismounting
The only way to stop riding a kangaroo is through the dismount mechanic.
If Penny the Chicken attempts to perform an invalid jump, they should dismount the kangaroo.
An invalid jump occurs when:
- The destination tile is a position that is not on the board.
- The destination tile contains a
TREE. - The destination tile contains a
CAR.
When this occurs:
- The jump should not be performed,
- Penny the Chicken should remain on the same tile, and
- The kangaroo should be removed from the board.
After dismounting, Penny the Chicken returns to normal movement.
For example, if the jump below was attempted by Penny the Chicken:
A dismount would occur, since Penny the Chicken is attempting to perform an invalid jump and the board state would be as follows:
Examples
Input:
6 2 t 2 3 r 5 v 5 3 r k 6 3 e d w w q
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 6 2 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |^_^| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: t 2 3 r 5 v 5 3 r k 6 3 e +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | T | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|[_0|###|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | |^_^|_b^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 ============ Gameplay Phase ============= d +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | T | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|[_0|###|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | |_B^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | T | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |_B^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|[_0|###|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |_B^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | T | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ |___|___|___|[_0|###|___|___|___|___|___| +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 q ============= Quitting Game =============
Input:
6 2 t 3 5 k 6 3 e d d w q
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 6 2 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |^_^| | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: t 3 5 k 6 3 e +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | T | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | |^_^|_b^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 ============ Gameplay Phase ============= d +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | T | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | |_B^| | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 d +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | T | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |_B^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | T | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^_^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 q ============= Quitting Game =============
Input:
6 2 r 1 v 1 9 l k 6 3 c 6 5 s d d w w
Input and Output:
dcc cs_chicken.c -o cs_chicken
./cs_chicken
_________________________________________
\\ \\
(o> !! Welcome to !! (o>
\\_//) CS CHICKEN \\_//)
\_/_) \_/_)
_|_ _|_
_________________________________________
============== Setup Phase ==============
Enter the starting position: 6 2
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | |^_^| | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
Enter setup commands:
r 1
v 1 9 l
k 6 3
c 6 5
s
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
|___|___|___|___|___|___|___|___|###|0_]|
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | |^_^|_b^| | c | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
============ Gameplay Phase =============
d
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
|___|___|___|___|___|___|___|###|0_]|___|
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | |_B^| | c | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
d
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
|___|___|___|___|___|___|###|0_]|___|___|
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | |_B^| | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 5 Target: 20
w
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
|___|___|___|___|___|###|0_]|___|___|___|
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | |_B^| | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 5 Target: 20
w
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
|___|___|___|___|###|_B^|___|___|___|___|
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 5 Target: 20
============ Game Statistics ============
Turns taken: 4
Step count: 4
Coins Collected: 1
Score: 5
_________________________________________
\\ \\
(x> !! Game !! (x>
\\_//) Over \\_//)
\_/_) \_/_)
_|_ _|_
_________________________________________
Assumptions / Restrictions / Clarifications
-
If more than one mechanic should affect Penny the Chicken's appearance at once, use the following priority:
- Kangaroo Movement -
_B^ - Shocked Chicken -
0_0 - Standard -
^_^
- Kangaroo Movement -
-
Kangaroos movements should function in Static Game Mode, Driving Game Mode, and Scrolling Game Mode.
-
When in Scrolling Game Mode:
- Kangaroos do not reappear in their setup positions after the board scrolls.
- Jumping up by
ntiles (where n is either 2 or 3) should result innscrolls of the board. - If a kangaroo jump would land outside the board, the jump is considered invalid and the board should not scroll.
-
Kangaroos should work with all previously implemented game mechanics.
- If a kangaroo lands on a
COIN, the coin should be collected as normal. - When riding a kangaroo, Wombat Tunnels should behave like a
TREEentity. That is, they should block the movement of the kangaroo and Penny the Chicken should dismount. - In Driving Game Mode or Scrolling Game Mode, if a car moves onto Penny’s tile while she is riding a kangaroo, the Game Loss mechanic should trigger immediately.
- If a kangaroo lands on a
-
If the kangaroo jumps onto a tile containing another
KANGAROO:- the existing kangaroo should be removed from the board, and
- the jump should complete normally.
In this sub-stage and all future stages:
[row]and[col]will always be integers.- Incomplete commands will not be tested. For example when a
kis entered, it will always be followed by[row] [col].
Autotest
Stage 4.2 - Opening a Daycare
In the previous substage, Penny the Chicken was riding kangaroos across the board. Now they will open a daycare to look after some baby chickens!
Task
At the end of this substage, the program should support the BABY_CHICKEN entity and the Daycare Worker mechanic.
If baby chickens are spawned during the Setup Phase, Penny the Chicken will act as a daycare worker and baby chickens will follow their movements around the board.
Command
b
Description
Update the Setup Loop to recognise the b command, which spawns a baby chicken. Baby chickens should be displayed on the board as ^.^.
The b command may be entered up to four times during the Setup Phase. If this limit is exceeded, the program should print:
Invalid command: there can be at most 4 baby chickens at a time.
Daycare Worker Mechanic
If any baby chickens were added during the Setup Phase, Penny the Chicken should be printed with a baby chicken count, n, in the centre of their display like so: ^n^. For example, entering the b command three times will spawn Penny the Chicken as ^3^.
For the next n number of Penny the Chicken's movements:
- a baby chicken is spawned on the tile they moved from, and
ndecreases by 1.
When the baby chicken count reaches 0, Penny the Chicken returns to their normal appearance ^_^.
Penny the Chicken cannot move onto a tile occupied by a baby chicken.
If Penny the Chicken attempts to move onto a baby chicken:
- the movement is blocked,
- Penny the Chicken remains on their current tile, and
- the turn is treated as a rest move.
Game Loss Mechanic
Similar to Penny the Chicken, if a baby chicken is spawned on or occupies a tile containing HEADLIGHTS, they should appear shocked display as o.o.
If any baby chicken:
- is hit by a car, or
- is scrolled off the board,
the game should be lost immediately, and the Game Loss mechanic should be triggered.
^3^ and no baby chickens have been spawned yet.
Penny moves one tile to the left.
- A baby chicken
(^.^)is spawned on the tile Penny moved from, and the baby chicken count decreases to 2. - Penny the Chicken is displayed as
^2^.
Penny attempts to move onto a tile containing a tree.
- The movement is blocked, so Penny remains on the same tile and no baby chicken is spawned.
- The turn is treated as a rest move, so other mechanics (such as car movement) still occur.
Penny moves down one tile.
- A baby chicken
(^.^)is spawned on the tile Penny moved from, and the baby chicken count decreases to 1. - Penny the Chicken is displayed as
^1^.
Penny moves down again.
- A final baby chicken
(^.^)is spawned on the tile Penny moved from. - The baby chicken count reaches 0, so Penny the Chicken returns to their normal appearance
^_^.
Penny moves down again and moves onto a tile containing HEADLIGHTS.
- Penny appears shocked, and their appearance changes to
0_0.
Penny moves down again.
- During the Car Turn, a car moves onto a tile containing a baby chicken and the game is lost.
Examples
Input:
7 5 b b b e w w a w w q
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 7 5 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^_^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: b b b e +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^3^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 ============ Gameplay Phase ============= w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^2^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^.^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^1^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^.^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^.^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 a +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^|^.^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^.^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^.^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^.^|^.^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^.^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^.^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^.^|^.^| | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 q ============= Quitting Game =============
Input:
8 4 r 7 v 7 1 r b b b s w w w
Input and Output:
dcc cs_chicken.c -o cs_chicken
./cs_chicken
_________________________________________
\\ \\
(o> !! Welcome to !! (o>
\\_//) CS CHICKEN \\_//)
\_/_) \_/_)
_|_ _|_
_________________________________________
============== Setup Phase ==============
Enter the starting position: 8 4
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | |^_^| | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
Enter setup commands:
r 7
v 7 1 r
b
b
b
s
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
|___|[_0|###|___|___|___|___|___|___|___|
+---+---+---+---+---+---+---+---+---+---+
| | | | |^3^| | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
============ Gameplay Phase =============
w
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
|___|___|[_0|###|^2^|___|___|___|___|___|
+---+---+---+---+---+---+---+---+---+---+
| | | | |^.^| | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
w
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | |^1^| | | | | |
+---+---+---+---+---+---+---+---+---+---+
|___|___|___|[_0|o.o|___|___|___|___|___|
+---+---+---+---+---+---+---+---+---+---+
| | | | |^.^| | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
w
+---+---+---+---+---+---+---+---+---+---+
| C S C H I C K E N |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | |^_^| | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | |^.^| | | | | |
+---+---+---+---+---+---+---+---+---+---+
|___|___|___|___|o.o|###|___|___|___|___|
+---+---+---+---+---+---+---+---+---+---+
| | | | |^.^| | | | | |
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
Score: 0 Target: 20
============ Game Statistics ============
Turns taken: 3
Step count: 3
Coins Collected: 0
Score: 0
_________________________________________
\\ \\
(x> !! Game !! (x>
\\_//) Over \\_//)
\_/_) \_/_)
_|_ _|_
_________________________________________
Input:
9 4 w t 3 7 6 4 b b s w w w a a a q
Input and Output:
dcc cs_chicken.c -o cs_chicken ./cs_chicken _________________________________________ \\ \\ (o> !! Welcome to !! (o> \\_//) CS CHICKEN \\_//) \_/_) \_/_) _|_ _|_ _________________________________________ ============== Setup Phase ============== Enter the starting position: 9 4 +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 Enter setup commands: w t 3 7 6 4 b b s +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |(0)| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |(0)| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^2^| | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 ============ Gameplay Phase ============= w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |(0)| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |(0)| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^1^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^.^| | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |(0)| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |(0)| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^.^| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^.^| | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 w +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |^2^| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |(0)| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |(0)| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 a +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | |^1^|^.^| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |(0)| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |(0)| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 a +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | |^_^|^.^|^.^| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |(0)| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |(0)| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 a +---+---+---+---+---+---+---+---+---+---+ | C S C H I C K E N | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |^_^|^.^|^.^| | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | |(0)| | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | |(0)| | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ Score: 0 Target: 20 q ============= Quitting Game =============
Assumptions / Restrictions / Clarifications
-
If more than one mechanic should affect Penny the Chicken's appearance at once, use the following priority:
- Kangaroo Movement -
_B^ - Shocked Chicken -
0_0 - Daycare Worker -
^*^ - Standard -
^_^
- Kangaroo Movement -
-
When Penny the Chicken enters a
WOMBAT_TUNNEL, all accompanying baby chickens immediately follow them and are removed from the board. Penny spawns at the tunnel exit with the baby chicken count fully restored to the initial value, and baby chickens begin spawning again as she moves. -
If Penny the Chicken moves onto a
KANGAROO, all baby chickens follow them into the pouch and are removed from the board. When Penny the Chicken dismounts, the baby chicken count is restored to the initial value, and baby chickens begin spawning again as she moves. -
The Daycare Worker mechanic should function in Static Game Mode, Driving Game Mode, and Scrolling Game Mode.
-
The
bcommand can be entered at any time during the Setup Phase. If used multiple times, the commands do not need to be consecutive. -
If the game is lost due to a baby chicken being scrolled off the board, the baby chicken should not be printed on the scrolled row.
Autotest
Testing & 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-stagecommand 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_chicken.c 1511 autotest-stage 04 cs_chicken give cs1511 ass1_cs_chicken cs_chicken.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 worth any marks, nor are there any autotests. They are just for fun!
Getting Started
To get started with SplashKit, complete the SplashKit activities.
Sample Code
First, navigate to your SplashKit directory.
cd splashkit
Create a new directory for your project and cd into it.
mkdir cs_chicken cd cs_chicken
Set up your directory for SplashKit with:
1511 setup-splashkit-directory
Run this cp command to retrieve the sample code.
cp -n /web/cs1511/26T1/activities/cs_chicken/splashkit_example.c .
This should add the splashkit_example.c sample code to your current directory.
Check that SplashKit Works
Let's check that SplashKit works by running a test file. It should display a white square with a grid inside.
skm clang++ splashkit_example.c -o splashkit_example ./splashkit_example
Have a look inside of splashkit_example.c and note that:
- At the very top, the the SplashKit library
"splashkit.h"is included. If you see an error here, check SplashKit #1 - Getting Started for a solution to set up your VS Code project. - In the
main()function:open_window("SplashKit Example", 600, 400)creates a 600×400 window for displaying graphics.- The
while (!window_close_requested(w))loop keeps running until the user closes the window. Within this loop:process_events()handles input or window-related actions (like closing the window).refresh_screen()updates the window so any graphical changes (like drawing a rectangle) are displayed to the user.
Running Your SplashKit Code
When creating your SplashKit program, give it a distinctive name like splashkit_cs_chicken.c.
To compile and run your program, use:
skm clang++ splashkit_cs_chicken.c -o splashkit_cs_chicken ./splashkit_cs_chicken
Writing Your SplashKit Program
Now that you've seen how the sample code works, it’s time to create your own SplashKit program.
If you're not sure where to begin, start by researching the SplashKit Library. The goal at first is not to understand and memorise the entire library. Rather, it's better to skim through the pages to build a broad understanding of the capabilities that SplashKit can bring to your creations.
The Graphics page is a good place to start, and the following sections will be useful:
- Windows for opening, closing, and controlling the size of windows.
- Color for using different colours.
- Graphics for drawing shapes, images, and text.
- Geometry for handling shapes such as rectangles, circles, lines, and points.
- Input for capturing and handling user input such as keyboard and mouse events.
SplashKit Gallery
Have you built something fun or interesting using SplashKit? Show it off and inspire your classmates!
Share any screenshots or short videos of your running program in the SplashKit Gallery on the Course Forum. Feel free to add a brief description or reflect on how you made it, so we can all learn from your mistakes journey 😅.
Tools
Creating Levels in Separate Files
If you are getting sick of typing in your inputs for a level every single time you run CS Chicken, 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, it's just a regular plain text file, and the file extension .in works nicely for this!
Let's put it in the same directory as your cs_chicken.c code.
ls cs_chicken.c cs_chicken 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 (from substage 2.1 onwards).
Your file could look a bit like this:
8 8 e d s a R R R w a
3. Run the code with your file
Next, instead of just running ./cs_chicken, lets tell the computer to first read from the file we created.
If you have completed substage 2.1 then use the following:
cat my_level.in - | ./cs_chicken
Otherwise, use the following:
cat my_level.in | ./cs_chicken
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 the course forum! Prefix it with the stage required, and post it on Discourse 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_chicken.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_chicken cs_chicken.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_chicken.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 30 March 2026 18: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%.
Change Log
-
Version 1.0
(2026-03-10 16:00) -
- Assignment released
-
Version 1.1
(2026-03-11 14:30) -
- Stage 2.4: add missing error message for invalid points input