Finish up markov with implementation of !markov status

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-07-17 20:51:01 -07:00
parent 04a4c740bd
commit e375f1604a
3 changed files with 21 additions and 1 deletions

View File

@@ -85,4 +85,12 @@ defmodule Omnibot.Contrib.Markov.Chain do
[next | key] = key ++ [Util.weighted_random(weights)]
[next | do_generate(chain, key)]
end
def chain_sum(chain) do
Enum.reduce(chain.chain, 0, &(weight_sum(&1) + &2))
end
defp weight_sum({_, weights}) do
Enum.reduce(weights, 0, fn {_, weight}, acc -> weight + acc end)
end
end