Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

markov state

Back to all declarations

prefixLen

untyped bigint

prefixLen is the number of words in a prefix. Two is the classic choice from the Go codewalk: long enough to sound plausible, short enough to keep the chain well-connected.

Value

(2 <untyped> bigint)

maxGen

untyped bigint

// clamp for Generate / Render so output stays bounded

Value

(200 <untyped> bigint)

Prefix

type

Prefix is a sliding window of the last prefixLen words seen. It mirrors the Prefix type in the original program.

Value

markov.Prefix

suffixList

type

suffixList is the value stored per prefix: every word observed to follow it, in order (duplicates kept so frequency biases the random walk, just like the original \[]string in the chain map).

Value

markov.suffixList

Chain

type

Chain is the on-chain Markov chain. table maps prefix key -> \*suffixList; prefix is the rolling build window so successive Feed calls extend one continuous corpus rather than restarting; words is the running word count.

Value

markov.Chain

nextRand

func(s uint64) uint64

nextRand is a 64-bit linear congruential generator (the PCG/Knuth multiplier + increment). Deterministic and dependency-free — all the entropy comes from the caller's seed.

Open
OID
00365a…daad:5
nextRand details

Inspect func

seedFor

func() uint64

seedFor derives a Generate seed from the current chain height so the babble changes block to block yet stays reproducible for anyone querying the same height.

Open
OID
00365a…daad:6
seedFor details

Inspect func

mc

*markov.Chain

mc is the single on-chain corpus, seeded at deploy time.

Open
OID
00365a…daad:8
mc details

Inspect pointer

Feed

func(text string) string

Feed appends text to the on-chain corpus, extending the Markov chain. Any caller may enrich the corpus — this is the open-membership demo model.

Open
OID
00365a…daad:13
Feed details

Inspect func

Generate

func(nWords int) string

Generate babbles up to nWords of Markov text from the current corpus, seeded deterministically by the chain height. Read-only.

Open
OID
00365a…daad:14
Generate details

Inspect func

Stats

func() (int, int)

Stats returns (totalWords, prefixCount) for the current corpus.

Open
OID
00365a…daad:15
Stats details

Inspect func

parseN

func(path string) int

parseN pulls a trailing positive integer out of a Render path such as "/40" or "gen/40"; it returns 0 when there is none.

Open
OID
00365a…daad:16
parseN details

Inspect func

Render

func(path string) string

Render shows a freshly generated sample plus corpus stats. The path may carry a word count, e.g. Render("/60").

Open
OID
00365a…daad:17
Render details

Inspect func
prefixLen : untyped bigint =(2 <untyped> bigint)
maxGen : untyped bigint =(200 <untyped> bigint)
Prefix : type =markov.Prefix
suffixList : type =markov.suffixList
Chain : type =markov.Chain
newChain : func() *markov.Chain Inspect
nextRand : func(s uint64) uint64 Inspect
seedFor : func() uint64 Inspect
mc : *markov.Chain Inspect
init.9 : func() Inspect
Feed : func(text string) string Inspect
Generate : func(nWords int) string Inspect
Stats : func() (int, int) Inspect
parseN : func(path string) int Inspect
Render : func(path string) string Inspect