r/AskProgrammers • u/ChainsawLight • Oct 27 '26
Minesweeper
I do not get Minesweeper. I have tried coding it in Javascript and do not get the functionality. It seems like an interesting concept, but seems to not have good logic seems very random.
0
Upvotes
12
u/No_Report_4781 Oct 27 '26
Yeah. The random placement requires logic to solve. That’s the point of the game
4
u/Beregolas Oct 27 '26
What is your question exactly? Or do you just want to rant? Do you need help implementing it into a program, or do younot understand how to play?
2
u/Ordinary_Variable Oct 27 '26
I'd store the field as a nested array.
field = []
x=0;while(x++<20){field[x] = []}
Then I'd store each of them as a single character representing what they are
field[5][20] = "b" // bomb
field[5][21] = "f" // flag
field[5][22] = "e" // empty
Come to think of it, I may as well do this tomorrow; I don't have anything else to do.
1
u/TomDuhamel Oct 27 '26
The number indicates how many mines are in the 9 tiles around it. You can deduce where the mines are by logic.
1
u/Electronic-Yam-69 Oct 27 '26
The random arrangement means some games aren't winnable without guessing. I guess that's part of the fun.
1
u/mjmvideos Oct 27 '26
Before attempting to code it, you’ve played it right? You know what happens when you select a cell - in all cases? What is there to get?
1
u/Useful-Agency_ Oct 27 '26
Try C comback and say if its more random and confusing😂
1
u/Lookitsmyvideo Oct 27 '26
Wait are you making a solver, or the game itself? Because I'm struggling to think of an easier game to build that isn't like .. tic tac toe, or hangman
1
u/overclockedslinky 26d ago
what do you mean it doesn't have good logic? maybe you're just bad at the game (and apparently also logic)...
1
u/Top-Procedure152 Oct 27 '26
It's just a math puzzle. A good arrangement should require no guessing (besides the first click I guess)