Answered step by step
Verified Expert Solution
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 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 printboard 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 initboard function:
This sets up the board with default values.
A struct tile struct:
Each square of the board aka the D 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 of these values NONE WALL, or STORAGE
Lets have a look at what an example of a board might look like via the printboard 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
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started