Challenge
Design a compression algorithm specialized for compressing ASCII mazes. You will need to create both a compression algorithm and a decompression algorithm. Your score will be based on the size of your compressed mazes.
Mazes
These mazes are made primarily of the characters (floors),
+
, -
, |
, and #
(walls), and exactly one each of ^
(start) and $
(end). They may also contain ASCII letters, which count as floor tiles. For the purposes of this challenge, mazes do not have to be solvable and the actual meaning of maze contents is irrelevant.
+
will be used for wall cells where there is at least one horizontally adjacent wall cell and at least one vertically adjacent wall cell.|
will be used for wall cells where there is at least one vertically adjacent wall cell, but no horizontally adjacent wall cells.-
will be used for wall cells where there is at least one horizontally adjacent wall cell, but no vertically adjacent wall cells#
will only be used for wall cells that are not orthogonally adjacent to other wall cells.
All mazes are rectangular, but do not necessarily have a regular grid/wall alignment.
Mazes To Compress
Maze 1
+----+----
| o | |
| -- | o--+
| | | $
--^-+-+---
Maze 2
+-----+---+
| a | |
^ +-+-+ # |
| | | B |
| | | --+ |
| c | $
+-------+--
Maze 3
----------+-+-+-----+-+
^ | | | | |
+-- --+R # | |p| | | |
| | | | | |
+---+ +-+-+-- +-+ | | |
| m| | | | | | | |
| +-+ | | | | | --+ | |
| | | h | | | | |
| | | | | | # --+-+ |
| | | | | | S| $
+-----+-+-+-+-+---+----
Maze 4
+-----+---+-+---+-------^-----+
| |x | | | tsrq |
+-+-- +-- | +-- # --+---- --+
| | | | | |
| | | | | +-+-+---+ | +-- | +-+
| | | u | | | | | | | | |
| +-+ | | | | +---- +-+---+ | |
| | | | | y | w |
| | --+ | --+ +-- | +---- | | |
| | | | | | | | | |
+-- --+ +-+ | | | | +-- | +-+-+
| | | | | | | | | |
$ | --+-+ | --+-+ | +-+-+-- --+
| | | z| | | v |
+-+---+-------+---+---+-------+
Maze 5
++ -----------+
++- Beep|
$ ----+---+--+
+-+boop| | |
| +--- | | | ++
| | | +++
+------+-+--+ ^
Maze 6
+-$---------------+-+--
| | |j
| |l ---- # ---+ | |
| | | m | +--+ |
| | | +-+---- # |
| | | | | +----+ |
|o| | | | +----+ | |
| | | | -- | |
| | | | | | -+ | | |
| | | | | | | +--- | |
| | | | +- | | | | ++
+-+ |n| | | ++ +--+ |
| | -+- | | | +-
+---+ +--- | | | ^
| | --+ --+ | |
| -- | | k | | ++
| | | +--- | ++
| | | | | |
+-- -+---- | +----+--+
Maze 7
+---+-+-------------+-+^+-----+-------+---+-+---+-+---+-+---+
| |c| | | | c | | | | | | |c| |
+-- | | +-- +-- # | | | +-- --+ +---- +-- | +-+ | | +-+ | --+
| | | | | | | | |c| | |
| | +-- | +-+-- +-+ +-- # +- # -+-- +-- | | --+ | | | | --+C|
|c| | | | c | | |c | | | |
+-+-+---+-+-----+---------+---------+---+-------------+---+$|
Maze 8
------+-+-+---+-+---+-----------+---+-----+---------------+-+
^ | | | | | | | | | r | |
+-- | | | t | | +-- +----- # ---+-- +-- --+-- ----+-+ --+ | |
| | | | | | | r | | | | | |
| | | | | +-+ --+ --+-- --------+-- | ----+ --+ | | | --+ | |
| |r| | rotation | | | | | | $
+-+-+-+-----------------------------------+---+-+---+---+-+--
Maze 9
|$|^--+-+---+-----+-+---+-+-+---+---+-+---+-----+
| | | | | | | | | | f | | | | |
| +-+ | | # +-+ --+ +-+ | | | # | +-+ +-- | ----+
| | | | f| | | | | | f |
| |F+-+ | | | | +---+ | | | ----+-+ | | --+ --+-+
| | | | | | | | | f | | | |
| | | | +-+-+---+-- | | | +-+-+-+ +-+ +--- # -+ |
| | | | | | | | | | | | | | |
+-+-+ | +---+ --+ | +---+-+ | | --+ f | | | | --+
| | | | | | | | | |
| --+f| | | +-- --+--f--+ --+ | ----+ | +-+ +---+
| | | | | | | | | |
+---+-----+-+-----+-----+---+-+-----------+-----+
Maze 10
+-----+-+-----------+
| q | | q |
|Q+-+ | +-+-+-+---- |
$ | | | | | q |
+-+ | | | | | +-- +-+
| | | | | | |
| +-- +-+ |q| +-+ | |
| q| | | | |
| | | +-- | +-+ | --+
| | | | | | | |
+-+-+-+ +-+-+ +-- | |
| | | |
+--- # -+ | | +-- | |
| q | | | | ^
+-+ +-- | | +-+ | +-+
| | | | |q| | |
| +-+-+ | +-+-- | | |
| | | | | | |
| | | +-+-+-- +-+ +-+
| | | | q |
+-+-+---------+-----+
Rules, Assumptions, Scoring
- Standard loopholes are banned
- Write a general program, not one that only works for the ten test cases. It must be able to handle any arbitrary maze.
- You may assume there will be exactly one entrance and one exit. Entrances and exits will always be on the border of the maze.
- You may assume that all inputs use walls that follow the rules enumerated above. Your compression algorithm does not have to work for mazes containing walls that violate those rules.
- Input mazes may or may not be solvable.
- You may assume the maze will be no larger than 100 characters in either direction.
- You may assume that letters will not appear on the edge of the maze. (since this is the case for the examples provided)
- Your score is the total size, in bytes (octets), of all of the compressed mazes.
- You may use hex, base64, binary strings, or any similar format as a representation for your compressed maze if you find that more convenient. You should still count the result in whole octets, rounded up for each maze (e.g. 4 base64 digits is 3 bytes, 2 hex digits is 1 byte, 8 binary digits is 1 byte, etc...)
- Lowest score wins!