prefixLen
untyped bigintprefixLen 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
typePrefix is a sliding window of the last prefixLen words seen. It mirrors the Prefix type in the original program.
Value
markov.Prefix
suffixList
typesuffixList 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
typeChain 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
newChain
func() *markov.Chain- OID
- 00365a…daad:3
newChain details
nextRand
func(s uint64) uint64nextRand 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.
- OID
- 00365a…daad:5
nextRand details
seedFor
func() uint64seedFor 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.
- OID
- 00365a…daad:6
seedFor details
mc
*markov.Chainmc is the single on-chain corpus, seeded at deploy time.
- OID
- 00365a…daad:8
mc details
init.9
func()- OID
- 00365a…daad:12
init.9 details
Feed
func(text string) stringFeed appends text to the on-chain corpus, extending the Markov chain. Any caller may enrich the corpus — this is the open-membership demo model.
- OID
- 00365a…daad:13
Feed details
Generate
func(nWords int) stringGenerate babbles up to nWords of Markov text from the current corpus, seeded deterministically by the chain height. Read-only.
- OID
- 00365a…daad:14
Generate details
Stats
func() (int, int)Stats returns (totalWords, prefixCount) for the current corpus.
- OID
- 00365a…daad:15
Stats details
parseN
func(path string) intparseN pulls a trailing positive integer out of a Render path such as "/40" or "gen/40"; it returns 0 when there is none.
- OID
- 00365a…daad:16
parseN details
Render
func(path string) stringRender shows a freshly generated sample plus corpus stats. The path may carry a word count, e.g. Render("/60").
- OID
- 00365a…daad:17