aivill 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aivill-0.1.0/LICENSE +21 -0
- aivill-0.1.0/PKG-INFO +616 -0
- aivill-0.1.0/README.md +574 -0
- aivill-0.1.0/aivill/__init__.py +59 -0
- aivill-0.1.0/aivill/config.py +183 -0
- aivill-0.1.0/aivill/core/__init__.py +0 -0
- aivill-0.1.0/aivill/core/decision_engine.py +186 -0
- aivill-0.1.0/aivill/core/engine.py +239 -0
- aivill-0.1.0/aivill/core/perception.py +276 -0
- aivill-0.1.0/aivill/exceptions.py +58 -0
- aivill-0.1.0/aivill/learning/__init__.py +0 -0
- aivill-0.1.0/aivill/learning/learning_engine.py +156 -0
- aivill-0.1.0/aivill/learning/pattern_learning.py +141 -0
- aivill-0.1.0/aivill/learning/reinforcement.py +179 -0
- aivill-0.1.0/aivill/llm/__init__.py +0 -0
- aivill-0.1.0/aivill/llm/ollama_client.py +169 -0
- aivill-0.1.0/aivill/logging/__init__.py +0 -0
- aivill-0.1.0/aivill/logging/event_logger.py +174 -0
- aivill-0.1.0/aivill/memory/__init__.py +0 -0
- aivill-0.1.0/aivill/memory/memory_manager.py +145 -0
- aivill-0.1.0/aivill/memory/player_profile.py +114 -0
- aivill-0.1.0/aivill/memory/short_term_memory.py +89 -0
- aivill-0.1.0/aivill/memory/strategy_memory.py +145 -0
- aivill-0.1.0/aivill/personality/__init__.py +0 -0
- aivill-0.1.0/aivill/personality/personality_engine.py +232 -0
- aivill-0.1.0/aivill/strategy/__init__.py +0 -0
- aivill-0.1.0/aivill/strategy/mutation.py +191 -0
- aivill-0.1.0/aivill/strategy/strategy_engine.py +220 -0
- aivill-0.1.0/aivill/utils/__init__.py +0 -0
- aivill-0.1.0/aivill/utils/helpers.py +43 -0
- aivill-0.1.0/aivill.egg-info/PKG-INFO +616 -0
- aivill-0.1.0/aivill.egg-info/SOURCES.txt +37 -0
- aivill-0.1.0/aivill.egg-info/dependency_links.txt +1 -0
- aivill-0.1.0/aivill.egg-info/requires.txt +23 -0
- aivill-0.1.0/aivill.egg-info/top_level.txt +1 -0
- aivill-0.1.0/pyproject.toml +84 -0
- aivill-0.1.0/setup.cfg +4 -0
- aivill-0.1.0/setup.py +32 -0
- aivill-0.1.0/tests/test_engine.py +144 -0
aivill-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 AiVill Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
aivill-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,616 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aivill
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: AiVill - A modular self-learning villain AI engine designed to create adaptive game antagonists.
|
|
5
|
+
Author: AiVill Team
|
|
6
|
+
Author-email: AiVill Team <team@aivill.dev>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/aivill/aivill
|
|
9
|
+
Project-URL: Documentation, https://aivill.readthedocs.io
|
|
10
|
+
Project-URL: Repository, https://github.com/aivill/aivill
|
|
11
|
+
Project-URL: Issues, https://github.com/aivill/aivill/issues
|
|
12
|
+
Keywords: ai,game,villain,enemy,artificial-intelligence,ollama,self-learning,gamedev
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Topic :: Games/Entertainment
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
|
+
Requires-Python: >=3.9
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: requests>=2.28.0
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
23
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
24
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
25
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
26
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
27
|
+
Provides-Extra: llm
|
|
28
|
+
Requires-Dist: ollama>=0.1.0; extra == "llm"
|
|
29
|
+
Provides-Extra: cli
|
|
30
|
+
Requires-Dist: click>=8.0.0; extra == "cli"
|
|
31
|
+
Provides-Extra: all
|
|
32
|
+
Requires-Dist: pytest>=7.0.0; extra == "all"
|
|
33
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "all"
|
|
34
|
+
Requires-Dist: black>=23.0.0; extra == "all"
|
|
35
|
+
Requires-Dist: mypy>=1.0.0; extra == "all"
|
|
36
|
+
Requires-Dist: ruff>=0.1.0; extra == "all"
|
|
37
|
+
Requires-Dist: ollama>=0.1.0; extra == "all"
|
|
38
|
+
Requires-Dist: click>=8.0.0; extra == "all"
|
|
39
|
+
Dynamic: author
|
|
40
|
+
Dynamic: license-file
|
|
41
|
+
Dynamic: requires-python
|
|
42
|
+
|
|
43
|
+
# AiVill
|
|
44
|
+
|
|
45
|
+
Adaptive AI Villains for Games
|
|
46
|
+
|
|
47
|
+
[](https://pypi.org/project/aivill/)
|
|
48
|
+
[](https://pypi.org/project/aivill/)
|
|
49
|
+
[](https://opensource.org/licenses/MIT)
|
|
50
|
+
[](https://github.com/aivill/aivill/stargazers)
|
|
51
|
+
|
|
52
|
+
<p align="center">
|
|
53
|
+
<img src="assets/aivill-logo.png" width="220">
|
|
54
|
+
</p>
|
|
55
|
+
|
|
56
|
+
<h1 align="center">AiVill</h1>
|
|
57
|
+
|
|
58
|
+
<p align="center">
|
|
59
|
+
Adaptive AI Villains for Games
|
|
60
|
+
</p>
|
|
61
|
+
|
|
62
|
+
AiVill is a **modular AI engine that creates adaptive villains capable of learning player behavior and evolving strategies across sessions**.
|
|
63
|
+
|
|
64
|
+
Most video game enemies are scripted AI that follow fixed logic. AiVill instead creates villains that **observe, learn, adapt, and evolve** — making each player encounter unique.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Why AiVill Exists
|
|
69
|
+
|
|
70
|
+
Most game AI is static. Villains follow predictable patterns, exploit the same weaknesses, and never truly "learn" from player behavior.
|
|
71
|
+
|
|
72
|
+
AiVill explores a different approach: **adaptive antagonists that evolve with the player**. Instead of hardcoded behavior trees, the villain:
|
|
73
|
+
|
|
74
|
+
* Observes how you play
|
|
75
|
+
* Remembers your strategies
|
|
76
|
+
* Adapts its tactics
|
|
77
|
+
* Evolves over multiple encounters
|
|
78
|
+
* Develops personality traits based on outcomes
|
|
79
|
+
|
|
80
|
+
The goal isn't just a harder enemy — it's a **living antagonist** that makes each playthrough feel different.
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Key Features
|
|
85
|
+
|
|
86
|
+
* **Adaptive Villain AI** — Villains that learn from player behavior and adapt strategies
|
|
87
|
+
* **Persistent Memory** — Remember player patterns across sessions
|
|
88
|
+
* **Reinforcement Learning** — Strategy effectiveness updates based on outcomes
|
|
89
|
+
* **Strategy Evolution** — Automatic mutation and improvement of tactics
|
|
90
|
+
* **Personality System** — Six trait dimensions that shape villain behavior
|
|
91
|
+
* **Ollama LLM Integration** — Optional local LLMs for reasoning and dialogue
|
|
92
|
+
* **Modular Architecture** — Swap components as needed
|
|
93
|
+
* **Game-Agnostic Design** — Integrate with any game genre
|
|
94
|
+
* **Simple API** — Full integration in under 10 lines of code
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Installation
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
pip install aivill
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Quick Start
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from aivill import VillainEngine
|
|
108
|
+
|
|
109
|
+
# Create and initialize
|
|
110
|
+
villain = VillainEngine()
|
|
111
|
+
villain.initialize({"data_dir": "data"})
|
|
112
|
+
|
|
113
|
+
# Game loop
|
|
114
|
+
while game_running:
|
|
115
|
+
villain.update_state(game_state)
|
|
116
|
+
action = villain.decide_action()
|
|
117
|
+
villain.learn_from_result(result)
|
|
118
|
+
|
|
119
|
+
villain.save_memory()
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
For more examples, see the [examples](examples/) directory.
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## How AiVill Works
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
130
|
+
│ GAME LOOP │
|
|
131
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
132
|
+
│ │
|
|
133
|
+
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
|
|
134
|
+
│ │ Game │───▶│ AiVill │───▶│Decision │───▶│ Execute │ │
|
|
135
|
+
│ │ State │ │ Engine │ │ │ │ Action │ │
|
|
136
|
+
│ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │
|
|
137
|
+
│ │ │ │
|
|
138
|
+
│ ▼ │ │
|
|
139
|
+
│ ┌──────────┴─────┐ │
|
|
140
|
+
│ │ Learning │ │
|
|
141
|
+
│ │ + Memory │ │
|
|
142
|
+
│ └───────────────┘ │
|
|
143
|
+
│ │
|
|
144
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### The Learning Loop
|
|
148
|
+
|
|
149
|
+
1. **Observe** — Game state updates the villain's perception
|
|
150
|
+
2. **Remember** — Player patterns stored in memory
|
|
151
|
+
3. **Decide** — Strategy selected based on personality + learning
|
|
152
|
+
4. **Act** — Villain executes action
|
|
153
|
+
5. **Learn** — Outcome updates strategy effectiveness
|
|
154
|
+
6. **Adapt** — Personality and strategies evolve
|
|
155
|
+
|
|
156
|
+
Over time, the villain becomes **smarter** and develops its own **playstyle**.
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Architecture
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
164
|
+
│ AiVill Engine │
|
|
165
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
166
|
+
│ │
|
|
167
|
+
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
|
|
168
|
+
│ │ Perception │ │ Memory │ │ Personality │ │
|
|
169
|
+
│ │ System │ │ System │ │ Engine │ │
|
|
170
|
+
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
|
|
171
|
+
│ │
|
|
172
|
+
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
|
|
173
|
+
│ │ Strategy │ │ Learning │ │ Decision │ │
|
|
174
|
+
│ │ Engine │──│ Engine │──│ Engine │ │
|
|
175
|
+
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
|
|
176
|
+
│ │
|
|
177
|
+
│ ┌─────────────┐ ┌─────────────┐ │
|
|
178
|
+
│ │ LLM │ │ Event │ │
|
|
179
|
+
│ │ Interface │ │ Logger │ │
|
|
180
|
+
│ └─────────────┘ └─────────────┘ │
|
|
181
|
+
│ │
|
|
182
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Components
|
|
186
|
+
|
|
187
|
+
| Component | Description |
|
|
188
|
+
|-----------|-------------|
|
|
189
|
+
| **Perception System** | Analyzes game state, extracts observations |
|
|
190
|
+
| **Memory System** | Stores player profiles, strategy history, events |
|
|
191
|
+
| **Personality Engine** | Six trait dimensions affecting decision-making |
|
|
192
|
+
| **Strategy Engine** | Manages tactics, evaluates effectiveness |
|
|
193
|
+
| **Learning Engine** | Reinforcement updates, pattern recognition |
|
|
194
|
+
| **Decision Engine** | Integrates all systems to select actions |
|
|
195
|
+
| **LLM Interface** | Optional Ollama integration for reasoning |
|
|
196
|
+
| **Event Logger** | Records all interactions for analysis |
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Quick Start
|
|
201
|
+
|
|
202
|
+
### Installation
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
# Clone the repository
|
|
206
|
+
git clone https://github.com/aivill/aivill.git
|
|
207
|
+
cd aivill
|
|
208
|
+
|
|
209
|
+
# Install in development mode
|
|
210
|
+
pip install -e .
|
|
211
|
+
|
|
212
|
+
# Or install dependencies only
|
|
213
|
+
pip install -r requirements.txt
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Basic Usage
|
|
217
|
+
|
|
218
|
+
```python
|
|
219
|
+
from aivill import VillainEngine
|
|
220
|
+
|
|
221
|
+
# Create and initialize
|
|
222
|
+
villain = VillainEngine()
|
|
223
|
+
villain.initialize({
|
|
224
|
+
"name": "Lord of Shadows",
|
|
225
|
+
"data_dir": "data",
|
|
226
|
+
"log_dir": "logs"
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
# Set personality (optional)
|
|
230
|
+
villain.load_personality({
|
|
231
|
+
"traits": {
|
|
232
|
+
"aggression": 0.8,
|
|
233
|
+
"patience": 0.4,
|
|
234
|
+
"ego": 0.9,
|
|
235
|
+
"chaos": 0.3,
|
|
236
|
+
"adaptability": 0.7,
|
|
237
|
+
"caution": 0.3
|
|
238
|
+
}
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
# Game loop
|
|
242
|
+
while game_running:
|
|
243
|
+
# Update with current game state
|
|
244
|
+
game_state = {
|
|
245
|
+
"player_health": 80,
|
|
246
|
+
"villain_health": 100,
|
|
247
|
+
"player_last_action": "attack",
|
|
248
|
+
"round_number": 5
|
|
249
|
+
}
|
|
250
|
+
observations = villain.update_state(game_state)
|
|
251
|
+
|
|
252
|
+
# Get villain's decision
|
|
253
|
+
decision = villain.decide_action()
|
|
254
|
+
print(f"Villain chooses: {decision['action']}")
|
|
255
|
+
|
|
256
|
+
# Execute action in your game...
|
|
257
|
+
|
|
258
|
+
# Learn from result
|
|
259
|
+
result = {
|
|
260
|
+
"outcome": "victory",
|
|
261
|
+
"success": True,
|
|
262
|
+
"reward": 1.0
|
|
263
|
+
}
|
|
264
|
+
villain.learn_from_result(result)
|
|
265
|
+
|
|
266
|
+
# Save memory for next session
|
|
267
|
+
villain.save_memory()
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Game State Format
|
|
271
|
+
|
|
272
|
+
```python
|
|
273
|
+
game_state = {
|
|
274
|
+
"player_health": 80, # 0-100
|
|
275
|
+
"villain_health": 100, # 0-100
|
|
276
|
+
"player_last_action": "attack", # Player's last action
|
|
277
|
+
"round_number": 5, # Current round
|
|
278
|
+
"available_actions": [ # What villain can do
|
|
279
|
+
"attack", "defend", "retreat", "set_trap", "taunt"
|
|
280
|
+
],
|
|
281
|
+
"environment_objects": [ # What's in the environment
|
|
282
|
+
"trap", "cover", "weapon"
|
|
283
|
+
],
|
|
284
|
+
"player_id": "hero_001" # Optional player identifier
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Result Format
|
|
289
|
+
|
|
290
|
+
```python
|
|
291
|
+
result = {
|
|
292
|
+
"outcome": "victory", # Outcome type
|
|
293
|
+
"success": True, # Did it work?
|
|
294
|
+
"reward": 1.0, # Reward value (-1 to 1)
|
|
295
|
+
"damage_dealt": 20, # Damage to player
|
|
296
|
+
"damage_received": 5 # Damage to villain
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## Ollama Integration
|
|
303
|
+
|
|
304
|
+
AiVill can optionally use **local LLMs via Ollama** for enhanced reasoning.
|
|
305
|
+
|
|
306
|
+
### Setup
|
|
307
|
+
|
|
308
|
+
1. Install [Ollama](https://ollama.ai)
|
|
309
|
+
2. Pull a model:
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
ollama pull phi3.5 # 2.2GB - Good balance
|
|
313
|
+
ollama pull qwen2.5 # 986MB - Best for edge
|
|
314
|
+
ollama pull llama3 # 4.9GB - Most capable
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### Enable LLM
|
|
318
|
+
|
|
319
|
+
```python
|
|
320
|
+
villain = VillainEngine({
|
|
321
|
+
"llm_model": "qwen2.5", # Or phi3.5, llama3, etc.
|
|
322
|
+
"llm_enabled": True
|
|
323
|
+
})
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### LLM Features
|
|
327
|
+
|
|
328
|
+
* **Strategy Suggestions** — "What should the villain do against an aggressive player?"
|
|
329
|
+
* **Behavior Analysis** — "What patterns has this player shown?"
|
|
330
|
+
* **Villain Dialogue** — Generate menacing taunts and monologue
|
|
331
|
+
* **Strategy Mutation Ideas** — AI-generated tactical variations
|
|
332
|
+
|
|
333
|
+
> **Note:** LLM calls are slow (~2-10 seconds). Disable for real-time gameplay.
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
## Examples
|
|
338
|
+
|
|
339
|
+
### Terminal Demo
|
|
340
|
+
|
|
341
|
+
Run an interactive simulation:
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
python -m examples.automated_test
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### Stress Test
|
|
348
|
+
|
|
349
|
+
Test performance with 500+ iterations:
|
|
350
|
+
|
|
351
|
+
```bash
|
|
352
|
+
python -m examples.stress_test
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
---
|
|
356
|
+
|
|
357
|
+
## AiVill Experiment Playground
|
|
358
|
+
|
|
359
|
+
Run experiments to observe adaptive villain behavior:
|
|
360
|
+
|
|
361
|
+
```bash
|
|
362
|
+
# Learning demo - watch villain learn from player patterns
|
|
363
|
+
python experiments/learning_demo.py
|
|
364
|
+
|
|
365
|
+
# Strategy evolution demo - observe strategy mutations
|
|
366
|
+
python experiments/strategy_evolution_demo.py
|
|
367
|
+
|
|
368
|
+
# Pattern detection demo - test player pattern recognition
|
|
369
|
+
python experiments/player_pattern_test.py
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### What You'll See
|
|
373
|
+
|
|
374
|
+
- **Learning Demo** — Villain win rate improves from ~20% to ~80% as it learns
|
|
375
|
+
- **Evolution Demo** — Strategies mutate and adapt over 100 rounds
|
|
376
|
+
- **Pattern Test** — Detect player archetypes (aggressive, defensive, evasive)
|
|
377
|
+
|
|
378
|
+
---
|
|
379
|
+
|
|
380
|
+
## Villain Leaderboard
|
|
381
|
+
|
|
382
|
+
Community rankings for the smartest villains:
|
|
383
|
+
|
|
384
|
+
| Rank | Name | Strategy | Win Rate |
|
|
385
|
+
|------|------|----------|----------|
|
|
386
|
+
| 1 | trap_master_v2 | adaptive_trap_strategy | 91% |
|
|
387
|
+
| 2 | chaos_overlord | chaos_manipulation | 86% |
|
|
388
|
+
| 3 | mind_reader | predictive_counter | 82% |
|
|
389
|
+
| 4 | aggressive_berserker | rush_strategy | 78% |
|
|
390
|
+
| 5 | defensive_turtle | fortress_strategy | 65% |
|
|
391
|
+
|
|
392
|
+
### Submit Your Villain
|
|
393
|
+
|
|
394
|
+
```python
|
|
395
|
+
from leaderboard import VillainLeaderboard
|
|
396
|
+
|
|
397
|
+
lb = VillainLeaderboard()
|
|
398
|
+
lb.add_entry(
|
|
399
|
+
villain_name="my_villain",
|
|
400
|
+
strategy="my_strategy",
|
|
401
|
+
win_rate=0.85,
|
|
402
|
+
rounds_tested=100,
|
|
403
|
+
personality={...}
|
|
404
|
+
)
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
See [Leaderboard](leaderboard/README.md) for full submission guidelines.
|
|
408
|
+
|
|
409
|
+
---
|
|
410
|
+
|
|
411
|
+
## Villain Personality Generator
|
|
412
|
+
|
|
413
|
+
Generate unique villain personalities:
|
|
414
|
+
|
|
415
|
+
```python
|
|
416
|
+
from villains import PersonalityGenerator
|
|
417
|
+
|
|
418
|
+
generator = PersonalityGenerator()
|
|
419
|
+
|
|
420
|
+
# Random personality
|
|
421
|
+
villain = generator.generate_random()
|
|
422
|
+
|
|
423
|
+
# From archetype
|
|
424
|
+
villain = generator.generate_from_archetype("the_mind_reader")
|
|
425
|
+
|
|
426
|
+
# Pre-made villains
|
|
427
|
+
from villains import load_villain
|
|
428
|
+
villain = load_villain("chaos_overlord")
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
### Available Archetypes
|
|
432
|
+
|
|
433
|
+
- **the_calculating_tyrant** — Patient strategist
|
|
434
|
+
- **the_chaos_overlord** — Unpredictable force
|
|
435
|
+
- **the_mind_reader** — Master psychologist
|
|
436
|
+
- **the_aggressive_berserker** — Relentless warrior
|
|
437
|
+
- **the_defensive_turtle** — Impenetrable defense
|
|
438
|
+
- And more!
|
|
439
|
+
|
|
440
|
+
See [Villain Generator](villains/README.md) for full documentation.
|
|
441
|
+
|
|
442
|
+
---
|
|
443
|
+
|
|
444
|
+
## Configuration
|
|
445
|
+
|
|
446
|
+
### Personality Traits
|
|
447
|
+
|
|
448
|
+
| Trait | Range | Effect |
|
|
449
|
+
|-------|-------|--------|
|
|
450
|
+
| `aggression` | 0-1 | Prefers offensive actions |
|
|
451
|
+
| `patience` | 0-1 | Willing to wait and plan |
|
|
452
|
+
| `ego` | 0-1 | Risk tolerance, confidence |
|
|
453
|
+
| `chaos` | 0-1 | Tendency for random actions |
|
|
454
|
+
| `adaptability` | 0-1 | Speed of learning |
|
|
455
|
+
| `caution` | 0-1 | Defensive preference |
|
|
456
|
+
|
|
457
|
+
### Config File
|
|
458
|
+
|
|
459
|
+
```python
|
|
460
|
+
from aivill import Config
|
|
461
|
+
|
|
462
|
+
config = Config({
|
|
463
|
+
"name": "Custom Villain",
|
|
464
|
+
"llm_model": "qwen2.5",
|
|
465
|
+
"personality": {
|
|
466
|
+
"aggression": 0.7,
|
|
467
|
+
"patience": 0.3,
|
|
468
|
+
"ego": 0.8,
|
|
469
|
+
"chaos": 0.2,
|
|
470
|
+
"adaptability": 0.8,
|
|
471
|
+
"caution": 0.2
|
|
472
|
+
}
|
|
473
|
+
})
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
---
|
|
477
|
+
|
|
478
|
+
## Repository Structure
|
|
479
|
+
|
|
480
|
+
```
|
|
481
|
+
aivill/
|
|
482
|
+
├── aivill/ # Main package
|
|
483
|
+
│ ├── __init__.py # Exports
|
|
484
|
+
│ ├── config.py # Configuration
|
|
485
|
+
│ ├── exceptions.py # Custom exceptions
|
|
486
|
+
│ ├── core/ # Engine, decisions
|
|
487
|
+
│ ├── memory/ # Memory management
|
|
488
|
+
│ ├── learning/ # Reinforcement learning
|
|
489
|
+
│ ├── strategy/ # Strategy engine + mutations
|
|
490
|
+
│ ├── personality/ # Personality traits
|
|
491
|
+
│ ├── llm/ # Ollama client
|
|
492
|
+
│ └── logging/ # Event logger
|
|
493
|
+
│
|
|
494
|
+
├── examples/ # Demo scripts
|
|
495
|
+
│ ├── automated_test.py
|
|
496
|
+
│ ├── stress_test.py
|
|
497
|
+
│ └── terminal_demo.py
|
|
498
|
+
│
|
|
499
|
+
├── tests/ # pytest suite
|
|
500
|
+
├── docs/ # Documentation
|
|
501
|
+
├── data/ # Memory storage
|
|
502
|
+
├── logs/ # Event logs
|
|
503
|
+
└── pyproject.toml # Package config
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
---
|
|
507
|
+
|
|
508
|
+
## Built With
|
|
509
|
+
|
|
510
|
+
* **Python** — Core language
|
|
511
|
+
* **Reinforcement Learning** — Q-learning strategy updates
|
|
512
|
+
* **Local LLMs (Ollama)** — Optional reasoning
|
|
513
|
+
* **Modular Architecture** — Swappable components
|
|
514
|
+
|
|
515
|
+
---
|
|
516
|
+
|
|
517
|
+
## Roadmap
|
|
518
|
+
|
|
519
|
+
- [ ] Advanced reinforcement learning algorithms
|
|
520
|
+
- [ ] Emergent strategy generation
|
|
521
|
+
- [ ] Multi-agent villain ecosystems
|
|
522
|
+
- [ ] Environment awareness system
|
|
523
|
+
- [ ] Visualization tools
|
|
524
|
+
- [ ] Unity/Unreal engine plugins
|
|
525
|
+
- [ ] Web-based dashboard
|
|
526
|
+
|
|
527
|
+
---
|
|
528
|
+
|
|
529
|
+
## AiVill Research Playground
|
|
530
|
+
|
|
531
|
+
AiVill is an **experimental platform for adaptive AI research in games**.
|
|
532
|
+
|
|
533
|
+
### Open Research Ideas
|
|
534
|
+
|
|
535
|
+
* **Emergent Villain Strategies** — Can strategies evolve beyond human design?
|
|
536
|
+
* **Player Psychology Modeling** — Detecting and exploiting player tendencies
|
|
537
|
+
* **Adaptive Boss Battles** — Learning bosses that counter player builds
|
|
538
|
+
* **Narrative-Aware Antagonists** — Villains that remember story events
|
|
539
|
+
* **Multi-Agent Ecosystems** — Villain factions that coordinate
|
|
540
|
+
* **Transfer Learning** — Villains that learn across multiple games
|
|
541
|
+
|
|
542
|
+
---
|
|
543
|
+
|
|
544
|
+
## The Adaptive Villain Challenge
|
|
545
|
+
|
|
546
|
+
Can you create the **most intelligent villain** using AiVill?
|
|
547
|
+
|
|
548
|
+
### Challenge
|
|
549
|
+
|
|
550
|
+
Build a villain that:
|
|
551
|
+
|
|
552
|
+
1. Learns a player's strategy within 10 rounds
|
|
553
|
+
2. Adapts to counter the player's strengths
|
|
554
|
+
3. Defeats the player within 20 rounds
|
|
555
|
+
|
|
556
|
+
### Submit
|
|
557
|
+
|
|
558
|
+
* Share your strategies, configurations, and results
|
|
559
|
+
* Open an issue with your approach
|
|
560
|
+
* Submit pull requests with improvements
|
|
561
|
+
|
|
562
|
+
Let's push adaptive AI in games forward together!
|
|
563
|
+
|
|
564
|
+
---
|
|
565
|
+
|
|
566
|
+
## Contributing
|
|
567
|
+
|
|
568
|
+
Contributions welcome! Areas of interest:
|
|
569
|
+
|
|
570
|
+
* **AI Algorithms** — Improve learning, strategy selection
|
|
571
|
+
* **Strategy Mutations** — Novel tactical variations
|
|
572
|
+
* **Reinforcement Learning** — Better reward functions
|
|
573
|
+
* **LLM Prompts** — More intelligent reasoning
|
|
574
|
+
* **Game Integrations** — Unity, Godot, Unreal wrappers
|
|
575
|
+
* **Performance** — Edge deployment optimizations
|
|
576
|
+
|
|
577
|
+
See [CONTRIBUTING.md](docs/CONTRIBUTING.md) for guidelines.
|
|
578
|
+
|
|
579
|
+
---
|
|
580
|
+
|
|
581
|
+
## License
|
|
582
|
+
|
|
583
|
+
MIT License — See [LICENSE](LICENSE) for details.
|
|
584
|
+
|
|
585
|
+
---
|
|
586
|
+
|
|
587
|
+
## Vision
|
|
588
|
+
|
|
589
|
+
AiVill aims to transform game villains from **scripted obstacles** into **genuine adversaries that learn, adapt, and evolve**.
|
|
590
|
+
|
|
591
|
+
Every player deserves an antagonist who:
|
|
592
|
+
|
|
593
|
+
* Remembers their past victories
|
|
594
|
+
* Learns from their mistakes
|
|
595
|
+
* Develops a unique personality
|
|
596
|
+
* Makes each encounter feel alive
|
|
597
|
+
|
|
598
|
+
That's the future AiVill is building.
|
|
599
|
+
|
|
600
|
+
---
|
|
601
|
+
|
|
602
|
+
## Repository Topics
|
|
603
|
+
|
|
604
|
+
`ai` `game-ai` `adaptive-ai` `reinforcement-learning` `procedural-ai` `game-development` `ai-agents` `ollama` `llm` `game-enemy-ai` `self-learning` `adaptive-villain`
|
|
605
|
+
|
|
606
|
+
---
|
|
607
|
+
|
|
608
|
+
## Star History
|
|
609
|
+
|
|
610
|
+
If AiVill inspires you, please ⭐ star the repository to show your support!
|
|
611
|
+
|
|
612
|
+
[](https://star-history.com/#aivill/aivill&Date)
|
|
613
|
+
|
|
614
|
+
---
|
|
615
|
+
|
|
616
|
+
**Star AiVill today and help create the next generation of game AI!**
|