Add a blacklist to akinator guesses

This commit is contained in:
Dragon Fire
2020-05-20 09:40:01 -04:00
parent 872289453a
commit e52d8b9090
2 changed files with 11 additions and 4 deletions
+10 -3
View File
@@ -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...`)
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "114.16.7",
"version": "114.16.8",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {