Laserbrain API

Reference and code examples for building with the weather field.

Installation

pip install laserbrain

Core API

Laserbrain()

Create a new weather field.

from laserbrain import Laserbrain lb = Laserbrain() # 36×80 field # Fields: T (temp), Q (humidity), P (pressure), # R (rain), V (vitality) # Terrain: permanent memory of rain carving

step()

Advance the weather simulation one tick.

lb.step() # runs one weather iteration # Updates: pressure noise, wind, advection, # diffusion, saturation, rain, vitality, # terrain carving, ghost field decay

absorb(word: str)

Feed a word into the field (heats it).

lb.absorb('fire') # heats a region lb.absorb('rain') # adds moisture # Words map to quadrants and G-elements (binary classification)

generate(n: int) → List[str]

Generate words from the language layer.

words = lb.generate(n=12) # temperature driven by humidity # Hot, humid field → creative, wild # Cold, dry field → sparse, literal

hear(text: str) → str

Full conversational loop: absorb input, generate reply.

reply = lb.hear('what is fire?') # Absorbs all words from input, # generates reply based on field state

Use Case: Weather-regulated System

Feed sensor data, read a control signal 0–1.

import laserbrain import threading import time lb = laserbrain.Laserbrain() def step_loop(): while True: lb.step() time.sleep(0.05) threading.Thread(target=step_loop, daemon=True).start() def control_signal(): """Returns 0–1 based on field state.""" t = float(lb.T.mean()) # avg temperature q = float(lb.Q.mean()) # avg humidity r = float(lb.R.mean()) # avg rain # Hot and clear → high. Cold and rainy → low. return max(0.0, min(1.0, t * (1 - r) + 0.1 * (1 - q))) def feed_sensor(activity, pressure): """Inject sensor readings into the field.""" cy, cx = lb.H // 2, lb.W // 2 import numpy as np # Heat up the center region lb.T[cy-3:cy+3, cx-6:cx+6] = np.clip( lb.T[cy-3:cy+3, cx-6:cx+6] + activity * 0.06, 0, 1) # Add moisture lb.Q[cy-3:cy+3, cx-6:cx+6] = np.clip( lb.Q[cy-3:cy+3, cx-6:cx+6] + pressure * 0.02, 0, 1) # Main loop while True: activity = 0.5 # from sensor pressure = 0.3 # from sensor feed_sensor(activity, pressure) signal = control_signal() # Use signal to control LED, fan, color, etc. print(f"Signal: {signal:.2f}") time.sleep(0.2)

Use Case: Language Field

Feed text, read temperature-modulated output.

lb = laserbrain.Laserbrain() lb.seed() # initialize the holographic memory # Single words lb.absorb('morning') lb.absorb('rain') output = lb.generate(n=8) print(' '.join(output)) # Conversation while True: user = input('> ') reply = lb.hear(user) print(f'lb: {reply}') # Field state (humidity, temperature) modulates generation

Fields Reference

T (temperature) — 0–1. Drives intensity and speed. High T → fast generation, strong convection.

Q (humidity) — 0–1. Drives creativity. High Q → wild language, condensation. Low Q → dry, literal.

P (pressure) — unbounded. Drives wind (advection). High P compresses and heats.

R (rain) — 0–1. Precipitation. Forms when Q > saturation. Carves terrain permanently.

V (vitality) — 0–1. Accumulates when T > 0.4. Measures aliveness.

terrain — Permanent. Rain carves basins. Shapes future moisture flow. Persists across steps.

Learn more

Guide — full explanation of how it works

GitHub — source code, full implementation

Teach — book a live session to build something