Documentation

Using GaiaBasic

How the library is organised and how to write your own worlds and theories.

Status

Design preview. GaiaBasic is being written. This documentation describes the planned API so that philosophers, scientists and programmers can comment on it before it is fixed. Names and signatures will change. Follow progress on GitHub.

Installation

GaiaBasic will be a pure-Python package (Python 3.10+), with NumPy as its only required dependency. Plotting and notebooks are optional extras.

# once the first release is published
pip install gaiabasic

# until then, from source
git clone https://github.com/manuherran/GaiaBasic
cd GaiaBasic
pip install -e .

Architecture

The package is split into small modules, so each theory is an independent, testable component.

ModuleContents
gaiabasic.worldWorld, the clock, the spatial layout and the random seed.
gaiabasic.elementsMatter, Idea, Experience, Identity and user-defined element types.
gaiabasic.operatorsWill, Motivation, and the transcendence operators copy, move, transform.
gaiabasic.substanceMonism, Dualism, Trialism, Quadrialism, Pluralism.
gaiabasic.sentienceEmergentism, Immersionism, Panpsychism, Functionalism, Eliminativism, Epiphenomenalism…
gaiabasic.identityClosedIndividualism, EmptyIndividualism, OpenIndividualism.
gaiabasic.agentsOrganisms: bodies, nervous systems, behaviour rules, memory, reproduction and mutation.
gaiabasic.speciesReady-made organisms (frog, fly, fish, plant, machine…) for quick experiments.
gaiabasic.theoryTheory, the A–I theory map, family presets, and theory search.
gaiabasic.evaluateCoherence checks, evolutionary viability, valence accounting, comparison tables.
gaiabasic.langParser and runner for .gaia world files.

The World

A World holds everything: the elements, the theory components and the clock. Its four slots (ontology, sentience, identity, physics) can each be replaced independently.

import gaiabasic as gb

world = gb.World("My world", seed=1, size=(100, 100))
world.ontology  = gb.Dualism(gb.Matter, gb.Experience)
world.sentience = gb.Emergentism(threshold=gb.Complexity(min_neurons=1_000), causal=True)
world.identity  = gb.ClosedIndividualism()

world.describe()   # prints the theory in plain English
world.map_code()   # e.g. "A5-B1-C2-D4-E1-F3-G1-H1-I3"

Elements

Every element has a type, a position (in space, in idea-space, or nowhere) and attributes. Experiences carry a valence (from −1, maximum suffering, to +1, maximum pleasure) and an intensity.

pain = gb.Experience(valence=-0.8, intensity=3.0, quality="burn")
two  = gb.Idea("number:2")
me   = gb.Identity("frog-17")

world.add(pain, holder=me)          # who has it depends on the identity model
gb.copy(pain, to=gb.Idea)           # transcendence: copy an experience into idea-space

Theory components

A theory component is a class with a few hooks. The world calls them at each step:

  • arises(entity): does this entity have experiences now? Which ones?
  • holder(experience): which identity has this experience?
  • effect(experience, entity): does the experience change what the entity does? (Epiphenomenal theories return nothing.)
  • cost(experience): does having the experience cost energy?

Common parameters are shared across models, so they can be compared directly: causal, threshold, intensity_scale (for example by neuron count), valence_model (pleasure and pain, only pain, only pleasure) and p_zombies (possible or impossible).

The simulation loop

Each step of world.run() does the following:

  1. Physics. Matter updates by the world's physical rules.
  2. Perception. Organisms sense their environment and their own body.
  3. Experience. The sentience model decides which experiences arise, and the identity model assigns them to subjects.
  4. Decision. Behaviour rules fire, through will and motivation. If experience is causal, it changes the probabilities here.
  5. Evolution. Organisms eat, reproduce, mutate and die. Scarcity selects.
  6. Audit. Coherence checks run. A contradiction is logged, and severe ones end the world.

Writing your own theory

Subclass gb.SentienceModel and implement the hooks you need. This example is a simple "particle" theory: experience appears only in organisms that contain a special component.

class SoulParticle(gb.SentienceModel):
    """Experience requires a special particle bound to three A-units in a row."""

    def arises(self, entity):
        if entity.contains_pattern("AAA") and entity.has(gb.Particle("psi")):
            return [gb.Experience(valence=entity.wellbeing(), intensity=1.0)]
        return []

    def effect(self, experience, entity):
        # dualist interaction: experience shifts motivation
        entity.motivation.bias(toward=experience.valence)

world.sentience = SoulParticle()

The particle is an assumption of the model, not a claim that such a particle exists. That is the point: GaiaBasic lets you write down any assumption and see what follows from it.

The .gaia language

Not everyone who wants to test a theory writes Python. GaiaBasic also includes a small, readable world-description language, in the spirit of BASIC. A .gaia file is translated into the same Python objects.

frog_pond.gaia
WORLD "Frog pond" SEED 42

SUBSTANCE monism OF matter
SENTIENCE emergent WHEN neurons > 10000 CAUSAL no
IDENTITY closed

POPULATE frog 200
POPULATE fly 5000

RUN 50000 STEPS
REPORT coherence, valence_balance, selection("sentience")
gb.run_file("frog_pond.gaia")   # or, from the shell:  gaiabasic run frog_pond.gaia

Reports

world.run() returns a Report. Reports from different worlds can be put side by side.

report.coherence              # 0.0 – 1.0
report.contradictions         # list of rule conflicts found
report.valence_balance        # total pleasure minus total suffering
report.valence_by("species")  # broken down per species, per identity, per time
report.rule_breaks            # behaviour not predicted by the physical rules
report.selection_pressure("sentience")
report.plot()                 # needs the optional [plot] extra

gb.compare([report_a, report_b, report_c]).table()

Games and tournaments

GaiaBasic is also meant to be played. Two formats are planned:

  • World-building game. Players configure a world's initial parameters. Worlds run side by side. The coherent worlds that last longest win; incoherent ones disintegrate.
  • Dialectical tournaments. Players (or AI models) defend characters who believe in monism, dualism, emergentism or epiphenomenalism. Their claims are checked by running the corresponding worlds.

Contributing

Contributions are welcome from programmers and from philosophers. A clearly written theory, with its assumptions listed, is as useful as code. Open an issue or a discussion on GitHub.