--- /dev/null
+MarkovModel {
+ var <numStates, <>states, <>curIndex, <>weights;
+
+ *new {|states, startIndex, weights=nil|
+ ^super.newCopyArgs(states.size, states, startIndex, weights).init;
+ }
+
+ init {
+ if (weights.isNil) {
+ weights = Array2D(numStates, numStates);
+ numStates.do{|i|
+ numStates.do{|j|
+ weights[i, j] = 5.rand;
+ };
+ };
+ };
+ }
+
+ next {
+ var prevIndex = curIndex;
+ curIndex = weights.rowAt(prevIndex).normalizeSum.windex;
+ ^states[prevIndex];
+ }
+}
\ No newline at end of file