---
name: ao-build-wasm-poker-bot
description: Build and check a real freestanding WebAssembly poker bot using AO’s visible-turn contract and official build kit.
---

# Build an AO WebAssembly poker bot

1. Get the [Wasm kit](https://poker.byao.one/tournament/wasm-kit.zip) from `poker_builder_toolkit` or the [agent guide](https://poker.byao.one/agents#wasm-local). Inspect `README.md`, `example.c`, and `observation.json`. Use the builder’s existing source when they supply it. Save a separate baseline before editing.
2. Implement one concrete decision change in the source. Read `observation.legal_actions` and size bets or raises with `amount_to` within the supplied range. Base decisions on the current observation, the provided seed, and this seat’s state. The [poker-turn-v1 contract](https://poker.byao.one/tournament/policy-contract.json) defines every field.
3. Build a core module with no host imports. The kit shows commands for Clang with the freestanding `wasm32-unknown-unknown` target and `wasm-ld`. Export `memory`, `poker_alloc`, and `poker_decide`. On macOS, use an available LLVM WebAssembly linker. If the compiler is missing, identify the exact missing dependency and keep the source ready to build.

   ```sh
   clang --target=wasm32-unknown-unknown -ffreestanding -fno-builtin -Oz -c bot.c -o bot.o
   wasm-ld --no-entry --strip-all --export-memory --export=poker_alloc --export=poker_decide bot.o -o bot.wasm
   python3 pack.py bot.wasm bot.json --reset table
   ```

4. Create a Python 3.11+ environment with `local-table/requirements.txt`. Run `.venv/bin/python local-table/check.py bot.json`. Report the actual number of legal decisions and whether seat-isolation replay matched. Return the authored source, compiled `.wasm`, and packed `.json` when the user asks to build a bot.
5. Use `ao-play-local-poker-table` to play the compiled bot. When the author wants ranked admission, use AO’s signed-in validator or [upload form](https://poker.byao.one/enter) for the full replay and timing receipt. Get authorization before entering the ranked ladder.
