cond

package
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cond is the When of a branch: who is in what state, every clause saying whom it is about.

When: cond.Other.If(traveller).
	And(cond.Self.If(cond.Not(talking))).
	And(cond.Self.If(cond.Not(talked))),

Clauses

Self, Other, At and On each take one state: an effect the entity is under, a role it plays, a Word of the moment, Chance, Always, or Not of any of them. Clauses join with And and Or; Not of a whole Cond turns it round. At the top of a rule a role of Self or of Other narrows whom the host walks; anywhere else it is asked of the entity as the branch runs.

Words

A moment's or a fact's words are its owner's, made with NewWord: a predicate of the moment or the fact under a name. A word says whether it is of the entity or of the other (Word.OfOther), and a clause of the wrong side is refused as the branch is built.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Self is the entity the branch is about.
	Self = Subject{who{/* contains filtered or unexported fields */}}
	// Other is the other of the pair the moment met, or the subject of the moment or the fact;
	// a clause of it does not hold while there is none.
	Other = Subject{who{/* contains filtered or unexported fields */}}
)

Functions

This section is empty.

Types

type Cond

type Cond interface {
	// And holds where both hold.
	And(c Cond) Cond
	// Or holds where either holds.
	Or(c Cond) Cond
	// contains filtered or unexported methods
}

Cond is a branch's When: clauses of who is in what state, joined with And and Or.

func Not

func Not(what any) Cond

Not is the state what absent, inside If; or, given a Cond, where it does not hold.

type Ever

type Ever struct{}

Ever is the state everybody is in.

var Always Ever

Always is the state everybody is in: Self(Always) holds every tick.

type Likelihood

type Likelihood struct {
	// contains filtered or unexported fields
}

Likelihood is what Chance makes.

func Chance

func Chance(p float64) Likelihood

Chance is the state of being drawn with the likelihood p, drawn afresh every step from the world's seed, the game time and the entity asked, so a load and a replay draw alike.

type Role

type Role interface{ Tag() tag.Tag[Roles] }

Role is a role an entity plays, a ceremony.Part: a state Self, Other or a place is in.

type Roles

type Roles struct{}

Roles is the family of roles: one tag.Tags[Roles] on an entity holds every role it plays.

type Subject

type Subject struct {
	// contains filtered or unexported fields
}

Subject is whom a clause is about: Self, Other, At(places) or On(plugin). If makes the clause.

func At added in v0.3.0

func At(places host.Places) Subject

At is each of the places its moment's host tells (host.Tick.Places), in a rule of a moment with them: the branch runs once a place.

func On

func On(plugin any) Subject

On is a plugin's own entity: anything with an Entity.

func (Subject) If

func (s Subject) If[W any](what W) Cond

If is the subject being in the state what: under an effect, playing a role, as a word of the moment says, Chance, Always, Not any of them, or, in a loop's Until alone, a fact (a value of its type) come to the entity afresh.

type Word

type Word[P any] struct {
	// contains filtered or unexported fields
}

Word is a word of a moment or a fact P: a state Self or Other is in as the moment or the fact says, made with NewWord by whoever gives it.

func NewWord

func NewWord[P any](name string, holds func(P) bool) Word[P]

NewWord is the word named name of the moment P, of the entity the moment is about, holding where holds does.

func (Word[P]) Holds

func (w Word[P]) Holds(p P) bool

Holds reports whether the word holds of p.

func (Word[P]) OfOther

func (w Word[P]) OfOther() Word[P]

OfOther is the word of the other the moment met, in Other alone.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL