This document describes the .maze file format used for saving and loading mazes.
The maze file format is a human-readable text format that stores the structure of a 3D maze. It consists of a header section defining maze metadata followed by cell data describing the passages between cells.
.maze
UTF-8
SIZE X Y Z
START X Y Z
END X Y Z
CELLS
X Y Z DIRECTIONS
X Y Z DIRECTIONS
...
The header must contain the following declarations in any order before the CELLS marker:
Defines the dimensions of the maze.
SIZE X Y Z
X- Width (number of cells along X axis)Y- Depth (number of cells along Y axis)Z- Height (number of cells along Z axis, use 1 for 2D mazes)
All values must be positive integers.
Example:
SIZE 20 20 1
Defines the starting point of the maze.
START X Y Z
Coordinates are zero-indexed. The start point must be within the maze bounds.
Example:
START 0 0 0
Defines the ending point of the maze.
END X Y Z
Coordinates are zero-indexed. The end point must be within the maze bounds.
Example:
END 19 19 0
Marks the beginning of the cell data section. All lines after this marker are interpreted as cell definitions.
CELLS
Each line after CELLS defines the connections (passages) for a single cell.
X Y Z DIRECTIONS
X Y Z- The cell coordinates (zero-indexed)DIRECTIONS- The directions this cell connects to
Directions can be specified in two formats:
A string of direction characters with no separators:
| Character | Direction | Axis Movement |
|---|---|---|
L |
Left | X - 1 |
R |
Right | X + 1 |
B |
Back | Y - 1 |
F |
Forward | Y + 1 |
D |
Down | Z - 1 |
U |
Up | Z + 1 |
N |
None | No connection |
Characters are case-insensitive. Order does not matter.
Examples:
0 0 0 RF # Connects right and forward
1 1 0 LRBF # Connects left, right, back, and forward (4-way junction)
0 0 0 RFU # Connects right, forward, and up (3D connection)
A decimal number representing the direction flags as a bitmask:
| Direction | Flag Value |
|---|---|
| Left | 1 |
| Right | 2 |
| Down | 4 |
| Up | 8 |
| Back | 16 |
| Forward | 32 |
The value is the sum of the individual direction flags.
Examples:
0 0 0 34 # RF: Right(2) + Forward(32) = 34
1 1 0 51 # LRBF: Left(1) + Right(2) + Back(16) + Forward(32) = 51
Valid numeric values range from 0 to 63.
Cells with no connections (isolated cells) may be omitted from the file. Any cell not explicitly listed is assumed to have Direction.None.
Lines beginning with # are treated as comments and ignored.
# This is a comment
SIZE 10 10 1
# Another comment
START 0 0 0
Blank lines are ignored and may appear anywhere in the file.
# A simple 3x3 maze
SIZE 3 3 1
START 0 0 0
END 2 2 0
CELLS
# Bottom row
0 0 0 RF
1 0 0 LRF
2 0 0 LF
# Middle row
0 1 0 BRF
1 1 0 LRBF
2 1 0 LBF
# Top row
0 2 0 BR
1 2 0 LRB
2 2 0 LB
When importing a maze, the following validations are performed:
SIZE,START, andENDdeclarations must be presentCELLSmarker must be present (even if no cells follow)
- Start and end points must be within maze bounds (0 to SIZE-1 for each axis)
- Cell coordinates must be within maze bounds
- Direction connections must not point outside maze bounds
- All connections must be bidirectional
- If cell A connects to cell B, cell B must connect back to cell A
- Example: If
(0,0,0)hasR, then(1,0,0)must haveL
- Start point should have at least one connection
- End point should have at least one connection
When serialising a maze, the following conventions are used:
- Header declarations are written in order:
SIZE,START,END,CELLS - Cells are written in Z, Y, X order (outermost to innermost loop)
- Directions are written in letter format using the order:
L,R,D,U,B,F - Cells with no connections are omitted
- No comments are included in output
The coordinate system follows these conventions:
- X axis: Left (-X) to Right (+X)
- Y axis: Back (-Y) to Forward (+Y)
- Z axis: Down (-Z) to Up (+Z)
In Godot's 2D rendering:
- Positive Y goes down on screen
- Forward (Y+1) renders as going down
- Back (Y-1) renders as going up