diff --git a/server/djrandom/model/markov.py b/server/djrandom/model/markov.py index bc956019a73ffac536688ced1e0a8ee4571d26cf..7bdd15482078d09a2e7228fdb0361e4c4f85b7bd 100644 --- a/server/djrandom/model/markov.py +++ b/server/djrandom/model/markov.py @@ -54,9 +54,13 @@ class MarkovModel(object): norm_vec = [] tot = sum(target_map.itervalues()) cur = 0 - for k, v in target_map.iteritems(): - cur += float(v) / tot - norm_vec.append((cur, k)) + for target, count in target_map.iteritems(): + # We explicitly drop this target to avoid repeating + # the same song more than once. + if target == key[-1]: + continue + cur += float(count) / tot + norm_vec.append((cur, target)) norm_map[key] = norm_vec self._map = norm_map