File size: 9,082 Bytes
295d147 | 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 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | import argparse
import json
import random
from pathlib import Path
UNITY_CAPSULE = """Create the capsule player object and attach movement logic to it. A Unity capsule primitive already has a `CapsuleCollider`, so the clean option is to add a `CharacterController` and move through it.
```csharp
using UnityEngine;
[RequireComponent(typeof(CharacterController))]
public class CapsulePlayerMovement : MonoBehaviour
{
[SerializeField] private float moveSpeed = 5f;
private CharacterController controller;
private void Awake()
{
controller = GetComponent<CharacterController>();
}
private void Update()
{
float x = Input.GetAxisRaw("Horizontal");
float z = Input.GetAxisRaw("Vertical");
Vector3 direction = new Vector3(x, 0f, z).normalized;
controller.Move(direction * moveSpeed * Time.deltaTime);
}
}
```
```csharp
using UnityEngine;
public class CapsulePlayerSpawner : MonoBehaviour
{
private void Start()
{
GameObject player = GameObject.CreatePrimitive(PrimitiveType.Capsule);
player.name = "PlayerCapsule";
player.transform.position = new Vector3(0f, 1f, 0f);
CapsuleCollider capsuleCollider = player.GetComponent<CapsuleCollider>();
if (capsuleCollider != null)
Object.Destroy(capsuleCollider);
CharacterController controller = player.AddComponent<CharacterController>();
controller.height = 2f;
controller.radius = 0.5f;
controller.center = new Vector3(0f, 1f, 0f);
player.AddComponent<CapsulePlayerMovement>();
}
}
```
Attach `CapsulePlayerSpawner` to an empty GameObject in the scene. Press Play and the script creates a capsule player with collider-based WASD movement."""
UNITY_RIGIDBODY_CAPSULE = """Create a capsule with a `CapsuleCollider`, add a `Rigidbody`, and move it with WASD in `FixedUpdate`.
```csharp
using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
[RequireComponent(typeof(CapsuleCollider))]
public class RigidbodyCapsuleMovement : MonoBehaviour
{
[SerializeField] private float moveSpeed = 5f;
private Rigidbody rb;
private Vector3 input;
private void Awake()
{
rb = GetComponent<Rigidbody>();
rb.freezeRotation = true;
}
private void Update()
{
float x = Input.GetAxisRaw("Horizontal");
float z = Input.GetAxisRaw("Vertical");
input = new Vector3(x, 0f, z).normalized;
}
private void FixedUpdate()
{
Vector3 nextPosition = rb.position + input * moveSpeed * Time.fixedDeltaTime;
rb.MovePosition(nextPosition);
}
}
```
```csharp
using UnityEngine;
public class RigidbodyCapsuleSpawner : MonoBehaviour
{
private void Start()
{
GameObject player = GameObject.CreatePrimitive(PrimitiveType.Capsule);
player.name = "RigidbodyCapsulePlayer";
player.transform.position = new Vector3(0f, 1f, 0f);
Rigidbody rb = player.AddComponent<Rigidbody>();
rb.freezeRotation = true;
player.AddComponent<RigidbodyCapsuleMovement>();
}
}
```"""
GODOT_CAPSULE = """Create a `CharacterBody3D` with a capsule mesh, capsule collision shape, and WASD movement.
```gdscript
extends Node3D
func _ready() -> void:
var player := CharacterBody3D.new()
player.name = "CapsulePlayer"
var mesh := MeshInstance3D.new()
mesh.mesh = CapsuleMesh.new()
player.add_child(mesh)
var collision := CollisionShape3D.new()
collision.shape = CapsuleShape3D.new()
player.add_child(collision)
player.set_script(preload("res://CapsulePlayerMovement.gd"))
add_child(player)
```
```gdscript
# CapsulePlayerMovement.gd
extends CharacterBody3D
@export var move_speed := 5.0
func _physics_process(_delta: float) -> void:
var input_dir := Input.get_vector("move_left", "move_right", "move_forward", "move_back")
var direction := Vector3(input_dir.x, 0.0, input_dir.y).normalized()
velocity.x = direction.x * move_speed
velocity.z = direction.z * move_speed
move_and_slide()
```
Add input actions for `move_left`, `move_right`, `move_forward`, and `move_back`, then bind them to A, D, W, and S."""
UNITY_CAMERA_CAPSULE = """Create a capsule player, add collider-based WASD movement, and make the camera follow it.
```csharp
using UnityEngine;
[RequireComponent(typeof(CharacterController))]
public class CapsulePlayerMovement : MonoBehaviour
{
[SerializeField] private float moveSpeed = 5f;
private CharacterController controller;
private void Awake()
{
controller = GetComponent<CharacterController>();
}
private void Update()
{
Vector3 direction = new Vector3(Input.GetAxisRaw("Horizontal"), 0f, Input.GetAxisRaw("Vertical")).normalized;
controller.Move(direction * moveSpeed * Time.deltaTime);
}
}
```
```csharp
using UnityEngine;
public class FollowCamera : MonoBehaviour
{
[SerializeField] private Transform target;
[SerializeField] private Vector3 offset = new Vector3(0f, 4f, -6f);
[SerializeField] private float smoothTime = 0.15f;
private Vector3 velocity;
public void SetTarget(Transform newTarget)
{
target = newTarget;
}
private void LateUpdate()
{
if (target == null)
return;
transform.position = Vector3.SmoothDamp(transform.position, target.position + offset, ref velocity, smoothTime);
transform.LookAt(target);
}
}
```
```csharp
using UnityEngine;
public class CapsulePlayerSceneSetup : MonoBehaviour
{
private void Start()
{
GameObject player = GameObject.CreatePrimitive(PrimitiveType.Capsule);
player.name = "PlayerCapsule";
player.transform.position = new Vector3(0f, 1f, 0f);
Object.Destroy(player.GetComponent<CapsuleCollider>());
player.AddComponent<CharacterController>();
player.AddComponent<CapsulePlayerMovement>();
Camera mainCamera = Camera.main;
if (mainCamera != null)
{
FollowCamera follow = mainCamera.gameObject.AddComponent<FollowCamera>();
follow.SetTarget(player.transform);
}
}
}
```"""
COMMANDS = [
{
"domain": "unity",
"answer": UNITY_CAPSULE,
"prompts": [
"create a capsule and its collider, give wasd movement logic to it for unity project",
"create a capsule player with collider and WASD movement in Unity",
"Unity project: create capsule, add collider, add wasd movement",
"make a capsule object with collider and keyboard movement",
"capsule player objesi olustur collider ekle wasd hareket ver unity",
"generate a capsule character controller with WASD controls",
],
},
{
"domain": "unity",
"answer": UNITY_RIGIDBODY_CAPSULE,
"prompts": [
"create a physics capsule with rigidbody collider and wasd movement",
"Unity rigidbody capsule movement with WASD",
"make a capsule player using rigidbody MovePosition",
"capsule collider rigidbody ile wasd hareket sistemi yaz",
],
},
{
"domain": "godot",
"answer": GODOT_CAPSULE,
"prompts": [
"create a capsule character and give it wasd movement in godot",
"Godot 4 create capsule with collision and WASD movement",
"capsule player collision shape and movement gdscript",
"godot kapsul karakter olustur collider ekle wasd hareket ver",
],
},
{
"domain": "unity",
"answer": UNITY_CAMERA_CAPSULE,
"prompts": [
"create a capsule player with collider wasd movement and camera follow",
"Unity capsule controller plus follow camera",
"make capsule player move with WASD and make camera follow it",
"capsule player olustur wasd hareket ve kamera takip ekle",
],
},
]
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--out", default="data/instructions/compound_game_commands_v4.jsonl")
parser.add_argument("--repeat", type=int, default=900)
parser.add_argument("--seed", type=int, default=9904)
args = parser.parse_args()
rows = []
for item in COMMANDS:
for _ in range(args.repeat):
for prompt in item["prompts"]:
rows.append(
{
"domain": item["domain"],
"instruction": prompt,
"answer": item["answer"],
"source": "synthetic_compound_game_command",
}
)
random.seed(args.seed)
random.shuffle(rows)
out = Path(args.out)
out.parent.mkdir(parents=True, exist_ok=True)
with out.open("w", encoding="utf-8") as f:
for row in rows:
f.write(json.dumps(row, ensure_ascii=False) + "\n")
print(f"wrote {len(rows)} rows -> {out}")
if __name__ == "__main__":
main()
|