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

DPST1091/CPTG1391 Programming Fundamentals - Assignment 1: Sokoban

Order Now
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. Assignment Writing Service

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

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].) Assignment Writing Service

Initial Code and Data Structures

The starter code for this assignment includes some functions and defined types: Assignment Writing Service

  • 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).

Assignment Writing Service

Assignment Writing Service

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. Assignment Writing Service

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

Assignment Writing Service

Assignment Writing Service

FAQ

Assignment Writing Service

Assignment Writing Service

Stages

We have broken the assignment spec down into incremental stages: Assignment Writing Service

  • 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. Assignment Writing Service

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. Assignment Writing Service

There is a reference implementation that you can play by running the command 1091 cs_sokoban in the terminal. Assignment Writing Service

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

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) Assignment Writing Service

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. Assignment Writing Service

In this substage, you will need to do the following: Assignment Writing Service

  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 :) Assignment Writing Service

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:

Assignment Writing Service

Assignment Writing Service

Assignment Writing Service

Assignment Writing Service

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! Assignment Writing Service

In this substage, you will need to do the following: Assignment Writing Service

  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

Autotest

Examples

Assignment Writing Service

Assignment Writing Service

Assignment Writing Service

Assignment Writing Service

Assignment Writing Service

Assignment Writing Service

Assignment Writing Service

Assignment Writing Service

Assignment Writing Service

Assignment Writing Service

Autotest

Stage 1.4: Add lines of walls

Add the capital W commmand to add lines of walls. Assignment Writing Service

In this substage, you will need to the following: Assignment Writing Service

  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

Autotest

Testing and Submission

Are you finished with this stage? If so, you should make sure to do the following: Assignment Writing Service

  • 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

Assignment Writing Service

Assignment Writing Service

Assignment Writing Service

Assignment Writing Service

Assignment Writing Service

Assignment Writing Service

Assignment Writing Service

Assignment Writing Service

Assignment Writing Service

Assignment Writing Service



联系辅导老师!
私密保护
WeChat 微信
UNSW代写,DPST1091代写,CPTG1391代写,Programming Fundamentals代写,Sokoban代写,C代写,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编程代写,UNSW作业答案,DPST1091作业答案,CPTG1391作业答案,Programming Fundamentals作业答案,Sokoban作业答案,C作业答案,