|
| 1 | +# NetRTS - Real-Time Strategy Game Engine for Programming Competitions |
| 2 | + |
| 3 | +NetRTS is a specialized RTS game engine designed for programming competitions where players control their units through a REST API. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Tick-Based Engine**: Consistent 1-second game ticks. |
| 8 | +- **REST API for Bots**: Complete control over units and buildings via simple JSON commands. |
| 9 | +- **Fog of War**: Real-time vision calculations using QuadTree spatial indexing. |
| 10 | +- **Resource Management**: Gather resources, build structures, and produce units. |
| 11 | +- **Upgrades**: Enhance unit and building capabilities through research. |
| 12 | +- **Real-Time UI**: Blazor-based web client for monitoring matches. |
| 13 | +- **Distributed Observability**: Built with .NET Aspire for comprehensive logging and telemetry. |
| 14 | + |
| 15 | +## Getting Started |
| 16 | + |
| 17 | +### Prerequisites |
| 18 | + |
| 19 | +- [.NET 10.0 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) |
| 20 | +- [Docker Desktop](https://www.docker.com/products/docker-desktop) (for PostgreSQL) |
| 21 | + |
| 22 | +### Running the Application |
| 23 | + |
| 24 | +The easiest way to run the entire system is using .NET Aspire: |
| 25 | + |
| 26 | +```bash |
| 27 | +dotnet run --project src/NetRts.AppHost |
| 28 | +``` |
| 29 | + |
| 30 | +This will start: |
| 31 | +- **API**: The backend game engine. |
| 32 | +- **Client**: The Blazor web dashboard. |
| 33 | +- **Database**: PostgreSQL container for persistence. |
| 34 | + |
| 35 | +### Accessing the Dashboard |
| 36 | + |
| 37 | +Once started, the Aspire dashboard will be available at the URL shown in your console (usually `http://localhost:18888`). From there, you can access the API Swagger UI and the Web Client. |
| 38 | + |
| 39 | +## Bot Development |
| 40 | + |
| 41 | +Bots interact with the engine using standard HTTP requests. |
| 42 | + |
| 43 | +### Basic Workflow |
| 44 | + |
| 45 | +1. **Register/Login**: Get a JWT token. |
| 46 | +2. **Join Lobby**: Find or create a match. |
| 47 | +3. **Get Game State**: `GET /api/v1/matches/{matchId}/state` |
| 48 | +4. **Queue Commands**: `POST /api/v1/matches/{matchId}/commands` |
| 49 | + |
| 50 | +### Example Move Command |
| 51 | + |
| 52 | +```json |
| 53 | +{ |
| 54 | + "commands": [ |
| 55 | + { |
| 56 | + "commandType": "Move", |
| 57 | + "unitIds": [1, 2, 3], |
| 58 | + "targetPosition": { "x": 50, "y": 50 } |
| 59 | + } |
| 60 | + ] |
| 61 | +} |
| 62 | +``` |
| 63 | + |
| 64 | +## Architecture |
| 65 | + |
| 66 | +- **Domain**: Pure domain logic, entities, and business rules. |
| 67 | +- **Application**: CQRS handlers using MediatR, command validation with FluentValidation. |
| 68 | +- **Infrastructure**: EF Core persistence, background game loop, spatial indexing. |
| 69 | +- **API**: Minimal APIs for low-latency command queueing. |
| 70 | +- **Client**: Blazor WebAssembly for real-time visualization. |
| 71 | + |
| 72 | +## License |
| 73 | + |
| 74 | +MIT |
0 commit comments