How mohjb/sokobansolver works
Project type & purpose (from README + tree)
This is a Java Sokoban puzzle solver implementing A\* search (“A* application”). It’s not a distributed system; it’s a single-process algorithmic tool that:
• loads Sokoban levels (likely from levels.levels),
• represents game states,
• generates legal moves (actions),
• runs A* (priority queue / open set, closed set),
• outputs a solution path (sequence of moves / actions).
What the file structure implies architecturally
Relevant files:
• githubMohJBSokobanSolver/src/SokobanSolver.java
Likely the main solver entry and A* driver (open/closed sets, loop, termination).
• githubMohJBSokobanSolver/src/OldSokobanSolver.java
• githubMohJBSokobanSolver/src/SokoAct.java
Likely “Sokoban Action” (move representation), or action generator.
• githubMohJBSokobanSolver/src/levels.levels
Input dataset of levels.
• SokoSo.java (top-level, outside Eclipse project folder)
Possibly another entry point / wrapper / earlier version.
Also present: Eclipse metadata (.project, .settings) → indicates a local IDE project, not a packaged multi-module system.
Entry Point / Orchestration
• SokobanSolver (and possibly SokoSo)
• Responsibilities:
• select level
• initialize state
• call solver
• print solution / stats
Level Repository + Parser
• levels.levels (data)
• “LevelLoader/Parser” (may be embedded in SokobanSolver)
• Responsibilities:
• read level text
• produce initial board/state representation
Domain Model (Game State / Board Representation)
• Even if not explicitly named in tree, the solver must have:
• Board grid (walls, goals)
• Player position
• State hashing/equality (critical for closed set)
• If this is embedded in SokobanSolver, represent it as an internal component/class.
Action / Move Representation
• SokoAct
• Responsibilities:
• Moves (Up/Down/Left/Right)
• possibly also pushes vs moves
• apply action to state (transition function), or describe it
Successor Generator (Legal Moves)
• Often implemented using the domain model + action representation.
• Responsibilities:
• from a state, enumerate legal next states
A\* Search Engine
• Likely SokobanSolver
• Open Set (PriorityQueue ordered by f = g + h)
• Closed Set (HashSet/Map of visited states)
• Node/Record (state + parent + action + g + h + f)
• Responsibilities:
• loop: pop best node, goal test, expand successors, update open/closed
• reconstruct solution path via parent pointers
Heuristic Function
• deadlock detection (if present)
• Responsibilities:
• estimate remaining cost
• must be admissible/consistent if optimality is desired
Solution Reconstruction + Output
• Responsibilities:
• trace parent links
• format sequence of moves
• print/write stats (expanded nodes, runtime, solution length)
Legacy Solver (optional)
• OldSokobanSolver as “deprecated/previous algorithm”
• as an alternate implementation behind a “Solver Interface”, or
Architectural patterns/design principles used (explicitly call them out)
Even though it’s a small repo, it still has recognizable patterns:
• Search Pipeline / Algorithmic Architecture: parse → model → search → output
• Separation of concerns (should be depicted even if code is somewhat merged):
• state representation vs search strategy vs heuristic vs IO
• Graph search pattern:
• node expansion
• frontier management
• visited/closed tracking
• Heuristic strategy:
• heuristic is a pluggable concept; show it as a replaceable component (even if not coded that way)
Loop
• pop min-f node
• goal test
• generate successors
• compute g/h/f
• update Open/Closed