1. Homepage
  2. Programming
  3. COMP1511 Programming Fundamentals - Assignment 1 - CS Pacman

COMP1511 Programming Fundamentals - Assignment 1 - CS Pacman

Engage in a Conversation
UNSWCOMP1511CS1511Programming FundamentalsC

Assignment 1 - CS Pacman

Overview

Welcome to CS Pacman! CS Pacman is an adaptation of the 1980 maze game. In this assignment you will be implementing 1511's simplified version of this game and trying to get your Pacman to collect all the dots! Please read most of the spec before starting the assignment. (although you can save reading stages 2, 3 and 4 for later). CourseNana.COM

Assignment Structure

This assignment will test your ability to create, use and manipulate 2D arrays and structs to solve problems. To do this, the map used in the game has been implemented as a 2D array of tiles. These tiles are each represented by a struct tile, which is outlined below: CourseNana.COM

struct tile CourseNana.COM

  • Purpose:
    • To store information about the tiles of the map.
  • Contains:
    • enum entity entity
      • The type of entity that exists on this tile.
      • All entity types are found in the enum entity definition.
    • struct enemy enemy
      • Represents the enemy at this location (if one exists).

struct enemy CourseNana.COM

  • Purpose:
    • To store information about a particular enemy
  • Contains:
    • enum direction move_direction
      • The direction the enemy is moving.
      • All directions are found in the enum direction definition.
    • int is_present
      • Represents whether the enemy is present
    • You will need to add more fields to this struct in later stages.

The provided enums are quite extensive. Definitions of each are provided below: CourseNana.COM

enum entity CourseNana.COM

  • Purpose:
    • Represent possible entities that can exist on a tile
  • Possible values:
    • EMPTY_ENTITY
      • Represents no entity. Some tiles will have no entity present, this allows us to represent that.
    • WALL
      • A wall that blocks the movement of Pacman and enemies
    • DOT
      • A collectable that gives Pacman points (Stage 2)
    • APPLE
      • A collectable that gives points, helps collect DOTs and can destroy WALLs (Stage 2)
    • BANANA
      • A collectable that gives points and helps collect DOTs (Stage 2)
    • POWER_UP
      • A collectable that gives points and helps catch ghosts (Stage 3)
    • STAIRCASE_UP
      • Allows Pacman to travel up to a higher floor (Stage 4)
    • STAIRCASE_DOWN
      • Allows Pacman to travel down to a lower floor (Stage 4)

enum direction CourseNana.COM

  • Purpose:
    • Represent the direction of a ghost's movement
  • Possible values:
    • UP
    • DOWN
    • LEFT
    • RIGHT

Program phases

There are two main phases to the overall game: CourseNana.COM

  1. Create level phase. This is where you will be placing Pacman and adding features to the map. This is started in Stage 1 and you will add to this throughout the rest of the assignment.
  2. Gameplay phase. This is where you will handle Pacman's movement throughout the level. This is started in Stage 2 and you will add to this throughout the rest of the assignment.

How To Get Started

There are a few steps to getting started with CS Pacman. CourseNana.COM

  1. Create a new folder for your assignment work and move into it.
mkdir ass1
cd ass1
  1. Download the starter code (cs_pacman.c) here or use this command on your CSE account to copy the file into your current directory:

Or, copy this code to your CSE account using the following command CourseNana.COM

1511 fetch-activity cs_pacman
  1. Run 1511 autotest cs_pacman to make sure you have correctly downloaded the file.
1511 autotest cs_pacman
  1. Read through Stage 1. CourseNana.COM

  2. Spend a few minutes playing with the reference solution -- get a feel for how the assignment works. CourseNana.COM

    1511 cs_pacman

    CourseNana.COM

  3. Think about your solution, draw some diagrams, write some pseudocode to help you get started. CourseNana.COM

  1. Start coding!

Reference Solution

To help you understand the proper behaviour of the game, we have provided a reference implementation. If you have any questions about the behaviour of your assignment, you can check and compare it to the reference implementation. CourseNana.COM

To run the reference implementation, use the following command: CourseNana.COM

1511 cs_pacman

About the Starter Code

The provided starter code has done some setup for you. This is explained below. CourseNana.COM

Before the main function, the starter code has: CourseNana.COM

  1. Imported the standard input/output library.
  2. Defined some initial #define's and enums.
  3. Defined the struct(s) described above.

In the main function, the starter code: CourseNana.COM

  1. Creates a 2D array of struct tiles called map.
  2. Initialises this map with some default values.
  3. Prompts you to write your own code!

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. CourseNana.COM

A video explanation to help you get started with the assignment can here found here: CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

Stage 1

Stage 1.1 - Placing Pacman

Your first task for this assignment is to place our Pacman on the map! Currently, the starter code creates a 2D array of struct tiles, and initialises them with the initialise_map() function that we’ve provided. CourseNana.COM

Your program should scan in the coordinates (first row, then column) at which Pacman should be placed. The updated map should then be printed out, using the provided print_map() function. CourseNana.COM

Assumptions / Restrictions / Clarifications

  • You can assume that you will always be provided with two integers for the row and column for Pacman.
  • The row/column provided will always fall within the map.

Examples

CourseNana.COM

CourseNana.COM

Autotest

Stage 1.2 - Adding Features

Now that we’ve placed Pacman, we also need to place some features on the map! At this stage, the only feature that your program should handle is placing walls — but you will need to extend this to other features in later stages, so have a think about how best to do that! CourseNana.COM

To add features, your program should read characters in a loop, followed by a variable number of inputs based on which feature is being added. The loop should terminate when the user enters the 'S' character (meaning “Start the game”). CourseNana.COM

As mentioned, the only feature for this stage is the placement of walls. To place a wall, the user will first type the character 'W', followed by the wall’s start and end coordinates (first row, then column). CourseNana.COM

...
Create the level:
W [start_row] [start_col] [end_row] [end_col]
...

For this stage, you can assume that the walls will either be horizontal or vertical, and that the start values will be less than or equal to their end counterparts. In other words, every coordinate pair received will have either the row OR column equal, and go from left to right, or top to bottom. CourseNana.COM

In this stage, every wall entered will be valid — meaning that all walls will fall entirely within the map. CourseNana.COM

Once all of the walls have been placed, the map should be printed. CourseNana.COM

Assumptions / Restrictions / Clarifications

  • You can assume that input for this stage will always end with S.
  • In this stage, all walls entered will be horizontal or vertical (for each coordinate pair, either the column will be the same, or the row will be the same).
  • In this stage, you will not be given walls that fall outside the map.
  • You can assume that start_row will always be less than or equal to end_row.
  • You can assume that start_col will always be less than or equal to end_col.
  • A wall could be a single block (start_row equals end_row and start_col equals end_col)

Examples

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

Autotest

1511 autotest-stage 01_02 cs_pacman

Stage 1.3 - Validating Walls

In this stage, the walls given may not be horizontal or vertical, and thus unable to be placed. If this occurs, the error message "Given wall is not horizontal or vertical!" should be printed, and the program should continue reading input. CourseNana.COM

We also need to handle the case where some or all of the wall falls outside the map. If part or all of a wall lies out of the map, then that part should be ignored. The part of the wall that lies within the map should still be placed. CourseNana.COM

Assumptions / Restrictions / Clarifications

  • You can still assume that you receive a valid number of inputs.
  • You can still assume that start_row will always be less than or equal to end_row.
  • You can still assume that start_col will always be less than or equal to end_col.
  • If a wall is not horizontal/vertical AND falls outside of the map completely, you should still print "Given wall is not horizontal or vertical!"

Examples

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

Autotest

1511 autotest-stage 01_03 cs_pacman

Stage 1.4 - Placing Dots

Once the setup phase has finished, and all features have been placed, we need to fill all the remaining squares with dots. These are the points which Pacman will collect while moving around the map. Any square which does not already have an entity on it should have a dot placed on it. CourseNana.COM

Assumptions / Restrictions / Clarifications

  • Dots should not be placed on tiles with another entity already present.
  • A dot should be placed under Pacman

Examples

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

Autotest

1511 autotest-stage 01_04 cs_pacman

Testing and Submission

Remember to do your own testing CourseNana.COM

Are you finished with this stage? If so, you should make sure to do the following: CourseNana.COM

  • 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 and readability!
  • Autotest for this stage of the assignment by running the autotest-stage command as shown below.
  • Remember -- give early, and give often. Only your last submission counts, but why not be safe and submit right now?
1511 style cs_pacman.c
1511 autotest-stage 01 cs_pacman
give cs1511 ass1_cs_pacman cs_pacman.c

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM



Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
UNSW代写,COMP1511代写,CS1511代写,Programming Fundamentals代写,C代写,UNSW代编,COMP1511代编,CS1511代编,Programming Fundamentals代编,C代编,UNSW代考,COMP1511代考,CS1511代考,Programming Fundamentals代考,C代考,UNSWhelp,COMP1511help,CS1511help,Programming Fundamentalshelp,Chelp,UNSW作业代写,COMP1511作业代写,CS1511作业代写,Programming Fundamentals作业代写,C作业代写,UNSW编程代写,COMP1511编程代写,CS1511编程代写,Programming Fundamentals编程代写,C编程代写,UNSWprogramming help,COMP1511programming help,CS1511programming help,Programming Fundamentalsprogramming help,Cprogramming help,UNSWassignment help,COMP1511assignment help,CS1511assignment help,Programming Fundamentalsassignment help,Cassignment help,UNSWsolution,COMP1511solution,CS1511solution,Programming Fundamentalssolution,Csolution,