Closed adan-ea closed 2 years ago
You mean this is always your output? Or just very similar to this?
The algorithm used for planting the mines is a very simple random number generator. So if you always get the same or similar results, it means either:
Math.random
is overwritten by another functionTry running this before the generation and show me the matrix it produces:
const matrix = new Array(7).fill(null).map(e => new Array(9).fill(0));
for (let i = 0; i < 30; i++) {
const x = Math.floor(Math.random() * 7);
const y = Math.floor(Math.random() * 9);
if (matrix[x][y] === 1) {
i--;
} else {
matrix[x][y] = 1;
}
}
I'm having really similar results, every bomb on the top with way too many rows. I do have bad luck but this time i'm almost sure it's not it
Here :
The output seems normal to me here.
To be honest what weirds me out even more is that you asked for 7 rows and you somehow got 11 instead... I honestly haven't ever seen anything like this before.
Have you tried uninstalling and reinstalling the module? Also can you show me the full akairo command file? FYI I'm using akairo + discord.js-minesweeper too in my bot and it works fine, so I doubt that's the problem. Here's the code I have anyway: https://github.com/thimble-bot/thimble-bot/blob/master/src/commands/fun/minesweeper.ts
Oh, I think I just realized what you're doing wrong! You're calling minesweeper.start();
twice, so it tries to repopulate the matrix twice as well, which currently results in undefined behavior like this.
Ooh... right, i'm so sorry i opened an issue for this.. Sorry for the waste of time !
When i generate a minesweeper it just goes this way for some reason.
How i generate the minesweeper in my code (i use discord akairo, it might break something ?):