sankalphs commited on
Commit
65bf006
·
verified ·
1 Parent(s): a27e70f

Add model card

Browse files
Files changed (1) hide show
  1. README.md +88 -0
README.md ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - fighting-game
5
+ - tiny-model
6
+ - reinforcement-learning
7
+ - game-ai
8
+ library_name: torch
9
+ ---
10
+
11
+ # Duel Tiny Fighter (78,863 parameters)
12
+
13
+ A real-time CPU policy network for NPC move selection in a 3D fighting game.
14
+ Runs in <1ms per inference on CPU, conditioned on Nemotron strategic weights.
15
+
16
+ ## Architecture
17
+
18
+ | Layer | Shape | Notes |
19
+ |-------|-------|-------|
20
+ | Linear | 168 → 256 | One-hot move history + scalars |
21
+ | LayerNorm | 256 | Stable at batch=1 inference |
22
+ | ReLU + Dropout(0.1) | | |
23
+ | Linear | 256 → 128 | |
24
+ | LayerNorm | 128 | |
25
+ | ReLU + Dropout(0.1) | | |
26
+ | Linear | 128 → 15 | Logits over 15 moves |
27
+
28
+ **Total parameters:** 78,863
29
+
30
+ ## Move Vocabulary
31
+
32
+ `jab`, `cross`, `hook`, `kick`, `uppercut`, `block`, `parry`, `dodge`,
33
+ `advance`, `retreat`, `grapple`, `throw`, `sweep`, `feint`, `wait`
34
+
35
+ ## Input Features (168-dim)
36
+
37
+ - Last 5 NPC moves (5 × 15 one-hot = 75)
38
+ - Last 5 player moves (5 × 15 one-hot = 75)
39
+ - HP difference, stamina difference (2)
40
+ - Distance one-hot (3)
41
+ - Strategy weights: aggression, defense, parry_affinity, kick_affinity, grapple_affinity (5)
42
+ - Round normalised (1)
43
+ - Absolute HP, stamina for both (4)
44
+ - Padding to 168
45
+
46
+ ## Inference
47
+
48
+ ```python
49
+ import torch
50
+ from tiny_fighter import TinyFighter, state_to_features, make_move_mask
51
+
52
+ model = TinyFighter()
53
+ model.load_state_dict(torch.load("tiny_fighter.pt", map_location="cpu"), strict=False)
54
+ model.eval()
55
+
56
+ feats = state_to_features(
57
+ last_npc_moves=["jab", "block"],
58
+ last_player_moves=["cross", "retreat"],
59
+ player_hp=80.0, npc_hp=50.0,
60
+ player_stamina=60.0, npc_stamina=40.0,
61
+ distance="mid",
62
+ aggression=0.7, defense=0.3,
63
+ parry_affinity=0.4, kick_affinity=0.6,
64
+ grapple_affinity=0.2,
65
+ )
66
+ mask = make_move_mask("mid")
67
+
68
+ with torch.inference_mode():
69
+ logits = model.predict(feats, mask)
70
+ move = logits.softmax(-1).argmax().item()
71
+
72
+ print(f"Selected: {model.MOVES[move]}")
73
+ ```
74
+
75
+ ## Training
76
+
77
+ Trained on 20k procedurally generated (state, strategy_weights) → move examples
78
+ using supervised learning on CPU. The model learns to map Nemotron's strategic
79
+ direction (aggressive/defensive/grappling) into concrete move probabilities.
80
+
81
+ ## Part of Duel of Nemotron
82
+
83
+ - **Strategist:** Nemotron 3 Nano 4B (fine-tuned, Modal A10)
84
+ - **Executor:** This tiny model (CPU, <1ms)
85
+ - **Game:** React + Three.js 3D fighting game
86
+
87
+ Built for the [Build Small Hackathon](https://huggingface.co/build-small-hackathon)
88
+ by [@sankalphs](https://huggingface.co/sankalphs).