How nv5466/matrix-game. works
Purpose and Entry Points
This is an early C++ terminal-game prototype for a turn-based D&D-style dungeon game. Its intended core is procedurally generated matrix rooms: 0 denotes walkable space, 1 walls, and player/NPC values encode facing direction. There is no single confirmed application entry point; the executable experiments appear to be separate .cpp programs.
World and Room Generation
Room layouts are generated as 2D matrix grids, likely with perimeter/interior wall handling and randomized blocks. The generation work is split across:
• worldGeneration.cpp
• Room+Mazegen.cpp
• Maze blocks rand code.cpp
• Testing maze generation.cpp
These files define the primary world-model boundary: generated numeric matrices become the authoritative representation for room geometry.
Maze/Connectivity Stage
Maze-oriented generation is distinct from generic randomized room blocks. Room+Mazegen.cpp likely combines room construction with maze generation, while Maze blocks rand code.cpp focuses on placing randomized maze obstacles. This is the key stage that must preserve navigable empty cells for later spawning and movement.
Entity State, Movement, and Orientation
The README defines tile values for an entity’s facing state: default 2, up 3, right 4, down 5, left 6. Movement updates both matrix position and facing. The likely prototypes for this behavior are:
• Attributes.cpp
• Testing class sel.cpp
The architecture currently appears to store entity state directly in the same grid that stores terrain, creating an important boundary between static room tiles (0/1) and dynamic actor markers (2–6).
Encounter and Combat Logic
Combat is an independent gameplay subsystem, presumably invoked after movement or NPC detection:
• Fighting code.cpp
• Testing(dice, loading).cpp
The dice/loading test suggests randomized combat or character initialization mechanics. Combat should consume actor attributes and encounter state rather than directly owning maze generation.
Spawning, Sight, and Distance Rules
NPC/player placement must choose valid empty tiles and avoid immediate encounters. The README specifies Manhattan/taxicab distance, abs(y2-y1) + abs(x2-x1), with a minimum separation target of at least two tiles. Sight is planned as a generated range value and will depend on grid geometry, actor position, orientation, and wall occlusion.
Relevant model experimentation may reside in:
• Attributes.cpp
• worldGeneration.cpp
Runtime and Infrastructure
The project is native C++ and currently targets terminal/Visual Studio-style output rather than a graphical runtime. No build system, package manager, database, network service, or external API is represented in the repository tree. Launch.json config indicates editor/debug-launch configuration rather than game infrastructure.
Main Control Flow
A coherent game loop implied by the prototypes is: generate world/room matrix → validate connectivity and empty tiles → spawn player and NPCs with distance constraints → accept turn input → update movement/facing → evaluate sight/encounters → run combat → render the updated matrix in the terminal. The central integration risk is coordinating currently separate generation, attributes, movement, and combat experiments into one shared grid/entity model.
Main entry points: Attributes.cpp Actor Attributes · Room+Mazegen.cpp Room + Maze Generation · Fighting code.cpp Combat Logic · worldGeneration.cpp World Grid Generator
Components 18
Room Generation
Procedural matrix construction experiments.
- World Grid Generator · Generates authoritative numeric room matrices.
worldGeneration.cpp - Room + Maze Generation · Combines room construction and maze layout.
Room+Mazegen.cpp - Random Maze Blocks · Places randomized obstacle blocks.
Maze blocks rand code.cpp - Maze Generation Test
Testing maze generation.cpp - Room Matrix · 0 is walkable space and 1 is wall terrain.
- Connectivity Validation · Keeps navigable empty cells available for play.
Turn Gameplay
Shared-grid entity and encounter behavior.
- Spawn Rules · Chooses empty tiles with Manhattan-distance separation.
- Actor Attributes · Experiments with player and NPC state.
Attributes.cpp - Class Selection Test
Testing class sel.cpp - Actor Grid Markers · Values 2–6 encode actor position and facing in the room matrix.
- Turn Input
- Movement + Facing · Updates grid position and orientation.
- Sight + Encounter Check · Uses geometry, orientation, range, and wall occlusion.
- Combat Logic · Consumes encounter and actor state.
Fighting code.cpp - Dice / Loading Test · Randomized combat or character-initialization experiment.
Testing(dice, loading).cpp
Other components
- Terminal Runtime · Separate C++ executable experiments write to the terminal.
- Matrix Renderer · Renders the updated room matrix.
- Debug Launch Config · Visual Studio-style debug launch setup.
Launch.json config
Connections 23
- World Grid Generator → Room Matrix: generates
- Room + Maze Generation → Room Matrix: generates
- Random Maze Blocks → Room + Maze Generation: supplies obstacles
- Maze Generation Test → Room + Maze Generation: validates
- Room Matrix → Connectivity Validation: validates
- Connectivity Validation → Spawn Rules: provides empty tiles
- Spawn Rules → Actor Grid Markers: places actors
- Actor Attributes → Actor Grid Markers: defines actor state
- Class Selection Test → Actor Attributes: experiments with
- Room Matrix → Actor Grid Markers: shares grid
- Turn Input → Movement + Facing: selects action
- Actor Grid Markers → Movement + Facing: updates
- Movement + Facing → Actor Grid Markers: writes position/facing
- Movement + Facing → Sight + Encounter Check: triggers check
- Room Matrix → Sight + Encounter Check: wall geometry
- Actor Grid Markers → Sight + Encounter Check: positions and facing
- Sight + Encounter Check → Combat Logic: starts encounter
- Actor Attributes → Combat Logic: actor stats
- Dice / Loading Test → Combat Logic: randomization experiment
- Actor Grid Markers → Matrix Renderer: renders actors
- Room Matrix → Matrix Renderer: renders terrain
- Matrix Renderer → Terminal Runtime: prints
- Debug Launch Config → Terminal Runtime: debug launch