madewithlaya

Catalog / Tools & apps

0062GitHub

Laya Unity: a Unity-native SDK for System One decisions in games

Backend-independent Unity client for local Laya servers and TypeSafe-compatible endpoints. Game state in, Choice/Score/Noul out; transport-first, no embedded weights.

0x440-1me/laya-unityREADME ↗
# Laya Unity

Laya Unity is a community Unity SDK for System One decision models.

```text
game state
   ↓
Choice / Score / Noul
   ↓
Laya / compatible backend
   ↓
structured decision
```

It provides a Unity-native, backend-independent client for local Laya-compatible servers and TypeSafe-compatible System One endpoints. Version 0.1 is deliberately transport-first: it does not embed ONNX, a tokenizer, Python, or model weights.

> [!IMPORTANT]
> This project is an early community SDK, not production-ready software and not affiliated with Laya or TypeSafe.

## Install

In Unity 2022.3 LTS or newer, open **Window → Package Manager**, choose **Add package from git URL**, and enter:

```text
https://github.com/0x440-1me/laya-unity.git
```

The package depends on Unity's maintained `com.unity.nuget.newtonsoft-json` package, currently pinned to `3.2.2`.

## Quick start: local Laya

```csharp
using System.Threading;
using Laya.Unity;
using Laya.Unity.Questions;
using UnityEngine;

var client = LayaClient.CreateLocal("http://127.0.0.1:8000");

var result = await client.SystemOneAsync(
    state: new
    {
        health = 25,
        enemyDistance = 4.2f,
        ammo = 2
    },
    questions: QuestionSet.Create(
        ("action", Choice.Create(
            "What should the NPC do?",
            ("attack", "Engage the enemy"),
            ("retreat", "Move toward safety"),
            ("wait", "Hold position"))),
        ("danger", Score.Create(
            "How dangerous is the situation?",
            "safe", "moderate danger", "extreme danger")),
        ("flee", Noul.Create("Should the NPC flee?"))),
    cancellationToken: CancellationToken.None);

var action = result.GetChoice("action");
Debug.Log($"{action.Choice} ({action.Confidence:P0})");
```

The default local endpo

Also filed under Tools & apps

  1. 0005

    laya-mlx plays Snake at 60 decisions per second

    介绍比Jev快50倍,在你设备上跑的laya-mlx! 只在你的设备上占用最高1G内存 Laya是一个开源的类似于Jev的,基于文本输出概率的分类系统 我将其移植到MLX,并且做了一些性能优化! 视频中就是这个模型在我的本地M3Max上玩贪吃蛇 这个模型能够以每秒决策60次的速度玩贪吃蛇! https://t.co/31KGUiNunb

    @mizorewww · Tools & apps · free, local · 60 decisions/s

  2. 0112

    Laya on Axera AX650 and AX8850 edge NPUs, under 70 ms

    AXERA-TECH's conversion of all three Laya checkpoints for its edge AI chips, reported at latency under 70 ms per decision on AX650/AX8850.

    AXERA-TECH · Tools & apps · free, on-device · < 70 ms on AX650 / AX8850

  3. 0099

    laya-mcp (PerryLink): a warm sidecar that fixes Laya's silent truncation and constant noul

    MCP server plus HTTP sidecar: token-budget preflight that reports what would be cut, a persisted calibration store, structured errors, and a noul fix (P(true) 0.5 → 1.0).

    @PerryLink · Tools & apps · free, local

  4. 0097

    Gomoku against Laya-MLX: you play black, the model picks white's move from six candidates

    Local 15x15 Gomoku on Apple Silicon. Rules in Python, board in the browser, every AI move one real Laya choice over up to six candidates, probabilities shown. No Gomoku training.

    smile-magic · Tools & apps · free, local