From e52d8b9090103d9a322fc84d0470ebfe66e053bd Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Wed, 20 May 2020 09:40:01 -0400 Subject: [PATCH] Add a blacklist to akinator guesses --- commands/games-sp/akinator.js | 13 ++++++++++--- package.json | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/commands/games-sp/akinator.js b/commands/games-sp/akinator.js index 653df343..0e400630 100644 --- a/commands/games-sp/akinator.js +++ b/commands/games-sp/akinator.js @@ -45,6 +45,7 @@ module.exports = class AkinatorCommand extends Command { let timesGuessed = 0; let guessResetNum = 0; let forceGuess = false; + const guessBlacklist = []; this.client.games.set(msg.channel.id, { name: this.name }); while (timesGuessed < 3) { if (guessResetNum > 0) guessResetNum--; @@ -57,7 +58,7 @@ module.exports = class AkinatorCommand extends Command { await aki.step(ans); } } - if (!aki.answers || aki.currentStep >= 77) forceGuess = true; + if (!aki.answers || aki.currentStep >= 78) forceGuess = true; const answers = aki.answers.map(answer => answer.toLowerCase()); answers.push('end'); await msg.say(stripIndents` @@ -78,9 +79,15 @@ module.exports = class AkinatorCommand extends Command { else ans = answers.indexOf(msgs.first().content.toLowerCase()); if ((aki.progress >= 90 && !guessResetNum) || forceGuess) { timesGuessed++; - guessResetNum += 5; + guessResetNum += 10; await aki.win(); - const guess = aki.answers.sort((a, b) => b.proba - a.proba)[0]; + const guess = aki.answers.filter(guess => !guessBlacklist.includes(guess.id))[0]; + if (!guess) { + await msg.say('I can\'t think of anyone.'); + win = true; + break; + } + guessBlacklist.push(guess.id); const embed = new MessageEmbed() .setColor(0xF78B26) .setTitle(`I'm ${Math.round(guess.proba * 100)}% sure it's...`) diff --git a/package.json b/package.json index 300f9d88..91fd67ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "114.16.7", + "version": "114.16.8", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {