discord-tictactoe
discord-tictactoe copied to clipboard
Option to choose how hard the game is
is it possible to win vs the ki and how? can anyone explain me?
Hello @mnzasa-files, In theory, the AI of the module is unbeatable, because I am using the Minmax algorithm under the hood. Check more on how this works here: https://www.neverstopbuilding.com/blog/minimax
I was thinking of adding levels of difficulty in the module (like an error rate). What do you think of that?
Yes, It would nice when you can choose how Hard the game is.
Hey! Apologies for reviving and old thread, however I'm interested in attempting to add in a failure rate, to customise difficulty. Where abouts would i need to add this? (what file, line, etc)
Hello @BamBoozledMC, thank you for looking into this addition! But indeed it's not the simplest one..
AI algorithm is located in the AI.ts file inside the method called minimax
, check the code here:
https://github.com/utarwyn/discord-tictactoe/blob/6d40d2d02de24b60968c61d134812e59e4a14732/src/tictactoe/AI.ts#L49-L88
I already tried to work on this (look into this commit: 93c00bd), but the algorithm is not easy so I'm really interested if you have an idea to add a notion of difficulty level in the Minimax algorithm.
is this even possible to beat? i mean i have been trying for hours and i cant beat the bot.
is this even possible to beat? i mean i have been trying for hours and i cant beat the bot.
I'm pretty much certain its not, I've tried for a while. I don't see much point in there being an ai that you can't beat - in a game where you're meant to try to win - other than for practice. I've found that raising the value of depth that's taken away (const deep = this.minimax(game, depth - 1, (0, Player_1.getOpponent)(player));) in the AI.js file to something higher than 1 but lower than 2 works. I've set it to - 1.55 and it seems to be pretty balanced betweeen ai wins, player wins and draws. Its not the best solution but it works
And this feature is now available (YES!!) in both versions 3.2.0 (discord.js v13) and 4.1.0 (discord.js v14).
Use configuration key aiDifficulty
to customize difficulty level of the bot!
Check this PR to have more information on it 💯
ℹ️ Default value is still Unbeatable to do not break running bots.
npm project page: https://www.npmjs.com/package/discord-tictactoe Releases page: https://github.com/utarwyn/discord-tictactoe/releases