File size: 5,219 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 | import argparse
import json
import random
from pathlib import Path
ROWS = [
{
"domain": "godot",
"prompts": [
"sahneye kırmızı bir küp ekle",
"sahneye kirmizi kup ekle",
"Godot'ta sahneye kırmızı küp ekle",
"create a red cube in godot",
"add a cube and make it red in Godot 4",
],
"answer": """Create a `MeshInstance3D`, assign a `BoxMesh`, and give it a red `StandardMaterial3D`.
```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)
```
Attach this script to any `Node3D` in the scene. When the scene starts, it creates the red cube as a child.""",
},
{
"domain": "unreal",
"prompts": [
"add camera follow to player",
"make camera follow the player smoothly",
"third person follow camera code",
"Unreal Engine 5 C++ add camera follow to player",
"kamerayi oyuncuyu takip edecek sekilde ayarla unreal",
],
"answer": """For a third-person Unreal character, use a `USpringArmComponent` and a `UCameraComponent`. The spring arm follows the player and smooths camera placement.
```cpp
// MyPlayerCharacter.h
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Camera")
USpringArmComponent* CameraBoom;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Camera")
UCameraComponent* FollowCamera;
```
```cpp
// MyPlayerCharacter.cpp
AMyPlayerCharacter::AMyPlayerCharacter()
{
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;
}
```
Include `GameFramework/SpringArmComponent.h` and `Camera/CameraComponent.h`. Then rotate the controller from mouse input and let the spring arm follow the character.""",
},
{
"domain": "unity",
"prompts": [
"add wasd movement logic to the player object",
"make my player move with WASD",
"Unity C# add wasd movement to player",
"player objesine wasd hareket sistemi ekle",
],
"answer": """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`.""",
},
{
"domain": "unreal",
"prompts": [
"shoot projectile when player presses left mouse",
"spawn projectile from player unreal",
"Unreal Engine 5 C++ fire projectile from muzzle",
],
"answer": """Spawn the projectile actor from a muzzle component and bind the fire function to input.
```cpp
void AMyPlayerCharacter::Fire()
{
if (!ProjectileClass || !Muzzle)
return;
const FVector SpawnLocation = Muzzle->GetComponentLocation();
const FRotator SpawnRotation = Muzzle->GetComponentRotation();
GetWorld()->SpawnActor<AActor>(
ProjectileClass,
SpawnLocation,
SpawnRotation
);
}
```
Expose `ProjectileClass` as `TSubclassOf<AActor>` and give the projectile its own movement component.""",
},
]
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--out", default="data/instructions/direct_game_commands_hardfix_v2.jsonl")
parser.add_argument("--repeat", type=int, default=520)
parser.add_argument("--seed", type=int, default=6062)
args = parser.parse_args()
rows = []
for item in ROWS:
for _ in range(args.repeat):
for prompt in item["prompts"]:
rows.append(
{
"domain": item["domain"],
"instruction": prompt,
"answer": item["answer"],
"source": "synthetic_direct_command_hardfix",
}
)
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()
|