Port https://github.com/mxgmn/MarkovJunior to Unity, I've only tested it in 2021 LTS, but it should work for all version.
The documentation is done by https://github.com/kaya3/MarkovJunior-docs
It's a pretty rough port, feel free to further optimize it.