Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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!
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]|===|||
-----------------------------------------
|||===|===|===|===|===|===|||
-----------------------------------------
||||||||

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design For Mere Mortals

Authors: Michael J Hernandez

4th Edition

978-0136788041

More Books

Students also viewed these Databases questions