encounters to one-third of the pure DFS results. This
randomness with control provides good difficulty-
tuning tools for designers.
3 DATA STRUCTURE AND
SPATIAL REPRESENTATION
3D maze employs a layer grid model as storage. It is
stored by each unit of 3D coordinates (x,y,z), where
x-axis width, y-axis depth, and z-axis vertical height.
The supporting data structure consists of a 3D
array in which each cell contains unit properties (e.g.,
stair indicators, wall state, or texture types). To offset
O(n³) memory usage,I apply run-length encoding
(RLE) to continuous blocks, yielding 22%
compression for labyrinth-type mazes.
Though memory-intensive, the structure merely
encapsulates physical spatial relationships and
supports spatial queries well. For assisting in user
navigation, layered view tools are provided. By
specifying z-axis coordinates, 2D views of any
horizontal section can be extracted. For example,
when a character is located on the first floor (z=0) of
a building-themed maze, the system maps corridors,
walls, and stair positions to the second floor (z=1).
Shortest paths are highlighted,coloring them in. This
"unfolded layering" technique dramatically reduces
cognitive overload in 3D space (Alamri et al, 2022).
Empirical tests show gamers who use layered
maps possess 58% faster escape times than gamers
with no maps. Eye-tracking tells us of 65% fewer
gaze shifts from map to world.
4 RAY CASTING METHODS AND
INTERACTION
OPTIMIZATION
Ray casting plays a vital role in real-time rendering.
During navigation through the maze, virtual rays
projected from the eye encounter wall collisions.
Wall dimensions are determined by calculation of ray
distances, which produce perspective effects.
And,Implementation employs Bresenham's line
algorithm for fast ray traversal, reducing GPU work
by 18%.To introduce realism, texture mapping is
employed: walls display brick or wood textures rather
than single-colored surfaces, with dynamically
controlled brightness from a light attenuation
model—walls increasing in distance from the player
will be darker, which helps to improve depth
perception (Asai, 2025).
In terms of interaction modes, first-person
perspective offers high-level immersion through the
simulation of human vision, particularly effective in
horror-based closed mazes. Third-person perspective
allows players to view their character and
surroundings, more suitable for spatially strategic
puzzle situations. 72% preferred first-person in user
testing for adventure contexts, but third-person for
puzzles.Virtual joysticks replace keyboard controls
on mobile phones, and gyroscopes enable natural
view movement by tilting the phone. Haptic feedback
(e.g., vibration on wall hits) also enhances mobile
immersion. Additions maintain silky 30 FPS
interaction on Snapdragon 7-series devices.
5 INSTRUCTIONAL USE AND
PRAGMATIC USE
The 3D maze system offers multi-dimensional case
studies to incorporate in computer science education.
Algorithmically, students can naturally
understand the tradeoff between "complete
connectivity" and "random complexity" by adjusting
DFS-Prim hybrids ratios. In pathfinding lessons, A*
algorithm extensions for 3D grids demonstrate
heuristic function optimization. Algebraically, maze
modeling through coordinates is tangible pedagogical
substance for spatial vectors, and ray casting distance
calculations have analogues in real-world
Pythagorean theorem uses. Students calculate ray-
wall collision distances by calculating √(dx²+dy²
+dz²),
Improve the understanding of three-dimensional
geometry. Virtual Reality (VR) integration enriches
learning scenarios as well.
VR headset students navigate maze spaces with
head movements and action like "grabbing keys to
unlock doors" using hand-held controllers.This
"embodied cognition" simulation locks in abstract
spatial reasoning, particularly beneficial for less
spatially talented students (Bellot, 2021).
6 THEORETICAL
FOUNDATIONS OF HYBRID
MAZE GENERATION
Combining Depth-First Search (DFS) and Prim's
algorithms generates a two-phase generation process.