Yuka: Game AI for JavaScript Developers Who Like Clean Code
You're building a game in JavaScript or TypeScript. The rendering is smooth. The physics work. But the enemies? They just stand there. Or they walk into walls. Or they chase the player in a straight line like it's 1982.
That's where Yuka comes in.
It's not a game engine. It's not a physics library. Yuka is a focused, well structured toolkit for game AI. State machines, pathfinding, perception, steering behaviors. All the pieces you need to make NPCs that act like they have a brain.
What It Does
Yuka gives you the building blocks for common AI patterns in games:
- Finite State Machines (FSM) – clean transitions between idle, patrol, chase, attack.
- Goal Driven AI – like FSM but with priorities and subgoals.
- Pathfinding – A* and Dijkstra on custom navigation graphs or meshes.
- Steering Behaviors – seek, flee, pursue, evade, wander, flocking, and more.
- Perception – vision and hearing systems for AI awareness.
- Navigation Mesh – load and parse navmeshes for smarter movement.
All of it is written in modern JavaScript (ES modules) with TypeScript definitions included. No dependencies. No runtime bloat.
Why It’s Cool
Most game AI libraries either tie you to a specific engine (Unity, Unreal) or they’re academic prototypes that don't work in production. Yuka sits in a sweet spot.
It’s standalone. You can drop it into a Three.js project, a canvas 2D game, or even a Node.js server for AI simulation. It doesn't care about your renderer.
It’s modular. You don't import one giant AI class. You pick the pieces you need. Need only pathfinding? Grab the AStar class and a graph. Need the full suite? Import what you want.
It’s tested. The repo has solid unit tests and examples that actually run. No "works on my machine" surprises.
The documentation is actually good. Each feature has a dedicated page with code snippets and explanations. That’s rare in open source game dev tools.
How to Try It
Install via npm:
npm install yuka
Then in your project:
import { Vehicle, Vector3, SeekBehavior } from 'yuka';