1. Homepage
  2. Programming
  3. DPST1091/CPTG1391 Programming Fundamentals - Assignment 1: Sokoban

DPST1091/CPTG1391 Programming Fundamentals - Assignment 1: Sokoban

Engage in a Conversation
UNSWDPST1091CPTG1391Programming FundamentalsSokobanC

Sokoban

Overview

Sokoban is a simple Japanese puzzle game from the 80's, although the rules are simple, levels can be deceptively hard.

The main idea of Sokoban is a small grid board, containing walls, boxes, storage locations and a single player. The player moves around the board pushing boxes around until they manage to get all boxes stored in one of the storage locations! Feel free to check out the wikipedia entry for Sokoban too. CourseNana.COM

For this assignment, you will be building both a level generator for the game, as well as the mechanics to play your created levels! CourseNana.COM

Getting Started

  1. Create a new folder for your assignment. Here is an example:
mkdir ass1
cd ass1
  1. Fetch the starter code using the command below. Alternatively download the starter code here.
1091 fetch-activity cs_sokoban
  1. Check that everything works by running the autotest.
1091 autotest cs_sokoban

(These should fail initially. If you want to exit running the autotest midway, press [ctrl-c].) CourseNana.COM

Initial Code and Data Structures

The starter code for this assignment includes some functions and defined types: CourseNana.COM

  • print_board(...) function:
    • This prints out the current state of the board, allowing the user to play the game.
    • This ensures that the board will be consistent between you and the autotest.
  • init_board(...) function:
    • This sets up the board with default values.
  • struct tile struct:
    • Each square of the board (aka the 2D array) holds a struct tile. This tells us information about what is at that location in the board.
    • Note that the player location is stored separately to the contents of the board.
  • enum base enum:
    • This is used within struct tile. Every position on the board must be exactly 1 of these values (NONEWALL, or STORAGE).

CourseNana.COM

CourseNana.COM

Reference Implementation

To help you understand how the assignment works, we have written a reference implementation for you to run. You can run it via the command 1091 cs_sokoban. CourseNana.COM

1091 cs_sokoban
=== Level Setup ===
...

CourseNana.COM

CourseNana.COM

FAQ

CourseNana.COM

CourseNana.COM

Stages

We have broken the assignment spec down into incremental stages: CourseNana.COM

  • Stage 1: Level Builder - adding boxes, walls, and storage locations.
  • Stage 2: Player Movement - adding player starting location, player movement and move counter.
  • Stage 3: Core Game Mechanics - moving boxes, win condition, and reset level.
  • Stage 4: Advanced Game Mechanics - undo command, pushing multiple boxes, and linking boxes.
  • Extension (no marks): Adding graphics, multiple levels per game, and storing levels in text files.

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

CourseNana.COM

CourseNana.COM

CourseNana.COM

Stage 1

In Stage 1, you will set up the level builder for the Sokoban game. It includes asking the user for commands to place walls, boxes, and storage locations. CourseNana.COM

There is a reference implementation that you can play by running the command 1091 cs_sokoban in the terminal. CourseNana.COM

Here is an example of input for a finished stage 1 that you can try within the reference implementation. CourseNana.COM

1091 cs_sokoban
w 0 0
s 1 1
s 10 10
b 1 0
b 1 1
W 0 0 9 0 
[ctrl-d]

(note: the lowercase w and capital W are different commands) CourseNana.COM

Stage 1.1: Setting up level builder

To create a level builder, we need to give the user the ability to add items onto the board via commands until they decide to start playing the game. In this substage you will create a command loop that lets players add WALL or STORAGE to the board. CourseNana.COM

In this substage, you will need to do the following: CourseNana.COM

  1. Print out === Level Setup ===\n.
  2. Setup a loop for reading in commands.
  3. Given the command: w [row] [col] a wall will be placed at position [row][col].
  4. Given the command: s [row] [col] a storage location will be placed at position [row][col].
  5. Before reading in the next command, print out the board with the provided print_board() function.
  6. The loop should stop when the user inputs [ctrl-d].

Don't worry about error checking for this, we will cover that in a future stage :) CourseNana.COM

Clarifications

  • If a wall gets placed on a storage location, or vice versa, override the value.
  • We will only test valid row and col values within the map during this stage.
  • We will only test valid commands.

Examples:

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

Autotest

Stage 1.2: Array bounds checking

In stage 1.1, we didn't check if the given values are outside of the bounds of our array/board. Currently our program will crash in these cases, so let's fix that now! CourseNana.COM

In this substage, you will need to do the following: CourseNana.COM

  1. When the user enters the w or s command, check that row and col are within the bounds of the board. If either one is out of bounds, print out Location out of bounds and don't modify the board.

Clarifications

  • row and col will always be integer values.

Examples

CourseNana.COM

CourseNana.COM

Autotest

Stage 1.3: Add boxes

Add functionality for boxes to be added to the board. Although boxes can exist in the same tile as a storage location, we should never have a box and a wall at the same position. CourseNana.COM

In this substage, you will need to do the following: CourseNana.COM

  1. Given the command b [row] [col], add a box at that location.
    • If there is a storage location there, we will end up with both a storage location AND a box.
    • If there is a wall there, change the base from WALL to NONE and add in the box.
  2. Check that row and col are within the bounds, else, print Location out of bounds.
  3. Edit your w so that if someone places a wall where a box already exists, it removes the box.

Examples

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

Autotest

Stage 1.4: Add lines of walls

Add the capital W commmand to add lines of walls. CourseNana.COM

In this substage, you will need to the following: CourseNana.COM

  1. Given the command W [start_row] [start_col] [end_row] [end_col], add a line of walls from [start_row][start_col] to [end_row][end_col].
  2. If both start and end locations are out of bounds, print Location out of bounds.
  3. If only part of the line is out of bounds, add in the valid positions (ignore the out of bounds values) and don't print an error message.

Clarifications

  • We will only ask for values that form horizontal or vertical lines. We will never ask for a diagonal line.
  • We will only test values when start_row <= end_row and start_col <= end_col

Examples

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

Autotest

Testing and Submission

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

  • Run 1091 style, and clean up any issues a human may have reading your code. Don't forget -- 20% of your mark in the assignment is based on style!
  • Autotest for this stage of the assignment by running the autotest-stage command as shown below.
  • Remember -- give early, and give often. Only your last submission counts, but why not be safe and submit right now?
1091 style cs_sokoban.c
1091 autotest-stage 01 cs_sokoban
give dp1091 ass1_cs_sokoban cs_sokoban.c

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM

CourseNana.COM




CourseNana.COM

Assessment

Assignment Conditions

  • Joint work is not permitted on this assignment. CourseNana.COM

    This is an individual assignment. CourseNana.COM

    The work you submit must be entirely your own work. Submission of any work even partly written by any other person is not permitted. CourseNana.COM

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

    Assignment submissions will be examined, both automatically and manually for work written by others. CourseNana.COM

    Do not request help from anyone other than the teaching staff of DPST1091, e.g. in the course forum & help sessions. CourseNana.COM

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

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

  • The use of code-synthesis tools, such as GitHub Copilot, is not permitted on this assignment. CourseNana.COM

    Rationale: this assignment is intended to develop your understanding of basic concepts. Using synthesis tools will stop you learning these fundamental concepts. CourseNana.COM

  • Sharing, publishing, distributing your assignment work is not permitted. CourseNana.COM

    Do not provide or show your assignment work to any other person other than the teaching staff of DPST1091. For example, do not message your work to friends. CourseNana.COM

    Do not publish your assignment code via the internet. For example, do not place your assignment in a public GitHub repository. CourseNana.COM

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

  • Sharing, publishing, distributing your assignment work after the completion of DPST1091 is not permitted. CourseNana.COM

    For example, do not place your assignment in a public GitHub repository after DPST1091 is over. CourseNana.COM

    Rationale: DPST1091 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. CourseNana.COM

Violation of the above conditions may result in an academic integrity investigation with possible penalties, up to and including a mark of 0 in DPST1091 and exclusion from UNSW. CourseNana.COM

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

Note, you will not be penalised if your work is taken without your consent or knowledge. CourseNana.COM

For more information, read the UNSW Student Code, or contact the course account. The following penalties apply to your total mark for plagiarism: CourseNana.COM

0 for the assignmentKnowingly providing your work to anyone and it is subsequently submitted (by anyone).
0 for the assignmentSubmitting any other person's work. This includes joint work.
0 FL for DPST1091Paying another person to complete work. Submitting another person's work without their consent.


Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
UNSW代写,DPST1091代写,CPTG1391代写,Programming Fundamentals代写,Sokoban代写,C代写,UNSW代编,DPST1091代编,CPTG1391代编,Programming Fundamentals代编,Sokoban代编,C代编,UNSW代考,DPST1091代考,CPTG1391代考,Programming Fundamentals代考,Sokoban代考,C代考,UNSWhelp,DPST1091help,CPTG1391help,Programming Fundamentalshelp,Sokobanhelp,Chelp,UNSW作业代写,DPST1091作业代写,CPTG1391作业代写,Programming Fundamentals作业代写,Sokoban作业代写,C作业代写,UNSW编程代写,DPST1091编程代写,CPTG1391编程代写,Programming Fundamentals编程代写,Sokoban编程代写,C编程代写,UNSWprogramming help,DPST1091programming help,CPTG1391programming help,Programming Fundamentalsprogramming help,Sokobanprogramming help,Cprogramming help,UNSWassignment help,DPST1091assignment help,CPTG1391assignment help,Programming Fundamentalsassignment help,Sokobanassignment help,Cassignment help,UNSWsolution,DPST1091solution,CPTG1391solution,Programming Fundamentalssolution,Sokobansolution,Csolution,