File size: 2,585 Bytes
16eaadc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: OPTCG Deck Builder
colorFrom: red
colorTo: blue
sdk: gradio
sdk_version: 5.49.1
python_version: "3.12"
app_file: app.py
pinned: false
license: mit
short_description: Auto-build legal 50-card One Piece TCG decks
---

# OPTCG Deck Builder

Pick any **Leader** from the [optcg-en-card-embeddings](https://huggingface.co/datasets/t22000t/optcg-en-card-embeddings) dataset and the Space generates a legal 50-card OPTCG deck around it. The ranker layers OPTCG deckbuilding rules on top of the Qwen3-Embedding-derived synergy score:

- **Color legality** - every card shares at least one color with the Leader.
- **Family bonus** - cards in the Leader's family (Straw Hat Crew, Marines, etc.) get a +0.10 synergy boost so they outrank merely-similar off-archetype options.
- **Copy cap** - each card appears at most 4 times (the OPTCG standard).
- **Cost curve targeting** - one of three style presets shapes how slots are distributed across costs.

Sister Space: [OPTCG Card Explorer](https://huggingface.co/spaces/t22000t/optcg-explorer) - semantic search, UMAP scatter, similar-cards browser.

## Style presets

Each preset is a target distribution that sums to 50 cards. The builder fills cost buckets in order, and any deficit at the end spills into a backfill pass over remaining top-synergy cards (so the total is *always* 50).

| Cost   | aggro | midrange | control |
|--------|------:|---------:|--------:|
| 1      |     4 |        0 |       0 |
| 2      |    12 |        6 |       4 |
| 3      |    12 |       10 |       8 |
| 4      |     8 |       10 |       8 |
| 5      |     6 |        8 |       8 |
| 6      |     4 |        8 |       8 |
| 7      |     2 |        4 |       6 |
| 8+     |     2 |        4 |       8 |

## What the Space does *not* do

- No archetype/strategy detection (it does not know that, say, "Monkey.D.Luffy / OP01-001" is the aggro leader).
- No banlist or meta awareness.
- No card art (this is a structured-data / text-only project by design - see [parent project](https://github.com/timothy22000/optcg-cards) for the IP rationale).
- The result is a sketch you tweak, not a tournament-ready list.

## Configuration

- `HF_TOKEN` (Space secret) - required only while the source dataset stays private.

## Development

```bash
pip install -r requirements.txt
export HF_TOKEN=hf_...   # only if the source dataset is private
python app.py
```

```bash
pytest -v        # 21 hermetic tests
```

## License

MIT. Card data via the [vegapull](https://github.com/Coko7/vegapull) scraper. Not affiliated with Bandai or the One Piece Card Game.