diff --git a/modules/Markov.py b/modules/Markov.py index 5c413d3..c7376c4 100644 --- a/modules/Markov.py +++ b/modules/Markov.py @@ -383,10 +383,16 @@ class Markov(Module): self.log.debug("working_backwards: {0:s}".format(" ".join(working_backwards))) # now work backwards until we randomly bump into a start + # to steer the chainer away from spending too much time on + # the weaker-context reverse chaining, we make max_size + # a non-linear distribution, making it more likely that + # some time is spent on better forward chains + max_back = random.randint(1, max_size/2) + random.randint(1, max_size/2) + self.log.debug("max_back: {0:d}".format(max_back)) while True: key_hits = self._retrieve_k2_for_value(working_backwards[0], context_id) - if self.start2 in key_hits and len(working_backwards) > 2: - self.log.debug("working backwards forced start, finishing") + if self.start2 in key_hits and len(working_backwards) > max_back: + self.log.debug("max_back exceeded, cleanly finishing") gen_words += working_backwards self.log.debug("gen_words: {0:s}".format(" ".join(gen_words))) break