File size: 5,155 Bytes
410c365
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
---
base_model: Qwen/Qwen3.5-4B
base_model_relation: finetune
library_name: transformers
pipeline_tag: image-text-to-text
license: apache-2.0
tags:
  - qwen3.5
  - game2player
  - visual-agent
  - game-playing
  - sft
model_name: Game2Player 4B
---

# Game2Player 4B

Game2Player 4B is a visual game-playing model fine-tuned from
[Qwen3.5-4B](https://huggingface.co/Qwen/Qwen3.5-4B). It takes game
screenshots, a task description and recent actions as input, then predicts the
next keyboard or mouse action.

This repository contains the complete model weights. Load it directly with
vLLM or Transformers.

**Game2Player: Scaling Gameplay Experience for Visual Agents through
Environment–Player Co-Development**

[Project](https://game2player.github.io/) ·
[Code](https://github.com/game2player/Game2Player) ·
[PlayerBench](https://github.com/game2player/Game2Player/tree/main/benchmark/playerbench)

## Training

The model was trained on gameplay collected from code policies and VLM players
with Game2Player. Training updates the language model while keeping the vision
encoder and visual projector frozen.

| Setting | Value |
| --- | --- |
| Training examples | 1,564,236 |
| Training duration | One epoch, 9,237 optimizer steps |
| Maximum training sequence length | 25,000 tokens |
| Learning rate | 0.00001 with a cosine schedule |
| Weight precision | BF16 |

Dataset coming soon.

## Input and output

Provide the game rules, available controls and task goal in the system message.
The user message contains the current screenshot and, when available, up to
50 previous actions with their short notes and six previous screenshots.
Use at most seven images in total and about 1,024 visual tokens per image.

The model returns a `computer_use` action inside `<tool_call>` tags. For example:

```text
<tool_call>
{"name":"computer_use","arguments":{"action":"press_key","key":"ArrowRight","reasoning":"Move toward the exit."}}
</tool_call>
```

The `reasoning` field contains a short action note. Longer thinking, when enabled,
is returned separately. Mouse coordinates use a normalized 0–1000 range and
action durations are in seconds.

## Run the model

Install vLLM and start an OpenAI-compatible server:

```bash
pip install vllm==0.29.0 requests

vllm serve game2player/Game2Player-4B \
  --served-model-name game2player-4b \
  --dtype bfloat16 \
  --max-model-len 65536 \
  --max-num-seqs 8 \
  --max-num-batched-tokens 4096 \
  --limit-mm-per-prompt '{"image":7,"video":0}' \
  --mm-processor-kwargs '{"max_pixels":1048576}' \
  --reasoning-parser qwen3
```

Save a screenshot as `screen.png` and send a request. Replace the example game
rules and task with those of the game you want to play.

```python
import base64
from pathlib import Path
import requests

system_prompt = """You are an expert game agent. Choose the next action from the screenshot.

# Game Rules
Move the character through the maze to reach the exit. Walls block movement.

# Role and Controls
ArrowUp, ArrowDown, ArrowLeft and ArrowRight move the character.

# Task Instruction
Reach the exit.

# Output Format
Return exactly one action inside <tool_call> tags.
Use press_key with a key from the controls above, or wait with a duration in seconds.
Include reasoning with one short sentence explaining the action.
Think in the thinking channel, then emit only the tool call as the final answer.
Example:
<tool_call>{"name":"computer_use","arguments":{"action":"press_key","key":"ArrowRight","reasoning":"Move toward the exit."}}</tool_call>
"""

encoded = base64.b64encode(Path("screen.png").read_bytes()).decode("ascii")
response = requests.post(
    "http://localhost:8000/v1/chat/completions",
    json={
        "model": "game2player-4b",
        "messages": [
            {"role": "system", "content": system_prompt},
            {"role": "user", "content": [
                {"type": "text", "text": "# Current step\nCurrent game screen:\n"},
                {"type": "image_url", "image_url": {
                    "url": "data:image/png;base64," + encoded
                }},
                {"type": "text", "text": "\nReturn the next action."},
            ]},
        ],
        "temperature": 1.0,
        "max_tokens": 512,
        "chat_template_kwargs": {"enable_thinking": False},
    },
    timeout=180,
)
response.raise_for_status()
print(response.json()["choices"][0]["message"]["content"])
```

To enable thinking, set `enable_thinking` to `True` and increase `max_tokens` and
the request timeout. Our thinking evaluations allow up to 32,768 output tokens.
Keep previous action notes in the history and omit previous thinking chains.

## Evaluation

We evaluate Game2Player on PlayerBench, which contains 50 held-out games and
287 tasks, and GameWorld, which contains 34 games and 170 tasks. Results are
available on the [project leaderboard](https://game2player.github.io/#leaderboard).

## License

The model weights are released under [Apache-2.0](LICENSE).
Qwen3.5 is also licensed under Apache-2.0. Game titles, assets and screenshots
belong to their respective owners. The model license does not grant rights to
third-party game content.