Skip to main content

Lightweight educational simulation library for AI-generated visual lessons

Project description

ember

ember is a small educational simulation library.

The main goal is simple: an AI or teacher should be able to make a clear visual simulation without writing hundreds of lines. The code should focus on the idea, not on drawing everything manually.

It is useful for:

  • explaining science and maths concepts
  • making small interactive lessons
  • generating GIF/PNG style visual explanations
  • testing how LLMs can create better teaching simulations

This is not a game engine in the big sense and it is not a console emulator. It is a lightweight sandbox for educational visuals.

What Is Inside

  • A C11 core library in src/ and include/
  • Python bindings in python/ember/
  • A high-level education API in python/ember/edu.py
  • Example simulations in examples/ and games/
  • Plain text mission files in missions/
  • Documentation in docs/

The most important API for AI-generated lessons is ember.edu.

Example Gallery

These previews are regenerated into docs/gallery/ so changes in the visual library are visible in the README. The small examples show the target style: AI writes one clear mechanism in roughly 40-50 lines instead of making a large custom app.

Regenerate the gallery after visual/library changes:

make gallery
Concept Source Render
Fajan's rule examples/fajan_sim_test.py - 47 lines Fajan rule preview
Faraday's law examples/faraday_sim_test.py - 62 lines Faraday law preview
Hybridisation examples/hybridisation_sim.py - 64 lines sp3 hybridisation preview
Heart function games/heart_sim.py - richer demo Heart function animation
Transformer attention games/transformer_sim.py - richer demo Transformer attention animation

Run Examples

From the repo root:

PYTHONPATH=python python3 examples/hybridisation_sim.py
PYTHONPATH=python python3 games/heart_sim.py
PYTHONPATH=python python3 games/transformer_sim.py

Many examples also add the local python/ path themselves, so they can be run directly with python3.

Build And Test

make all
make test
make python-test

Run the default C mission:

make run

This writes frames into build/.

For AI Agents

Before generating a simulation, read the prompt contract:

import ember
print(ember.prompt)

The same guide is available here:

docs/AI_SIMULATION_GUIDE.md

Important rules for AI-generated simulations:

  • Ask what exact mechanism the user wants to understand.
  • Websearch for factual topics unless the user provides source material.
  • Show one clear cause and effect.
  • Prefer concrete scenes over abstract variable animation.
  • Keep the code small.
  • Use only existing public APIs.
  • Do not edit the library unless the user asks for library work.

For most visual lessons, use Lesson plus Sketch:

from ember.edu import Lesson, Sketch

def draw(canvas, state):
    canvas.text("main idea", 0, -0.8)

lesson = Lesson("My Lesson", theme="neon")
lesson.show_hud = False
lesson.state.params["_time"] = 0.0
lesson.rate("_time", lambda s: 1.0)
lesson.show(Sketch(draw, "one-line visual legend"))
lesson.explain("One sentence takeaway.")
lesson.run()

Useful Docs

Project Layout

include/          C public headers
src/              C implementation
python/ember/     Python package
examples/         small concept examples
games/            richer interactive lessons
missions/         text mission files
docs/             documentation
tests/            C and Python tests

Notes

The project is still evolving. The important direction is to make the library more general and easier for smaller models also. If a generated sim needs too much drawing code, that is a sign the library needs a better primitive.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ember_edu-0.2.0.tar.gz (58.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ember_edu-0.2.0-py3-none-any.whl (55.1 kB view details)

Uploaded Python 3

File details

Details for the file ember_edu-0.2.0.tar.gz.

File metadata

  • Download URL: ember_edu-0.2.0.tar.gz
  • Upload date:
  • Size: 58.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for ember_edu-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e1e69bfcdc6eafce4b458913b97790a5708217f6236c9bcdd9ceb0c5707dd4aa
MD5 e087683a550dc0aab1582d21159b8533
BLAKE2b-256 a7f4973a720df295e0a5c0cbcf7fcca850af327dabbec946cfbd1f53ecef7747

See more details on using hashes here.

File details

Details for the file ember_edu-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ember_edu-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 55.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for ember_edu-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cf1acaf05fc38a32819dfe0d18f57c196a5493505f08a1462c35ef9e5344bd2b
MD5 d47de65faa0180318f1ab901a7321cc6
BLAKE2b-256 e1fa8766a2e4373f0117a7924d68701607e800e72f1860906250447e1ff34a1e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page