File size: 14,882 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 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | import argparse
import json
import random
from pathlib import Path
TASKS = [
{
"name": "wasd_movement",
"prompts": [
"add wasd movement logic to the player object",
"make my player move with WASD",
"create a basic player movement script",
"player objesine wasd hareket sistemi ekle",
"karakteri klavye ile hareket ettiren kod yaz",
],
"answers": {
"unity": """Attach this script to the Player GameObject. It reads WASD/arrow input and moves the object every frame.
```csharp
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
[SerializeField] private float moveSpeed = 5f;
private void Update()
{
float x = Input.GetAxisRaw("Horizontal");
float z = Input.GetAxisRaw("Vertical");
Vector3 direction = new Vector3(x, 0f, z).normalized;
transform.position += direction * moveSpeed * Time.deltaTime;
}
}
```
If the player uses physics, move the same direction in `FixedUpdate` with `Rigidbody.MovePosition` instead of changing `transform.position`.""",
"godot": """Attach this script to a `CharacterBody3D` player. It reads WASD actions and moves the character.
```gdscript
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 map actions for `move_left`, `move_right`, `move_forward`, and `move_back`, then bind them to A, D, W, and S.""",
"unreal": """Add movement input in your character class and bind WASD axis mappings to it.
```cpp
void AMyPlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
PlayerInputComponent->BindAxis("MoveForward", this, &AMyPlayerCharacter::MoveForward);
PlayerInputComponent->BindAxis("MoveRight", this, &AMyPlayerCharacter::MoveRight);
}
void AMyPlayerCharacter::MoveForward(float Value)
{
if (Controller && Value != 0.0f)
{
AddMovementInput(GetActorForwardVector(), Value);
}
}
void AMyPlayerCharacter::MoveRight(float Value)
{
if (Controller && Value != 0.0f)
{
AddMovementInput(GetActorRightVector(), Value);
}
}
```
Create `MoveForward` and `MoveRight` axis mappings in Project Settings or Enhanced Input, then bind W/S and A/D.""",
},
},
{
"name": "jump",
"prompts": [
"add jump to the player",
"make the character jump when space is pressed",
"space tusuyla ziplama ekle",
"player jump logic yaz",
],
"answers": {
"unity": """Use a Rigidbody-based jump and only allow jumping while grounded.
```csharp
using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
public class PlayerJump : MonoBehaviour
{
[SerializeField] private float jumpForce = 6f;
[SerializeField] private Transform groundCheck;
[SerializeField] private float groundRadius = 0.2f;
[SerializeField] private LayerMask groundMask;
private Rigidbody rb;
private void Awake()
{
rb = GetComponent<Rigidbody>();
}
private void Update()
{
bool grounded = Physics.CheckSphere(groundCheck.position, groundRadius, groundMask);
if (grounded && Input.GetKeyDown(KeyCode.Space))
{
rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
}
}
}
```""",
"godot": """For `CharacterBody3D`, apply jump velocity only when the body is on the floor.
```gdscript
extends CharacterBody3D
@export var move_speed := 5.0
@export var jump_velocity := 6.0
@export var gravity := 20.0
func _physics_process(delta: float) -> void:
if not is_on_floor():
velocity.y -= gravity * delta
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = jump_velocity
move_and_slide()
```""",
"unreal": """If your class inherits from `ACharacter`, Unreal already provides jump helpers.
```cpp
void AMyPlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &ACharacter::Jump);
PlayerInputComponent->BindAction("Jump", IE_Released, this, &ACharacter::StopJumping);
}
```
Set `Jump Z Velocity` on the Character Movement component to tune the jump height.""",
},
},
{
"name": "red_cube",
"prompts": [
"create a red cube in the scene",
"add a cube and make it red",
"sahneye kirmizi kup ekle",
"spawn red cube object",
],
"answers": {
"unity": """Create a cube, assign a red material, and place it in front of the camera.
```csharp
using UnityEngine;
public class RedCubeSpawner : MonoBehaviour
{
private void Start()
{
GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.name = "Red Cube";
cube.transform.position = new Vector3(0f, 1f, 0f);
Renderer renderer = cube.GetComponent<Renderer>();
renderer.material = new Material(Shader.Find("Standard"));
renderer.material.color = Color.red;
}
}
```""",
"godot": """Create a `MeshInstance3D`, assign a `BoxMesh`, and give it a red material.
```gdscript
extends Node3D
func _ready() -> void:
var cube := MeshInstance3D.new()
cube.name = "RedCube"
cube.mesh = BoxMesh.new()
var mat := StandardMaterial3D.new()
mat.albedo_color = Color.RED
cube.material_override = mat
cube.position = Vector3(0, 1, 0)
add_child(cube)
```""",
"unreal": """Spawn a cube mesh actor and assign a red material instance in C++.
```cpp
// In BeginPlay after assigning CubeMesh and RedMaterial in the editor.
FActorSpawnParameters Params;
AStaticMeshActor* Cube = GetWorld()->SpawnActor<AStaticMeshActor>(AStaticMeshActor::StaticClass(), FVector(0, 0, 100), FRotator::ZeroRotator, Params);
Cube->GetStaticMeshComponent()->SetStaticMesh(CubeMesh);
Cube->GetStaticMeshComponent()->SetMaterial(0, RedMaterial);
Cube->SetActorLabel(TEXT("RedCube"));
```
Expose `CubeMesh` and `RedMaterial` as `UPROPERTY(EditAnywhere)` fields so they can be assigned in the editor.""",
},
},
{
"name": "health",
"prompts": [
"add health system to the player",
"write player health logic",
"player can take damage and die",
"oyuncuya can sistemi ekle",
],
"answers": {
"unity": """Put health in its own component so player, enemies, and destructible objects can reuse it.
```csharp
using System;
using UnityEngine;
public class Health : MonoBehaviour
{
[SerializeField] private int maxHealth = 100;
public int CurrentHealth { get; private set; }
public event Action<int, int> Changed;
public event Action Died;
private void Awake()
{
CurrentHealth = maxHealth;
}
public void TakeDamage(int amount)
{
CurrentHealth = Mathf.Max(CurrentHealth - amount, 0);
Changed?.Invoke(CurrentHealth, maxHealth);
if (CurrentHealth == 0)
Died?.Invoke();
}
}
```""",
"godot": """Use a small health component node and emit signals when health changes.
```gdscript
extends Node
signal health_changed(current: int, maximum: int)
signal died
@export var max_health := 100
var current_health := 100
func _ready() -> void:
current_health = max_health
func take_damage(amount: int) -> void:
current_health = max(current_health - amount, 0)
health_changed.emit(current_health, max_health)
if current_health == 0:
died.emit()
```""",
"unreal": """A reusable `UActorComponent` is the cleanest place for health.
```cpp
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class UHealthComponent : public UActorComponent
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Health")
float MaxHealth = 100.0f;
UPROPERTY(BlueprintReadOnly, Category="Health")
float CurrentHealth = 100.0f;
UFUNCTION(BlueprintCallable, Category="Health")
void ApplyDamage(float Amount)
{
CurrentHealth = FMath::Clamp(CurrentHealth - Amount, 0.0f, MaxHealth);
}
};
```""",
},
},
{
"name": "camera_follow",
"prompts": [
"add camera follow to player",
"make camera follow the player smoothly",
"kamerayi oyuncuyu takip edecek sekilde ayarla",
"third person follow camera code",
],
"answers": {
"unity": """Put this script on the Camera and assign the player Transform.
```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;
private void LateUpdate()
{
if (target == null)
return;
Vector3 desired = target.position + offset;
transform.position = Vector3.SmoothDamp(transform.position, desired, ref velocity, smoothTime);
transform.LookAt(target);
}
}
```""",
"godot": """Put a `Camera3D` under a spring arm or update the camera in `_physics_process`.
```gdscript
extends Camera3D
@export var target: Node3D
@export var offset := Vector3(0, 4, -6)
@export var follow_speed := 8.0
func _physics_process(delta: float) -> void:
if target == null:
return
global_position = global_position.lerp(target.global_position + offset, follow_speed * delta)
look_at(target.global_position)
```""",
"unreal": """For a third-person character, use a spring arm plus camera component.
```cpp
CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
CameraBoom->SetupAttachment(RootComponent);
CameraBoom->TargetArmLength = 350.0f;
CameraBoom->bUsePawnControlRotation = true;
FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));
FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName);
FollowCamera->bUsePawnControlRotation = false;
```
Then rotate the controller from mouse input and let the spring arm follow the character.""",
},
},
{
"name": "projectile",
"prompts": [
"shoot projectile when player presses left mouse",
"add fireball shooting logic",
"sol tikla mermi atma sistemi yaz",
"spawn projectile from player",
],
"answers": {
"unity": """Instantiate a projectile prefab from a fire point and push it forward.
```csharp
using UnityEngine;
public class PlayerShooter : MonoBehaviour
{
[SerializeField] private Rigidbody projectilePrefab;
[SerializeField] private Transform firePoint;
[SerializeField] private float projectileSpeed = 18f;
private void Update()
{
if (Input.GetMouseButtonDown(0))
{
Rigidbody projectile = Instantiate(projectilePrefab, firePoint.position, firePoint.rotation);
projectile.linearVelocity = firePoint.forward * projectileSpeed;
}
}
}
```""",
"godot": """Instantiate a projectile scene from a marker node and pass it velocity.
```gdscript
extends Node3D
@export var projectile_scene: PackedScene
@export var fire_point: Node3D
@export var projectile_speed := 18.0
func _process(_delta: float) -> void:
if Input.is_action_just_pressed("fire"):
var projectile := projectile_scene.instantiate()
projectile.global_transform = fire_point.global_transform
projectile.velocity = -fire_point.global_transform.basis.z * projectile_speed
get_tree().current_scene.add_child(projectile)
```""",
"unreal": """Spawn a projectile actor from a muzzle transform.
```cpp
void AMyPlayerCharacter::Fire()
{
if (!ProjectileClass)
return;
const FVector SpawnLocation = Muzzle->GetComponentLocation();
const FRotator SpawnRotation = Muzzle->GetComponentRotation();
GetWorld()->SpawnActor<AActor>(ProjectileClass, SpawnLocation, SpawnRotation);
}
```
Bind `Fire` to the left mouse button and give the projectile a movement component.""",
},
},
]
DOMAIN_PREFIXES = {
"unity": [
"Unity C# olarak yaz:",
"Write this for Unity:",
"Use MonoBehaviour and valid Unity API:",
],
"godot": [
"Godot 4 GDScript olarak yaz:",
"Write this for Godot:",
"Use Godot 4 nodes and GDScript:",
],
"unreal": [
"Unreal Engine 5 C++ olarak yaz:",
"Write this for Unreal Engine:",
"Use UE5 C++ macros and APIs:",
],
}
def make_rows(repeat):
rows = []
for task in TASKS:
for domain, answer in task["answers"].items():
prompts = []
for prompt in task["prompts"]:
prompts.append(prompt)
for prefix in DOMAIN_PREFIXES[domain]:
prompts.append(f"{prefix} {prompt}")
prompts.append(f"{domain} {task['name']} code")
prompts.append(f"{domain} icin {task['name']} sistemi yaz")
for _ in range(repeat):
for prompt in prompts:
rows.append(
{
"domain": domain,
"instruction": prompt,
"answer": answer,
"source": f"synthetic_direct_command/{task['name']}",
}
)
return rows
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--out", default="data/instructions/direct_game_commands_v1.jsonl")
parser.add_argument("--repeat", type=int, default=140)
parser.add_argument("--seed", type=int, default=6061)
args = parser.parse_args()
rows = make_rows(args.repeat)
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}")
for domain in ("godot", "unity", "unreal"):
print(f"{domain}: {sum(1 for row in rows if row['domain'] == domain)}")
if __name__ == "__main__":
main()
|