# `gno.land/p/moul/x/daily/markov/v0` **Deterministic Markov-chain text generator** โ€” a port of Go's canonical example [*"Generating arbitrary text: a Markov chain algorithm"*](https://go.dev/doc/codewalk/markov/) with `math/rand` replaced by a caller-supplied seed. A `Chain` maps every two-word *prefix* to the list of words observed to follow it (duplicates kept, so frequency biases the walk), storing that map in a persistent `avl.Tree`. `Build` folds text into the chain; `Generate` walks it from the start prefix, picking one suffix per step from a small LCG seeded by the `uint64` you pass โ€” so generation is pure and replayable, and the caller decides where entropy comes from (on-chain, the block height). No chain imports, no ambient state. ```go import "gno.land/p/moul/x/daily/markov/v0" c := markov.New() c.Build("it was the best of times it was the worst of times") // fold in a corpus words := c.Generate(40, seed) // walk it, seeded c.Stats() // (totalWords, prefixCount) c.Iterate(func(prefix string, suffixes []string) bool { ... }) // inspect the map ``` **Live demo:** [`r/moul/x/daily/markovdemo`](https://github.com/moul/gno-contracts/tree/main/r/moul/x/daily/markovdemo/v0) ยท render it at [`/r/moul/x/daily/markovdemo/v0`](https://gno.land/r/moul/x/daily/markovdemo/v0). --- Part of **[moul/gno-contracts](https://github.com/moul/gno-contracts)** โ€” moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage. **Dependency graph:** ![gno.land/p/moul/x/daily/markov/v0 dependency graph](https://raw.githubusercontent.com/moul/gno-contracts/main/_assets/gno.land/p/moul/x/daily/markov/v0/deps.png) > ๐Ÿงช **Highly experimental โ€” potentially vibe-coded.** Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: [DISCLAIMER](https://github.com/moul/gno-contracts/blob/main/DISCLAIMER.md).