File size: 2,101 Bytes
12d64f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# RTS Game Web Application

## Quick Start for HuggingFace Spaces

This is a Dockerized web application ready for deployment on HuggingFace Spaces.

### Local Development

1. **Install dependencies**:
```bash
pip install -r requirements.txt
```

2. **Run the server**:
```bash
uvicorn app:app --host 0.0.0.0 --port 7860 --reload
```

3. **Open browser**: Navigate to `http://localhost:7860`

### Docker Build & Run

```bash
# Build the image
docker build -t rts-game .

# Run the container
docker run -p 7860:7860 rts-game
```

### Deployment to HuggingFace Spaces

1. Create a new Space on HuggingFace with Docker SDK
2. Upload all files from this directory
3. HuggingFace will automatically build and deploy using the Dockerfile

### Project Structure

```
web/
โ”œโ”€โ”€ app.py              # FastAPI server with WebSocket
โ”œโ”€โ”€ Dockerfile          # Container configuration
โ”œโ”€โ”€ requirements.txt    # Python dependencies
โ”œโ”€โ”€ README.md          # HuggingFace Space README
โ”œโ”€โ”€ static/
โ”‚   โ”œโ”€โ”€ index.html     # Main game interface
โ”‚   โ”œโ”€โ”€ styles.css     # Modern UI styling
โ”‚   โ””โ”€โ”€ game.js        # Game client logic
```

### Features

- **Real-time gameplay** via WebSocket
- **Modern UI/UX** with responsive design
- **Minimap** with viewport indicator
- **Resource management** system
- **AI opponent** with intelligent behavior
- **Multiple unit types** and buildings
- **Drag-to-select** and command interface

### API Endpoints

- `GET /` - Main game interface
- `GET /health` - Health check endpoint
- `WS /ws` - WebSocket connection for game communication

### Game Commands (WebSocket)

```javascript
// Move units
{
    type: "move_unit",
    unit_ids: ["unit-id-1", "unit-id-2"],
    target: { x: 100, y: 200 }
}

// Build unit
{
    type: "build_unit",
    building_id: "building-id",
    unit_type: "tank"
}

// Place building
{
    type: "build_building",
    building_type: "barracks",
    position: { x: 240, y: 240 },
    player_id: 0
}
```

## Credits

Reimplemented from Python/Pygame to FastAPI/WebSocket for better web accessibility.