Introduction
SKBN is a Sokoban clone for Master System. I published a first version in 2021
for the smspower.org programming contest. The current version (v2) has new
content and features:
- Even more levels! Now a total of 1736 levels!
Jacques Duthen sent me unpublished levels (Sokogen 990702, 990917 et 991123) and I created
my own collection of 100 (mostly easy) levels (raphnet 100).
- New themes
Four color/artwork themes are available (V2, V1, Mac et KSoko) and can be selected from the options
menu.
- Point mode
From the options menu, Point mode (vs. walk mode) can now be enabled. In this mode, you just
point to where the character should go and the game finds the shortest path. To push a box,
simply click on the box when the character is standing next to it.
- Support for the Sports Pad and the Mega Mouse[1]
Those peripherals are perfect to move a pointer! They are fully supported and auto-detected
at startup in port 1 or 2.
- New title screen
I redid the title screen as I did not really like the old one.
[1] The Mega Mouse only works on Master system consoles and cannot be used
on Mark III systems.
Development log/history (v2)
When I make games, I am often motivated by specific technical challenges. In V1, my challenge was to implement an engine supporting
different tiles sizes, despite the SMS native 8x8 tiles. This made the 4x4 and 12x12 engines a lot of fun.
In V2, I wanted to learn and implement path finding to upgrade the controls to feel more modern. Today, many online or mobile
implementations of this game use a pointing device to control the player, which means that instead of walking to a desination
step by step, you just say "go there" and it happens, provided that a path exists. I really like this approach as it saves a lot of time.
So the challenge understanding how path finding algorithms work, and choosing or adapting one so it would work given
the system memory constranints. It turned out to be easier than I though. What I did is similar to the Sample algorithm
described on the
Pathfinding wikipedia page.
To search the optimal path, each location needs a counter indicating its distance. The SMS only has 8kB of RAM and I was already
tight on memory. But I already had an array of bytes of 64x48 to hold the level state. Each byte indicates if this is a wall,
floor, a box, a target, a box on a target, or outside space. Only 3 bits are used, meaning the upper 5 bits were free. This is
where I store the distance. No need for a new array!
Path finding algorithms often seem to use a list or queue of next locations to examine, but I was not sure how big of a list I would
need to be certain that the algorithm would work even for the large levels, and if this list would fit into memory... So I came
up with this algorithm which does not use a list. Instead it scans the full surface of the level to find new canditates.
Stage 1: Init and seed
- Init distance of locations to 0
- Set distance of locations left/right/above/below the player to 1 if they are walkable. (walkable = floor or target)
- Set cur_distance to 1.
Stage 2: Search until destination is found
For each location where distance =
cur_distance, do:
- For walkable neighbor that still have a distance of 0, set distance to cur_distance+1
- If a neighbor was the destination, stop here and enter stage 3
- If there were no locations at all with distance = cur_distance, there is no open path, give up here.
- Increment cur_distance. If cur_distance becomes greater than 30 (the max. that fits in 5
bits minus one) set it back to 1. (not 0).
- Repeat.
Stage 3: Back track and mark the path
If we are here, the destination was reached. It is now time to mark the path the player will follow. The value of 31 is reserved for this.
Set
cur_distance to the distance of the destination, and set the distance of the destination to 31 (path marker). Then, starting with
the current position set to the destination:
- Look at neighbors and select one where distance = cur_distance - 1 (or 30 if cur_distance is 1). If there are several
equal canditates, just pick any. Set the distance of the picked neighbor to 31 (path marker).
- Set the current position to the selected neighbor.
- Decrease cur_distance. If if falls below 1, set it to 30.
- Repeat from step 1 until the starting point is found
Stage 4: Move the player along the marked path
At this point, the player can just move following the path markers.
Starting with the current player position:
- Look to neighbors for a path marker (31).
- Move player to that neighbor.
- Clear the path marker.
- Repeat until no path markers are found. The player should then be on the target.
The above worked fine, but it was a bit slow due to the way Stage 2 scans the whole level all the time. So I ended up adding
a short list of "next locations" which Stage 2 uses. The list is short, so if it fills up, no problem, the algorithm reverts to the
"scan the whole level" approach and everything still works.
The only thing left after this worked was to add support for pointing devices such as the Sports Pad and the Mega Mouse. I was pleasantly surprised
by the the Sports Pad. My experience with it, using the Sports Pad Soccer game was far from good... but it turned out to work very well when used as
Trackball to move a pointer!
Here is a video showing the path finding in action. Doing all this walking around manually would be a bit unpleasant, wouldn't it?
Development log/history (v1)
Yes, yes, another Sokoban clone.. But this one has lost its vowels ;-)
SKBN is a sokoban clone called SKBN. The 128kB ROM contains the 1043 levels of the Microban and Sasquatch level sets created by David W. Skinner.
In this project, I focused mostly on making sure that all levels of those sets would be playable, even large ones.
To achieve this, the engine supports different tile sizes: 24x24, 16x16, 12x12, 8x8 and 4x4.
The 12x12 engine was the most challenging, as the two grids of 8x8 tiles (native) and 12x12 tiles
(virtual) create interesting complications, combining vertical and/or horizontal splits. The required tiles
are built on-the-fly while displaying and playing the level.
The 4x4 engine is useful for previews, but also for very large levels. But those may not be very playable
unless you use an emulator or an RGB-connected display.
The in-game menu has options to undo a move or the last push. The history can hold 1000 moves.
Of course, solving more than 1000 levels in one session is unthinkable (probably) so the completion status of the levels is saved in SRAM,
or directly on flash, if the game is running on a compatible cartridge such as
those I designed...
Download
Version 2.0 September 14, 2022 (Wednesday) |
---|
After about a year of working part time on this project, version 2 is finally ready!- Added 100 raphnet levels (mostly very easy)
- Added more levels by Jacques Duthen, previously unpublished: Sokogen-990702, Sokogen-990917, and Sokogen-991123
- Updated the title screen
- Added options and credits screens
- Add themes: New (V2), Mac and Ksoko. V1 theme still available.
- Change keys in-game: Button 1 opens the menu, Button 2 undos the last push.
- Support for point mode (with path finding)
- Support for the Sports Pad and the Mega Mouse
- Add background music (can be turned off in the options)
|
File(s): skbn-v2.zip (186.7 KB)
|
Version 1.4 May 21, 2021 (Friday) |
---|
Correct the spelling of 'Dimitri & Yorick' |
File(s): skbn-v1.4.zip (125.2 KB)
|
Version 1.3 March 31, 2021 (Wednesday) |
---|
- Add a 'Well Done' message when solving a level
- Fix a bug where the player could move in diagonal, and undoing the last move would then remove a wall block and add a new box to the level!
- Move the Level number in the status bar one column to the right to avoid displaying text in the first column.
- Small tweaks to the tile screen (sharper box corner, black countour)
|
File(s): skbn-v1.3.zip (125.2 KB)
|
Version 1.2 March 30, 2021 (Tuesday) |
---|
- Added a 24x24 tiles mode.
- Boxes now move smoothly, in-sync with the player when pushed. (instead of teleporting).
- Reworked the player artwork and other small cosmetic details.
- Correct a bug which caused unsolved levels to show as solved in the menu when scrolling.
- Display 'player on target' correctly during previews.
|
File(s): skbn-v1.2.zip (121.4 KB)
|
Version 1.1 March 29, 2021 (Monday) |
---|
- Add a short 'end level' jingle.
- Add 'Dimitri & Yorick' and 'Sokogen-990602' level sets by Jacques Duthen (Easy levels)
- Fixed the 'parallax' effect at the end of a level (was not well controlled and jittery on real hardware).
- Correct initial player position (was not centered until first movement)
- Fine tune player sprite position in 12x12 tiles levels (was a bit too low)
- Remove the debug info (number in upper right corner) in 12x12 tile display mode
|
File(s): skbn-v1.1.zip (115.2 KB)
|
Version 1.0 March 27, 2021 (Saturday) |
---|
First release for smspower.org coding competition 2021 |
File(s): skbn_release_smscomp2021.zip (112.8 KB)
|
Box
The physical edition (for now) contains only the cartrige, but since I received a request I designed this box:
Here are PDF and PNG versions for printing (PDF recommended)
skbn-box-art.png
skbn-box-art.pdf
Thanks
Making this game would have been much more difficult without these tools:
A big thanks to the authors of the above!
Of course, there would be nothing to see here without the game contents, the levels! I used
levels that can be redistributed freely provided that their author is credited.
- Thanks to David W. Skinner for the Microban and Sasquatch collections.
- Thanks to Jaques Duthen for the Dimitri & Yorick, Sokogen-990602, Sokogen-990702, Sokogen-990917, and Sokogen-991123 collections.