Markov Chain Module

What does it do?

It creates messages from messages it ‘learns’ using a Markov Chain
See: Markov chain - Wikipedia
Markov Chains are used by everyday electronics like Phones,
you know how phones can predict what you are about to write, that uses Markov Chains

Markov Chains create sentences using the connections between words.
A Markov Chain can be used in all kinds of things such as filling a book with random text from a dataset, automatically generating multi word names and much more!

Sample Usage

local Markov = require(path.to.module)
local MarkovObject = Markov:New()
MarkovObject:Learn("text you want to teach to the module goes here")
MarkovObject:Learn("even more text goes here wow")
local TextOutput = MarkovObject:Generate()

The module might not always generate sensible text and might create inappropriate text combinations so remember to filter all generated text

Documentation

Markov:New()
-- Creates new Markov Object Instance

MarkovObject:Generate(MinLength, MaxLength, Seed)
-- Min and Max Length represent the minimum and maximum output length in words respectively
-- Seed is used to choose the first word from which to use to generate
-- All parameters in Generate are optional 

MarkovObject:Learn(String) 
-- Teaches the Markov chain how the words interact

Changelog

October 30th 2020

  • Fixed issue where the Markov Chain would attempt to generate as long of a sentence as possible and never stopping where it should

Script File:
Markov.lua (2.4 KB)

Roblox Link:
https://www.roblox.com/library/2845226312/The-Chain-Implementation

Sample Place:
https://www.roblox.com/games/2844976671/mrkv-chain-implementation

Github:

25 Likes

I really appreciate what you are doing for the community, but generally I would like to know more. I think it would be better if you put an explanation of what something is, instead of its actual name, unless it’s very popular so people wouldn’t be in doubt (I personally did not know what this was until I clicked your link and googled).

Also, are there any use cases for this? It sure seems cool, but currently I have no idea what it could be used for, maybe you could list a few examples?

Additionally put more content in your post instead of linking to an external page, so we don’t have to go any other links. You can of course link to the page, but type with your own words or at least paste some info about this, what it does.
You could say
What does this do? This module accepts various string inputs and then when calling :Generate() it will create a random phrase based on the inputs it has been given. This could be useful for X, and also Y where you do Z”.

6 Likes