aboutsummaryrefslogtreecommitdiff
path: root/markov
diff options
context:
space:
mode:
authorArjun Satarkar <me@arjunsatarkar.net>2024-03-06 21:31:59 +0000
committerArjun Satarkar <me@arjunsatarkar.net>2024-03-06 21:31:59 +0000
commit2f110607f7108451e3fc2c1c9f7df58217bc1cb4 (patch)
tree4b8afd4367d75b49c459c048137eac894e208e67 /markov
parent54a8d59a146d56148c65e248350c3bd6ecde526c (diff)
downloadaps-cogs-2f110607f7108451e3fc2c1c9f7df58217bc1cb4.tar
aps-cogs-2f110607f7108451e3fc2c1c9f7df58217bc1cb4.tar.gz
aps-cogs-2f110607f7108451e3fc2c1c9f7df58217bc1cb4.zip
markov: small logic improvement in unlikely case
Diffstat (limited to 'markov')
-rw-r--r--markov/markov.py6
1 files changed, 5 insertions, 1 deletions
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