Skip to content

andrewdmaclean/cyc-tinysnake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Companion repo for “Goodbye World, Hello Battlesnake” (Commit Your Code Conference)

This project shows how to build a tiny tinyhttp Battlesnake server, then add strategy control over WebSockets using Twilio Conversation Relay and a local LLM (Ollama).


What you need

  • Node.js 18+
  • pnpm (preferred): npm i -g pnpm
  • ngrok (to expose localhost:3000)
  • Twilio (Programmable Voice + Conversation Relay)
    – a Twilio account and a voice-enabled phone number
  • Ollama (for local LLM): https://ollama.com/ – run ollama serve and pull the required model:
    ollama pull qwen2.5:1.5b

Create a .env (based on .env.example):

NGROK_URL=https://your-subdomain.ngrok.app

NGROK_URL is used to form public callback / WS URLs for Twilio & Battlesnake.


Install

pnpm install

Run the demos

Each file in demo/ is standalone and builds on the previous one:

# Demo 1: Hello Battlesnake (basic server)
npm run 1

# Demo 2: LLM Move (creative strategy interpretation with qwen2.5:1.5b)
npm run 2

# Demo 3: Voice Control (Twilio voice updates strategy)
npm run 3

# Demo 4: Full Snake (voice + colors + streaming commentary)
npm run 4
# or
npm start

# Development mode (auto-reload)
npm run dev

Servers listen on http://localhost:3000.


Expose with ngrok

ngrok http 3000

Copy the https URL into .env as NGROK_URL.


Project structure

.
├─ demo/
│  ├─ 1-hello.js       - Basic Battlesnake server
│  ├─ 2-llmmove.js     - LLM-powered movement
│  ├─ 3-voicesnake.js  - Voice control via Twilio
│  └─ 4-fullsnake.js   - Full implementation with streaming commentary
├─ package.json
├─ .env
└─ README.md

Features

Demo 4 (Full Snake) includes:

  • Voice-controlled strategy: Say "go towards where the sun sets" and the LLM interprets it
  • Voice-controlled colors: Say "Color blue" to change your snake's color
  • Streaming commentary: AI-generated sports commentary streamed in real-time after each game
  • Educational logging: Clean emoji-based logs showing what's happening

Model Used

  • qwen2.5:1.5b: Handles all tasks - movement strategy, color conversion, and sports commentary generation

About

Companion repo for “Goodbye World, Hello Battlesnake” talk at the 2025 Commit Your Code Conference

Topics

Resources

License

Stars

Watchers

Forks

Contributors