Skip to main content

Crate neurodoom

Crate neurodoom 

Source
Expand description

Deterministic pure-Rust Doom simulator with semantic + depth perception buffers alongside the classic 320x200 indexed framebuffer.

The engine is #![no_std] (uses alloc), headless by default, and generic over a GameRules implementation — the built-in ClassicDoomRules reproduces classic single-player; user code can substitute its own rules for bespoke multiplayer or AI training setups.

§Layout

§Quick start

use neurodoom::{ClassicEngine, PeerId, PlayerAction};

let wad = std::fs::read("doom1.wad")?;
let mut engine = ClassicEngine::new(&wad, "E1M1")?;
engine.tick_single(PeerId(0), PlayerAction::default());
let rgba = engine.framebuffer();       // 320 * 200 * 4 bytes
let _semantic = engine.semantic_buffer(); // one SemanticClass per pixel
let _depth = engine.depth_buffer();       // fixed-point distance per pixel

Re-exports§

pub use classic::ClassicDoomRules;
pub use engine::ClassicEngine;
pub use engine::DoomEngine;
pub use engine::DoomError;
pub use math::Angle;
pub use math::Fixed;
pub use math::SCREENHEIGHT;
pub use math::SCREENWIDTH;
pub use perception::PerceptionFrame;
pub use render::SemanticClass;
pub use render::ViewParams;
pub use types::AmmoType;
pub use types::ArmorType;
pub use types::Button;
pub use types::Buttons;
pub use types::Card;
pub use types::MoveDir;
pub use types::WeaponType;
pub use rules::GameRules;
pub use rules::PlayerAction;
pub use rules::TouchResult;
pub use rules::WorldAction;
pub use world::Entity;
pub use world::EntityId;
pub use world::EntityType;
pub use world::HasPose;
pub use world::LevelExit;
pub use world::PeerId;
pub use world::PlayerState;
pub use world::Pose;
pub use world::World;

Modules§

classic
Classic Doom game rules — the built-in GameRules implementation.
combat
Core reusable gameplay logic — state machines, combat, AI, weapons.
demo
Parser for classic Doom demo (LMP) lumps.
engine
Top-level engine — owns the world, map, textures, and renderer, and exposes the tick / render API.
map
Map geometry loaded from a WAD: vertexes, sectors, linedefs, sidedefs, segs, subsectors, BSP nodes, blockmap, REJECT, and the raw THINGS list.
math
Fixed-point arithmetic, Binary Angle Measurement (BAM), and the screen-size constants used across the engine.
perception
AI-facing snapshot of the engine’s semantic + depth buffers.
physics
Entity motion, collision, sight-line checks, and BSP / blockmap queries. Stateless free functions on &mut Entity + &MapData, usable from any crate::rules::GameRules implementation.
render
Software BSP + column-based rasterizer that matches classic Doom’s visual output, with two extra buffers for AI perception: Renderer::semantic (one SemanticClass per pixel) and Renderer::depth (fixed-point distance per pixel).
rules
Game rules trait — the deterministic transition function.
specials
Sector specials: doors, lifts, switches, exit triggers, animated lights. Spawned from the map’s static sector/linedef flags at load time by spawn_specials, advanced once per tick by update_specials. Consumed by crate::combat::use_lines and crate::combat::check_crossed_lines.
texture
WAD visual assets: palettes, colormaps, wall textures, flats, and sprite patches. Loaded from a parsed [crate::wad::Wad] via TextureData::load and resolved against crate::map::MapData so each sidedef/sector holds a resolved index into the tables rather than a raw WAD name.
types
Game-specific enums and bitflags for type-safe gameplay code.
world
World state — the complete, serializable, deterministic game state.