How rpendleton/battleship-rust works
Battleship Probability Engine has two main workflows: generating and encoding the legal-board dataset offline, then filtering that dataset at query time to produce per-cell ship counts. The graph also preserves the generator’s board rules and the CLI/FFI entry points. The reader and CLI behavior are supported by sampled source; generator and dataset stages are described in the README. Filter internals and FFI wiring are not sampled, so their documented relationships are shown without inferring further implementation details.
Main entry points: reader.rs Dataset reader · filter.rs Filter and count · generator.rs Generator CLI · main.rs Query CLI
Components 22
Dataset generation
- Generator CLI
src/bin/generator.rs - Board enumeration
src/bin/generator.rs - Raw board records
- Delta encoder
src/bin/encoder.rs - Delta records
- zstd compressor
- Compressed dataset
Board model
- Placement state
src/generator/board_state.rs - Placement masks
src/generator/common_masks.rs - Bitmask utilities
src/generator/board_mask.rs - Board coordinates
src/generator/point.rs - Symmetry filter
src/generator/symmetries.rs
Query runtime
- Dataset reader
src/core/reader.rs - Filter and count
src/core/filter.rs - Parallel counting
src/core/filter.rs - Cell count heatmap
User interfaces
- Query CLI
src/main.rs - C FFI wrapper
src/core/ffi.rs
Other components
- Dataset operator
- Query client
- Rust API client
- Swift / iOS client
Connections 28
- Dataset operator → Generator CLI: runs
- Generator CLI → Board enumeration: starts enumeration
- Board enumeration → Placement state: places ships
- Placement state → Placement masks: gets placement masks
- Placement masks → Bitmask utilities: builds masks
- Placement state → Bitmask utilities: updates masks
- Board enumeration → Board coordinates: uses coordinates
- Generator CLI → Symmetry filter: filters canonical boards
- Generator CLI → Raw board records: writes records
- Raw board records → Delta encoder: streams records
- Delta encoder → Delta records: writes XOR deltas
- Delta records → zstd compressor: compresses
- zstd compressor → Compressed dataset: writes compressed data
- Query client → Query CLI: submits masks
- Query CLI → Dataset reader: opens dataset
- Query CLI → Filter and count: passes masks and boards
- Rust API client → Dataset reader: creates reader
- Rust API client → Filter and count: queries boards
- Swift / iOS client → C FFI wrapper: passes masks and path
- C FFI wrapper → Dataset reader: opens dataset
- C FFI wrapper → Filter and count: queries boards
- Compressed dataset → Dataset reader: streams records
- Dataset reader → zstd compressor: decodes when compressed
- Dataset reader → Filter and count: yields decoded boards
- Filter and count → Parallel counting: counts in parallel
- Filter and count → Cell count heatmap: returns cell counts
- Cell count heatmap → Query CLI: prints CSV
- Cell count heatmap → Swift / iOS client: fills output buffer