# KonsolScript AI Event Bridge Demo

Two programs. Zero AI code in the game.


What this demo shows

demogame_host is a C++ game stub that embeds libminks. It exposes a DemoGame: module - wave info, weather, spawning. It knows nothing about AI.

game_master.ks is a KonsolScript script you run from the command line. You give it a prompt. It calls the Claude API, gets back a KonsolScript event script, and ships it over the LAN to demogame_host, which runs it via engine.eval().

The game reacted to AI-authored code. The AI never touched the game binary.


Prerequisites


Build the host

cd minks/demo_ai_bridge
make

Produces demogame_host (Linux/macOS) or demogame_host.exe (Windows).

If your library name differs (e.g. libkonsolscript.a), edit the LDLIBS line in the Makefile.


Run

Terminal A - start the game host:

cd minks/demo_ai_bridge
./demogame_host

Output:

=== KonsolScript AI Event Bridge ===
Game state: wave=7  health=68%  night=yes
Listening on port 2310... (run game_master.ks in another terminal)

Terminal B - send an AI event:

cd minks/demo_ai_bridge
minks game_master.ks "blizzard event for wave 10"

Terminal A reacts:

--- event from gamemaster ---
[ANNOUNCE] Blizzard incoming! Prepare your defenses.
[WEATHER]  blizzard
[SPAWN]    ice_golem x 4
[MODIFIER] speed = 0.6
--- done (total spawned: 4) ---

Try other prompts:

minks game_master.ks "health bonus because the player survived wave 7"
minks game_master.ks "night is over, switch to day and give a reward"
minks game_master.ks "boss wave: spawn 1 dragon and 10 skeletons"

DemoGame API (what Claude can use)

Call Effect
DemoGame:GetWave(out) Current wave number → Number
DemoGame:GetHealth(out) Player health 0–100 → Number
DemoGame:IsNight(out) Night flag → Boolean
DemoGame:Announce(msg) Print a game announcement
DemoGame:SpawnWave(type, count) Spawn enemies
DemoGame:SetWeather(weather) Change weather
DemoGame:GiveBonus(type) Award a bonus
DemoGame:SetModifier(key, val) Set a named game modifier

How it works

You (prompt)
    │
    ▼
game_master.ks  ──Curl:Post──►  Claude API
                ◄──────────────  KonsolScript event script

game_master.ks  ──Net:Send──►  demogame_host
                               └─ engine.eval(script)
                                  └─ DemoGame:SpawnWave(...)
                                     DemoGame:SetWeather(...)
                                     ...

The newline encoding step (\n{{NL}}) exists because the Net plugin uses \n as its wire-protocol message terminator.


Extending this pattern

game_master.ks can Net:Join each one in turn to coordinate them.