TrekBot is a Rust implementation of a player for the Super Star Trek game that can work with any BASIC interpreter by launching it as a subprocess and communicating via stdin/stdout.
- Interpreter - Interface for launching and communicating with different BASIC interpreters
- GameState - Parses game output and tracks current state
- Strategy - Defines different playing strategies (Random, Cheat, etc.)
- Player - Orchestrates the game by connecting interpreter, state, and strategy
src/
├── main.rs # CLI interface and main entry point
├── interpreter/
│ ├── mod.rs # Interpreter trait and common functionality
│ ├── basicrs.rs # BasicRS interpreter implementation
│ ├── trekbasic.rs # Python TrekBasic interpreter implementation
│ └── trekbasicj.rs # Java TrekBasicJ interpreter implementation
├── game/
│ ├── mod.rs # Game module exports
│ ├── state.rs # Game state parsing and tracking
│ └── parser.rs # Output parsing utilities
├── strategy/
│ ├── mod.rs # Strategy trait and common functionality
│ ├── random.rs # Random strategy implementation
│ └── cheat.rs # Intelligent cheat strategy implementation
└── player.rs # Main player orchestration
- Interpreter Independence - No internal APIs, only subprocess communication
- Strategy Pattern - Different playing strategies can be swapped
- Error Handling - Robust error handling for subprocess communication
- Testability - All components are unit testable
- Extensibility - Easy to add new interpreters or strategies