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.

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

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

Initial Code and Data Structures

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

  • A print_board(...) function:
    • This prints out the current state of the board, allowing the user to play the game.
    • This ensures that the board will be consistent between you and the autotest.
  • A init_board(...) function:
    • This sets up the board with default values.
  • A 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.
  • A enum base enum:
    • This is used within struct tile. Every position on the board must be exactly 1 of these values (NONE, WALL, or STORAGE).

Lets have a look at what an example of a board might look like via the print_board() function:

-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |===|===|===|===|===|===|   |   |
-----------------------------------------
|   |   |===|   |^_^|[ ]| o |===|   |   |
-----------------------------------------
|   |   |===|===|===|===|===|===|   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

Here we have some tiles that contain:

  • walls ===
  • a box [ ]
  • a storage location o
  • the player ^_^

After moving the player to the right, we can push the box onto the storage location (which will solve the level).

-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |===|===|===|===|===|===|   |   |
-----------------------------------------
|   |   |===|   |   |^_^|[o]|===|   |   |
-----------------------------------------
|   |   |===|===|===|===|===|===|   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

Each of the 10x10 grid contains a single struct tile, this allows us to store information about the board. Looking at a couple of these, we can see how it works:

  • board[2][2] (top left wall) has the value of: board[2][2].base == WALL and board[2][2].box == false.
  • board[3][6] (contains the box and storage location) has the value of: board[3][6].base == STORAGE and board[3][6].box == true.

Where do we store the player?

The player isn't stored in the board, instead the print_board() function just asks you where the player is at any given time.

  • for the above example: print_board(board, 3, 5);.

So you have flexibility over how to store the player! (e.g. variables for the row/col, or perhaps a struct that contains both row & col!)

Reference Implementation

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

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

Try the following input in the reference implementation:

w 3 2
w 3 7
W 2 2 2 7
W 4 2 4 7
s 3 6
b 3 4
q
3 3
d
d

FAQ

Q: Can I edit the given starter code functions/structs/enums?

Yes. You can edit any of the functions/structs/enums given in the starter code. You can delete the whole starter code and start from scratch if you really want to (not recommended).

Some later stages might require you to edit the tile struct.

Q: Can I use pointers

The assignment can be done without pointer, but you can use them if you wish.

Q: Can I use X other C feature

A: For everything not taught in the course, check the style guide. If it says "Avoid", then we may take style marks off if its not used correctly. If it says "Don't Use" then we will take style marks off (see the style marking rubric).

Stages

We have broken the assignment spec down into incremental stages:

  • Stage 1: 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.

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.

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

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

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)

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.

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

  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 :)

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:

Input:

w 0 1
s 0 2
[ctrl-d]

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
w 0 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |===|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s 0 2
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |===| o |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Input:

w 2 2
s 2 2
w 2 2
[ctrl-d]

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
w 2 2
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |===|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s 2 2
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   | o |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

w 2 2
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |===|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

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!

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

  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

Input:

w -1 -1
w 2 10000
s 10 10
s 9 9
[ctrl-d]

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
w -1 -1
Location out of bounds
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

w 2 10000
Location out of bounds
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s 10 10
Location out of bounds
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s 9 9
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   | o |
-----------------------------------------

[ctrl-d]

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.

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

  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

Input:

b 0 0
b 0 1
[ctrl-d]

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
b 0 0
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|[ ]|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

b 0 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|[ ]|[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Input:

b 0 0
s 0 0
s 0 1
b 0 1
[ctrl-d]

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
b 0 0
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|[ ]|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s 0 0
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|[o]|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s 0 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|[o]| o |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

b 0 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|[o]|[o]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Input:

b 0 0
w 0 1
w 0 0
b 0 1
[ctrl-d]

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
b 0 0
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|[ ]|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

w 0 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|[ ]|===|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

w 0 0
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|===|===|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

b 0 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|===|[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Input:

b -1 -1
b 0 10
b 9 9
[ctrl-d]

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
b -1 -1 
Location out of bounds
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

b 0 10
Location out of bounds
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

b 9 9
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |[ ]|
-----------------------------------------

[ctrl-d]

Input:

b 0 0
w 0 0
s 0 0
[ctrl-d]

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
b 0 0
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|[ ]|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

w 0 0
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s 0 0
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
| o |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Autotest

Stage 1.4: Add lines of walls

Add the capital W commmand to add lines of walls.

In this substage, you will need to the following:

  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

Input:

W 0 0 9 0
W 2 3 2 8
[ctrl-d]

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
W 0 0 9 0
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------

W 2 3 2 8
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|===|   |   |===|===|===|===|===|===|   |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Input:

b 0 3
s 0 4
w 0 5
W 0 0 0 9
[ctrl-d]

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
b 0 3
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |[ ]|   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s 0 4
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |[ ]| o |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

w 0 5
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |[ ]| o |===|   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

W 0 0 0 9
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|===|===|===|===|===|===|===|===|===|===|
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Input:

W 3 4 3 100
W 10 10 11 10
[ctrl-d]

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
W 3 4 3 100
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |===|===|===|===|===|===|
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

W 10 10 11 10
Location out of bounds
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |===|===|===|===|===|===|
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Autotest

Testing and Submission

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

  • 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

Stage 2

In Stage 2, you will implement player movement for the gameplay. It includes setting a starting location, allowing for player movement, and counting the number of moves a player has made.

Here is an example of input for a finished stage 2 that you can try on the reference implementation.

b 5 5
w 0 0
s 0 1
q
0 0
2 2
a
w
w
a
w
a
s

Stage 2.1: Add the player's starting location and start the game

After adding all the walls/boxes/storage locations to the board, we have to allow the level creator to pick a starting location for the player.

In this substage, you will need to the following:

  1. Allow the level creator to use the command q (instead of [ctrl-d]) to exit the level builder.
  2. Prompt the level creator to give a player position. "Enter player starting position: ".
  3. Scan in two integers for the player row and col.
  4. Check that the position is valid. If not, print "Position ([row], [col]) is invalid\n" and repeat step 2.
  5. Once a valid position is given, declare the game started by printing "\n=== Starting Sokoban! ===\n" and printing the board.

What is a valid player position?

  • In the bounds of the board.
  • Not at the same location as a wall or box (adding the player to a storage location is fine).

Examples

Input:

w 0 0
q
0 1

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
w 0 0
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: 0 1

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|===|^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

Input:

w 2 3
b 2 4
q
-1 -1
10 3
2 3
2 4
2 5

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
w 2 3
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |===|   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

b 2 4
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |===|[ ]|   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: -1 -1
Position (-1, -1) is invalid
Enter player starting position: 10 3
Position (10, 3) is invalid
Enter player starting position: 2 3
Position (2, 3) is invalid
Enter player starting position: 2 4
Position (2, 4) is invalid
Enter player starting position: 2 5

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |===|[ ]|^_^|   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

Input:

s 0 0
q
0 0

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
s 0 0
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
| o |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: 0 0

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|^_^|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

Autotest

Stage 2.2: Gameplay Commands and Player movement

The player needs to be able give commands to actually play the game. Let's start a new command loop for gameplay commands and implement commands w, a, s, d for each direction.

In this substage, you will need to the following:

  1. Scan in a command.
  2. If the command is one of wasd, move the player in that direction.
  3. If the new position of the player is an invalid location (contains a wall), then don't move the player.
  4. Print out the board.
  5. Repeat the prompts until [ctrl-d].

Clarifications

  • For this stage, we won't check players moving off the edge of the board (stage 2.3).
  • For this stage, we won't check players moving into boxes (stage 3.1).
  • Players can walk on top of storage locations.
  • We won't test gameplay commands that are not defined in the spec (this stage and onwards)

Examples

Input:

q
0 0
s
d
w
a
[ctrl-d]

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
q
Enter player starting position: 0 0

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|^_^|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|^_^|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

d
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

w
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

a
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|^_^|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Input:

w 0 0
s 0 1
q
1 0
w
d
w
[ctrl-d]

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
w 0 0
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s 0 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|===| o |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: 1 0

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|===| o |   |   |   |   |   |   |   |   |
-----------------------------------------
|^_^|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

w
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|===| o |   |   |   |   |   |   |   |   |
-----------------------------------------
|^_^|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

d
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|===| o |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

w
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|===|^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

d
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|===| o |^_^|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Autotest

Stage 2.3: Board Wrapping

Let's add to the previous movement commands the ability for players to wrap around the board when they reach the edge.

In this substage, you will need to the following:

  1. During a wasd command, if the player walks off the edge of the board, their new location will be on the opposite side.

Examples

Input:

q
0 0
w
a
[ctrl-d]

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
q
Enter player starting position: 0 0

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|^_^|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

w
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|^_^|   |   |   |   |   |   |   |   |   |
-----------------------------------------

a
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |^_^|
-----------------------------------------

[ctrl-d]

Input:

w 0 9
q
0 0
a
[ctrl-d]

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
w 0 9
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |===|
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: 0 0

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|^_^|   |   |   |   |   |   |   |   |===|
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

a
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|^_^|   |   |   |   |   |   |   |   |===|
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Autotest

Stage 2.4: Movement counter

One challenge of sokoban is trying to solve a puzzle in as little movements as possible. Create a new command c for the gameplay that prints out the counter of number of moves.

In this substage, you will need to the following:

  1. When a player makes a valid move, increment the counter.
    • The only invalid moves currently are when walls block player movement.
  2. When the c command is called, print out "Number of moves so far: current_moves\n".
  3. Print out the board

Examples

Input:

q
0 0
d
d
c
[ctrl-d]

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
q
Enter player starting position: 0 0

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|^_^|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

d
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

d
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |^_^|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

c
Number of moves so far: 2
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |^_^|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Input:

w 0 0
q
0 1
a
c
[ctrl-d]

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
w 0 0
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: 0 1

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|===|^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

a
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|===|^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

c
Number of moves so far: 0
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|===|^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Autotest

Testing and Submission

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

  • 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 02 cs_sokoban
give dp1091 ass1_cs_sokoban cs_sokoban.c

Stage 3

In Stage 3, you will implement the rest of the core functionality to have a working sokoban game! It includes moving boxes, stating when a player has won the game, and allowing someone to reset if they get stuck.

Stage 3.1: Moving boxes

An important part of Sokoban allowing players to push boxes around the board. Give the wasd movement the functionality to push boxes around the board.

  1. Edit your wasd command so that:
    • If a player moves into a box, both the player and the box move in that direction
  2. If due to the move, the board is invalid (such as moving a box into a wall), then do nothing.

Clarifications

  • Currently only 1 box can move at a time (stage 4.2 will cover moving multiple boxes). We won't test moving boxes into other boxes for this stage.
  • If a player attempts to moves a box blocked by a wall, it doesn't count as a valid move that adds to the counter.

Examples

Input:

b 1 1
s 2 1
q
0 1
s
[ctrl-d]

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
b 1 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s 2 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   | o |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: 0 1

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   | o |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[o]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Input:

w 0 0
b 0 1
q
0 2
a
[ctrl-d]

Input and Output:

./cs_sokoban
dcc cs_sokoban.c -o cs_sokoban
=== Level Setup ===
w 0 0
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|===|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

b 0 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|===|[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: 0 2

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|===|[ ]|^_^|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

a
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|===|[ ]|^_^|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Input:

b 0 0
q
0 1
a
a
[ctrl-d]

Input and Output:

./cs_sokoban
dcc cs_sokoban.c -o cs_sokoban
=== Level Setup ===
b 0 0
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|[ ]|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: 0 1

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|[ ]|^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

a
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|^_^|   |   |   |   |   |   |   |   |[ ]|
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

a
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |[ ]|^_^|
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Autotest

Stage 3.2: Win condition

Once all blocks have been stored away, the game wins.

  1. After each move, check if the game is in a winning state. This means that all boxes are being stored in a storage location.
  2. If the game has been won, print out "=== Level Solved in [n_moves] Moves! ===\n" and end the program.
    • If the number of moves is 1, then print out "Move" instead of "Moves".

Clarifications

  • Make sure that the last state of the game gets printed out before declaring the win condition.
  • We won't test any boards that start in a winning state (this includes boards with no boxes to begin with).
  • We may test cases that cannot be won (e.g. no storage locations)
  • The game can be won with uncovered storage locations, the only condition is that all boxes are stored.

Examples

Input:

b 1 1
s 2 1
q
0 1
s

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
b 1 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s 2 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   | o |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: 0 1

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   | o |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[o]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

=== Level Solved in 1 Move! ===

Input:

b 1 1
b 1 2
s 2 1
s 1 3
q
0 1
s
d

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
b 1 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

b 1 2
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s 2 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   | o |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s 1 3
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|[ ]| o |   |   |   |   |   |   |
-----------------------------------------
|   | o |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: 0 1

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|[ ]| o |   |   |   |   |   |   |
-----------------------------------------
|   | o |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |^_^|[ ]| o |   |   |   |   |   |   |
-----------------------------------------
|   |[o]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

d
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |^_^|[o]|   |   |   |   |   |   |
-----------------------------------------
|   |[o]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

=== Level Solved in 2 Moves! ===

Input:

b 1 1
s 1 2
s 2 1
q
0 1
s

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
b 1 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s 1 2
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]| o |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s 2 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]| o |   |   |   |   |   |   |   |
-----------------------------------------
|   | o |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: 0 1

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]| o |   |   |   |   |   |   |   |
-----------------------------------------
|   | o |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |^_^| o |   |   |   |   |   |   |   |
-----------------------------------------
|   |[o]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

=== Level Solved in 1 Move! ===

Autotest

Stage 3.3: Reset game

If a player moves boxes around the board in an incorrect way, they might get stuck in a state that can never lead to a winning condition. Add a reset command to the gameplay so that a player can reset back to the beginning.

  1. Add an r command to the gameplay.
  2. Print out "=== Resetting Game ===\n"
  3. Reset the board, player position, and counter to the original state. The original state is the state after the level has been setup, and the player is first positioned.

Examples

Input:

b 1 1
q
0 1
s
r
c
[ctrl-d]

Input and Output:

dcc cs_sokoban.c -o cs_sokoban
./cs_sokoban
=== Level Setup ===
b 1 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: 0 1

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

r
=== Resetting Game ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

c
Number of moves so far: 0
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

Autotest

Testing and Submission

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

  • 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 03 cs_sokoban
give dp1091 ass1_cs_sokoban cs_sokoban.c

Stage 4

In Stage 4, you will implement some more advanced features for your sokoban level builder and game! It includes an undo button, pushing rows of boxes, and allowing boxes to be linked!

Stage 4.1: Undo button

Sometimes in Sokoban, you can make an incorrect move that results in the game being unsolvable. At this stage, your only option is to reset the whole game. Create a u command that allows users to undo any move that they have done so far!

  1. Add the u command to the gameplay.
  2. Undo the most recent valid move by returning to the state of the board to before that action was taken.

Clarifications

  • We will only test for the first 1000 valid moves in any given game.
  • After undo-ing, you don't need to save those states (aka: for redos or undo tree behaviour).
  • Undo-ing at the initial state does nothing.
  • Resetting the game cannot be undone.

Examples

Input:

b 1 1
q
0 1
s
u
[ctrl-d]

Input and Output:

=== Level Setup ===
b 1 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: 0 1

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

u
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Input:

b 1 1
w 3 1
q
0 1
s
s
u
[ctrl-d]

Input and Output:

./cs_sokoban
=== Level Setup ===
b 1 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

w 3 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |===|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q 
Enter player starting position: 0 1

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |===|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |===|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |===|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

u
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |===|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Input:

b 1 1
w 3 1
b 1 2
q
0 1
s
s
d
c
u
c
u
c
[ctrl-d]

Input and Output:

./cs_sokoban
=== Level Setup ===
b 1 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

w 3 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |===|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

b 1 2
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |===|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: 0 1

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |===|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |^_^|[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |===|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |^_^|[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |===|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

d
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |^_^|[ ]|   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |===|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

c
Number of moves so far: 2
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |^_^|[ ]|   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |===|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

u
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |^_^|[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |===|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

c
Number of moves so far: 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |^_^|[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |===|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

u
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |===|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

c
Number of moves so far: 0
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |===|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Autotest

Stage 4.2: Pushing multiple boxes

Currently, players can only move 1 box at a time. In the scenario a player pushes a box, and there is another box behind it, the player will end up moving both boxes. There could be a series of boxes in a row!

  1. Edit your wasd commands so that multiple boxes in a row can move.

Examples

Input:

b 0 1
b 0 2
q
0 0
d
[ctrl-d]

Input and Output:

./cs_sokoban

=== Level Setup ===
b 0 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

b 0 2
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |[ ]|[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: 0 0

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|^_^|[ ]|[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

d
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |^_^|[ ]|[ ]|   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Input:

b 0 1
b 0 2
w 0 3
q
0 0
d
[ctrl-d]

Input and Output:

./cs_sokoban
=== Level Setup ===
b 0 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

b 0 2
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |[ ]|[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

w 0 3
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |[ ]|[ ]|===|   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: 0 0

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|^_^|[ ]|[ ]|===|   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

d
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|^_^|[ ]|[ ]|===|   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Input:

b 0 0
b 9 0
q
1 0
w
w
[ctrl-d]

Input and Output:

./cs_sokoban
=== Level Setup ===
b 0 0
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|[ ]|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

b 9 0
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|[ ]|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|[ ]|   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: 1 0

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|[ ]|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|^_^|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|[ ]|   |   |   |   |   |   |   |   |   |
-----------------------------------------

w
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|^_^|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|[ ]|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|[ ]|   |   |   |   |   |   |   |   |   |
-----------------------------------------

w
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|[ ]|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|[ ]|   |   |   |   |   |   |   |   |   |
-----------------------------------------
|^_^|   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Autotest

Stage 4.3: Link 2 boxes

To make our sokoban game more interesting, we can add the feature of linking 2 boxes together.

  1. In your level builder, add a link command: l [row_1] [col_1] [row_2] [col_2] which links the two boxes at those locations.
  2. If one or both of the locations were either not a box or out of bounds, then print "Invalid Location(s)\n".
  3. Once two boxes are linked when moving boxes, any push to one of the boxes acts as though there a push in the same direction happening to the other box at the exact same time.

Clarifications

  • If two linked boxes are in the same line of boxes being moved at once (due to stage 4.2: pushing multiple boxes), we think of the forces as acting at the exact same time (so in essence, it looks the same as if they were not linked). Example 4.3.5 shows this behaviour.
  • You may end up having more than 2 boxes in the same linked group. Example 4.3.4 shows this.
  • In regard to implementing the move counter:
    • A valid move (aka something that adds to the counter) was previously defined as any move where the player was not blocked by a wall. But now we can have a case where the player doesn't move, but a box does (e.g. example 4.3.3).
    • From now on, a valid move is the case where either:
      • The player was not blocked by a wall/box, or,
      • At least 1 box was pushed (either directly, in a row, or by linking) and was not blocked from moving.
    • There are a couple cases where the board will look identical, but a valid move has been executed (hence the counter increases).

Examples

Input:

b 0 1
b 2 3
l 0 1 2 3
q
0 0
d
[ctrl-d]

Input and Output:

./cs_sokoban
=== Level Setup ===
b 0 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

b 2 3
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |[ ]|   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

l 0 1 2 3
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |[ ]|   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: 0 0

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|^_^|[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |[ ]|   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

d
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |^_^|[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |[ ]|   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Input:

b 0 1
b 2 3
w 2 4
l 0 1 2 3
q
0 0
d
[ctrl-d]

Input and Output:

./cs_sokoban
=== Level Setup ===
b 0 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

b 2 3
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |[ ]|   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

w 2 4
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |[ ]|===|   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

l 0 1 2 3
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |[ ]|===|   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: 0 0

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|^_^|[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |[ ]|===|   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

d
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |^_^|[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |[ ]|===|   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Input:

b 0 1
b 2 3
w 0 2
l 0 1 2 3
q
0 0
d
[ctrl-d]

Input and Output:

./cs_sokoban
=== Level Setup ===
b 0 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

b 2 3
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |[ ]|   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

w 0 2
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |[ ]|===|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |[ ]|   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

l 0 1 2 3
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |[ ]|===|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |[ ]|   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: 0 0

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|^_^|[ ]|===|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |[ ]|   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

d
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|^_^|[ ]|===|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |[ ]|   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Input:

b 1 1
b 1 2
b 1 3
b 1 4
l 1 1 1 2
l 1 3 1 4
l 1 1 1 4
q
0 1
s
[ctrl-d]

Input and Output:

./cs_sokoban
=== Level Setup ===
b 1 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

b 1 2
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

b 1 3
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|[ ]|[ ]|   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

b 1 4
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|[ ]|[ ]|[ ]|   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

l 1 1 1 2
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|[ ]|[ ]|[ ]|   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

l 1 3 1 4
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|[ ]|[ ]|[ ]|   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

l 1 1 1 4
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|[ ]|[ ]|[ ]|   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: 0 1

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|[ ]|[ ]|[ ]|   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |^_^|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|[ ]|[ ]|[ ]|   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Input:

b 1 1
b 1 2
l 1 1 1 2
q
1 0
d
[ctrl-d]

Input and Output:

./cs_sokoban
=== Level Setup ===
b 1 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

b 1 2
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

l 1 1 1 2
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |[ ]|[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: 1 0

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|^_^|[ ]|[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

d
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |^_^|[ ]|[ ]|   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Input:

b 0 1
b 0 2
b 1 2
l 0 2 1 2
q
0 0
d
s
d
d
[ctrl-d]

Input and Output:

./cs_sokoban
=== Level Setup ===
b 0 1
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |[ ]|   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

b 0 2
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |[ ]|[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

b 1 2
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |[ ]|[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

l 0 2 1 2
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |[ ]|[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

q
Enter player starting position: 0 0

=== Starting Sokoban! ===
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|^_^|[ ]|[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |[ ]|   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

d
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |^_^|[ ]|[ ]|   |   |   |   |   |   |
-----------------------------------------
|   |   |   |[ ]|   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

s
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |[ ]|[ ]|   |   |   |   |   |   |
-----------------------------------------
|   |^_^|   |[ ]|   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

d
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |[ ]|[ ]|   |   |   |   |   |   |
-----------------------------------------
|   |   |^_^|[ ]|   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

d
-----------------------------------------
|             S O K O B A N             |
-----------------------------------------
|   |   |[ ]|   |[ ]|   |   |   |   |   |
-----------------------------------------
|   |   |   |^_^|[ ]|   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------
|   |   |   |   |   |   |   |   |   |   |
-----------------------------------------

[ctrl-d]

Autotest

Testing and Submission

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

  • 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 04 cs_sokoban
give dp1091 ass1_cs_sokoban cs_sokoban.c

Extension

As an extension, we have set up a starting point to add a texture pack to your game via splashkit.

Extension activities are not work any marks, nor are there any autotests.

Installing Splashkit

To install splashkit, run the following command:

1091 setup-splashkit cs_sokoban

Next, open a new terminal to use the updated environment.

Check that Splashkit Works

Lets check that splashkit works by running a test file. It should display a white square with a grid inside.

The previous command should have added splashkit_example.c to your current directory. If you can't find it, run: cp -n /web/dp1091/24T3/activities/cs_sokoban/splashkit_example.c ..

skm clang++ splashkit_example.c -o splashkit_example
./splashkit_example

Running your code with splashkit

The last two commands are a bit like your new dcc cs_sokoban.c -o cs_sokoban and ./cs_sokoban but for splashkit. So it will look a bit like:

skm clang++ cs_sokoban.c -o cs_sokoban
./cs_sokoban

Starting Points for Splashkit

Have a look inside of splashkit_example.c to see what they have added. A couple things to note are:

  • #include "splashkit.h" is needed at the top of the file.
  • Line 48, window w = open_window("Splashkit Example", 600, 400); needs to be run when you decide to open your viewable window.
  • The loop in main allows us to update the screen according to any user events, and refreshes the screen after anything is drawn on the frame.

CS Sokoban assets

If you wish to use assets similar to the demo project run cp -rn /web/dp1091/24T3/activities/cs_sokoban/splashkit_assets .

Tools

Creating Levels in Separate Files

If you are getting sick of typing in your level creation every single time you run sokoban, you might want to store your input in a separate file. This allows you to play your level straight away.

1. Create a file for your input.

First, let's create a file to store in the input for a level that you have created. This isn't a .c file, its just a regular plain text file, the file extension .in works nicely for this!

Let's put it in the same directory as your cs_sokoban.c code.

ls
cs_sokoban.c 
cs_sokoban 
my_level.in

2. Add your input to the file

Inside of this file, add in the input for the level builder, as well as the player position. Don't add in any of the 'wasd' movement commands as those will come from the terminal. My file looks a bit like this:

Make sure there is a new line after the player position.

b 1 1
b 2 2
b 3 3
q
9 9

3. Run the code with your file

Next, instead of just running ./cs_sokoban, lets tell the computer to first read from that file, before taking input from the terminal. We can do that like this:

cat my_level.in - | ./cs_sokoban

This will also work on the reference implementation too!

cat my_level.in - | 1091 cs_sokoban

Example Levels

We have created you some levels to play! Each level is prefixed with the stage that is needed to be completed for the level to work. work

To get the levels, run the following code in the same directory you have your cs_sokoban.c.

1091 fetch-levels cs_sokoban

The levels included are:

  • 2.2_heart.in
  • 2.3_maze.in
  • 3.2_classic.in
  • 4.3_remote_control.in
  • 4.3_break_my_heart.in

Community Levels

If you want to create your own levels, we encourage you to share them on the Assignments channel in Teams. Prefix it with the stage required, and post it 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 DPST1091, 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.

    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 DPST1091. 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 DPST1091 is not permitted.

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

    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.

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.

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 DPST1091 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_sokoban.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 dp1091 ass1_cs_sokoban cs_sokoban.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_sokoban.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 functions are present, but functions are all more than 50 lines Some functions are present, and all functions are approximately 50 lines long Most code has been moved to sensible/thought out functions, but they are mostly more than 50 lines max (incl. main function) All code has been meaningfully decomposed into functions of approx 50 lines (incl. 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 DPST1091. 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 Week 8 Friday 09:00am (2024-10-18 09:00:00). For each day after that time, the maximum mark it can achieve will be reduced by 5% (off the ceiling).
  • For instance, at 1 day past the due date, the maximum mark you can get is 95%.
  • For instance, at 3 days past the due date, the maximum mark you can get is 85%.
  • For instance, at 5 days past the due date, the maximum mark you can get is 75%.
  • No submissions will be accepted after 5 days late, unless you have special provisions in place.