- Project Name: Civil War General
- Document Version: 1.0
- Date: January 17, 2026
- Author: Development Team
- Document Type: Software Requirements Specification
- Stage: Stage 2 - AI-Driven Tactical Analysis
This document specifies the functional and non-functional requirements for Stage 2 of the Civil War General application. Stage 2 transitions the application from a simple random command generator to an intelligent tactical advisor that considers battlefield context.
Stage 2 introduces an AI-driven selection engine that evaluates situational data—specifically battlefield conditions and troop states—to recommend the most appropriate tactical orders. This stage involves extending the data models, enhancing the UI to capture context, and implementing logic-based selection algorithms.
- AI Selection: The process of choosing an order based on weighted logic and environmental variables.
- Battlefield Condition: Environmental factors (weather, terrain, visibility) affecting combat.
- Troop State: The condition of a military unit (morale, fatigue, supply level).
- Weighting: The importance assigned to a specific condition when calculating the suitability of an order.
Stage 2 builds directly upon the MVP architecture established in Stage 1. It replaces the SecureRandom selection logic with a context-aware TacticalAISelector while maintaining the core UI and order management foundations.
- Capture and manage battlefield conditions (e.g., Rain, Fog, Heat).
- Capture and manage troop states (e.g., High Morale, Low Supplies, Exhausted).
- Perform weighted tactical analysis to select orders.
- Provide reasoning for the AI's selection.
- Persist environmental settings across selections within a session.
- REQ-034: The system shall support a set of Battlefield Conditions:
- Weather (Clear, Rain, Snow, Fog)
- Terrain (Open, Forest, Hill, Swamp)
- Time of Day (Day, Night)
- REQ-035: The system shall support a set of Troop States:
- Morale (High, Average, Low)
- Fatigue (Fresh, Weary, Exhausted)
- Supply Level (Plentiful, Limited, Critical)
- REQ-036: The system shall allow the user to toggle these conditions via the UI.
The CommandSelector interface shall be extended or implemented to provide logic-based selection instead of pure randomization.
- REQ-037: The AI shall assign "Suitability Weights" to orders based on current conditions.
- Example: "Attack Forward" weight decreases in "Swamp" or "Exhausted" state.
- Example: "Defend Forward" weight increases in "Forest" or "Low Supply".
- REQ-038: The AI shall select the order with the highest suitability score.
- REQ-039: If multiple orders have equal highest scores, the system shall randomly pick between them using the Stage 1 secure random logic.
- REQ-040: The system shall handle "Impossible" scenarios (where no order is suitable) by returning a "Hold Position" or default fallback.
- REQ-041: The UI shall include a "Tactical Context" panel.
- REQ-042: The context panel shall use ComboBoxes or RadioButtons for selecting conditions and states.
- REQ-043: The UI shall display the "Reasoning" behind an AI selection (e.g., "Selected 'Retreat' due to Critical Supplies and Exhausted troops").
- REQ-044: The history list shall record the conditions present at the time the command was generated.
- REQ-045: AI selection logic shall compute within 200 milliseconds.
- REQ-046: UI updates for condition toggles shall be instantaneous (< 50ms).
- REQ-047: AI logic shall be externalized in a strategy pattern to allow for future "Personalities" (e.g., Aggressive vs. Defensive General).
- REQ-048: Condition-Order mappings shall be configurable via JSON.
The system continues using MVP but introduces:
- Strategy Pattern: For different AI selection behaviors.
- Observer Pattern: To notify the Presenter when UI conditions change.
Orderis extended withMap<String, Integer> weights.TacticalContextclass introduced to encapsulate battlefield and troop data.
- Users can change battlefield conditions in the UI.
- AI selects different orders when conditions significantly change.
- The history log shows the context (e.g., Weather, Morale) for each entry.
- Selection reasoning is displayed to the user.
- Unit tests cover 100% of the new AI scoring logic.
- Integration tests verify that UI condition changes correctly affect the selection output.
- Javadoc is applied to all new Stage 2 classes and methods.
Document Approval
| Role | Name | Signature | Date |
|---|---|---|---|
| Product Owner | |||
| Lead Developer | |||
| QA Lead | |||
| Project Manager |