petri-net tutorial go-pflow codegen

Introducing Petri-Pilot

Petri-Pilot is an interactive learning platform for Petri nets. Rather than reading theory, you learn by playing games, modeling workflows, and seeing how ODE simulation reveals strategic insights. Each tutorial builds on the previous one, from basic concepts to complex multi-player state machines.

The platform explores a central question: What if the model was the app?

The Learning Path

Petri-Pilot organizes tutorials in a progressive sequence. Each one introduces new Petri net concepts through hands-on examples:

Learning Path

Tutorial Concepts Difficulty
Tic-Tac-Toe Places, transitions, arcs, ODE basics Beginner
Coffee Shop Capacity limits, weighted arcs, rates Intermediate
Texas Hold'em Roles, guards, event sourcing Advanced
Build Your Own Visual editor, JSON export Create

Start with Tic-Tac-Toe to understand the fundamentals. By the time you reach Texas Hold'em, you'll be modeling complex concurrent systems.

Core Concepts

Every tutorial uses the same building blocks. Understanding these six concepts unlocks all Petri net modeling:

Core Concepts

The first three define structure (what's possible). Tokens define state (what's current). ODE provides prediction (what will happen). Events provide history (what did happen).

Model-Driven Development

Petri-Pilot uses deterministic code generation. You define a model in JSON, and templates produce a complete application:

Model to App

The generated stack includes:

This isn't LLM-generated code that needs debugging. Templates produce consistent, predictable output. To change behavior, you change the model and regenerate.

Why Interactive Learning?

Petri nets are visual and dynamic. Reading about tokens moving through places doesn't build intuition the way playing does. When you make a move in Tic-Tac-Toe and see:

  1. The token leave one place
  2. The transition fire
  3. A new token appear in another place
  4. The ODE values update

...the concepts click in a way that diagrams alone can't achieve.

The ODE visualization is particularly powerful. Watching strategic value flow through the game tree—seeing why the center square matters more than corners—makes abstract theory concrete.

The Tutorials

Tic-Tac-Toe: The Foundation

The simplest complete model. Nine cells, two players, win detection. But even this "simple" game demonstrates:

See Tic-Tac-Toe Model for detailed analysis.

Coffee Shop: Resource Modeling

Moves beyond games to workflow modeling. A coffee shop with limited inventory teaches:

The ODE predicts when you'll run out of coffee beans. No scheduling logic—the dynamics emerge from structure.

See Coffee Shop Model for detailed analysis.

Texas Hold'em: Complex State

Multi-player poker with all the complexity that entails:

This demonstrates that Petri nets scale to production-grade state machines.

See Texas Hold'em Model for detailed analysis.

Build Your Own

The visual editor at pilot.pflow.xyz/pflow lets you create custom models. You can:

The Philosophy

Traditional development starts with code. Petri-Pilot inverts this: start with a model, generate the code. The model becomes the source of truth.

This matters because:

The experiment asks: can we make the model so good that the application becomes a commodity output? Petri-Pilot suggests the answer is yes.

Getting Started

  1. Visit pilot.pflow.xyz
  2. Start with Tic-Tac-Toe
  3. Play through the tutorials
  4. Build your own models

For the underlying library: go-pflow on GitHub

For theory behind ODE analysis: Declarative Differential Models

×

Follow on Mastodon