From 2f110607f7108451e3fc2c1c9f7df58217bc1cb4 Mon Sep 17 00:00:00 2001 From: Arjun Satarkar Date: Wed, 6 Mar 2024 16:31:59 -0500 Subject: markov: small logic improvement in unlikely case --- markov/markov.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'markov') diff --git a/markov/markov.py b/markov/markov.py index a61a3ce..2a37a6c 100644 --- a/markov/markov.py +++ b/markov/markov.py @@ -365,6 +365,7 @@ class Markov(commands.Cog): ) completion_count = row[0] + next_token = None for i in range(MAX_TOKEN_GENERATION_ITERATIONS): row = await ( await db.execute( @@ -405,7 +406,10 @@ class Markov(commands.Cog): " all of them. This should never happen!" ) else: - token = "" + # If we went through MAX_TOKEN_GENERATION_ITERATIONS completions + # without selecting any, then just select the last one we considered + # (round off the probability, effectively). + token = next_token if token == "": break -- cgit v1.2.3-57-g22cb