Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Pure Skill Minesweeper (andrewt.net)
282 points by ColinWright on Aug 16, 2020 | hide | past | favorite | 99 comments


I had a co-worker who played minesweeper all day long on his Linux workstation which I had remote access to. I grabbed the source code for the exact version of gnome-mines he was using and compiled my own version with some back doors. I would also launch an xvnc server so I could see him playing from my desk. Sometimes I'd have people over at my desk watching him play. It was hilarious.

I could enable various features while the game was playing. Features included: * Always lose on first click * Always win on first click * Force a guess in all 4 corners... so even if played perfectly he'd have to make 4 guesses. * Load custom designs from text file. For instance I had some that spelled things out. * Every click would be completely surrounded by mines (i.e. the number 8) until half the mines were exhausted. This one was fun because I remember him not believing it and actually clicking on a mine. * Ridiculous sounds when he won or lost


It sounds to me like you installed spyware on your coworkers computer. What kind of company were you working at where people see this as a joke instead of a security breach? And let's not forget the trust coworkers have in you not to fuck with their machines.


Sometimes, it's okay to play practical jokes on your friends.


A practical joke, especially in a work environment, should be good-natured and harmless. I think the screen recording aspect of this joke crosses that line. Every other aspect would make for a good prank, but there is just too much potential downside to watching their screen without them knowing. Even if OP didn't see anything but the Minesweeper games and the coworker has no legal expectation of privacy on a work computer, it still violates that person's trust and their likely assumed level of privacy.


"coworker has no legal expectation of privacy on a work computer"

That does rather vary by country - Germany has some strict rules about what employers can and can't monitor.

Also, some organisations explicitly choose not to monitor computer usage too closely (e.g. by using proxies that intercept HTTPS traffic) out of the fear that this would expose the organisation to greater liabilities in the case that someone was doing personal banking from their work PC.


One of the fun things that happens with HTTPS proxies is people desire a policy that only spies on some things people do, and the people making these middleboxes (who are concerned first and foremost with selling a product not with whether that product works or even if such a product could in principle work) are eager to offer that.

This can't work, but, having sold it/ bought it then there's a lot of pressure to make it work.

The best case scenario with such products is that some fraction of traffic is unmolested but the product owner policies do not actually control what that traffic is (which might surprise them and make their overall security policies ineffective but otherwise is no big deal)

The worst case is that in the attempt to do this "selective proxying" some or all traffic security is compromised. Non-participants aren't affected (except it might introduce denial of service) but active participants give up potentially all security. e.g. the company laptop that's configured to the trust the MITM proxy, might not only be uploading your bank password to some screen accessible by an entry level IT guy it might also just inadvertently remove the security of the bank connection altogether so that now random bad guys on the Internet can see everything, whoops.


Spyware is not a prank. Let's not come up with vague definitions of what is, and isn't acceptable.

Coworker has remote access to other coworkers machine and is abusing this trust to install spyware, setting a president for other "jokes".

Sorry man, I don't see anything funny here.


>president for other "jokes"

CJO in modern terms.


You must be fun at parties.


He is probably fun at parties and not undermining his colleagues trust at work.


I might agree with you if the modified Minesweeper did anything more than (if I read correctly) allow OP only to view and modify that game alone, and only when the worker was actually playing it

Nothing was seen that couldn't be seen by shoulder-surfing.


I've been in both kinds of cultures: ones where these kinds of shenanigans were common, and ones where, if HR or IT found out, you'd find your key card deactivated, and a box of your things shipped home.

As ridiculous as it sounds to someone in either camp, both were okay.

The former was an organization where everyone fundamentally trusted each other, and the concept of anyone doing anything really wrong was just foreign. It's so dissimilar to most business in tech today (which are either trillion-dollar megacorps, or places where people jump jobs every 3 years). This was an organization where people stuck around for decades, and everyone really knew each other. Doors weren't locked, and everyone had access to everything. It worked well.

The latter is like most of the tech industry today. My machine is private, and if you've hacked my minesweeper, I'm going to reinstall my OS. I don't know you well enough to know you didn't root my machine or steal my personal files. I'm also talking to HR since you shouldn't work here.


I think that's the right way to view it. People are viewing this through the lens of their current employment, but that's assuming a lot. I did something somewhat similar (in type, if not scope) when I was young and in tech support. The notable facts at the time were that a) we were friends, b) the computers were customized by us, but for the most part interchangeable because a web browser was the software needed, which allowed us to install Linux if we wanted, and c) I didn't really hack it as much as use an admin account he gave me to help in do something on his box.

Friendship comes fast when you're in your early 20's and there's lots of free time to screw around. It's twenty years later now, and I probably wouldn't do that to any of my coworkers. I probably would do it to any of my siblings though. How invasive you can get away with a prank being without upsetting the person targeted is largely based on trust.

When I pranked my friend, the company we were at had probably 30 people working for it, and there were maybe 16 of us in tech support total. It's easy to trust others when you're such a small group, because you can actually know most the people you work with. If your company employs even hundreds of people, that's much harder to do.


> Ridiculous sounds when he won or lost

You could really give someone some good experiences with that. A game that it artificially seems like you narrowly escape disaster turn after turn can feel great at the end.


Is the company you "work" at hiring? ;)


This reminds me of a prank i played on a classmate in high school. I snuck a "ver.com" command onto his boot floppy (the real "ver" was a builtin DOS command) that installed a TSR (remember those?).

We had a very simple custom serial bus network back then. It was sufficient to allow me to send a command to his PC to show a fake game screen when the teacher was looking at his PC. A fun exercise in x86 assembly (fun for me at least)!


I didn't install anything per se, but gained access to my colleague's machine remotely and would play very subtle audio messages in his headphones whilst he was listening to music. Was amusing to watch his facial expressions. I also messed with the volume every now and then and once went a bit crazy and he sussed it out.


As a consultant, I once did a two-day gig at a client site installing some software on a Sun workstation. It was very unsettling when the "restaurant scene" from "When Harry met Sally" started streaming out from the workstation speakers.


I hope the client fired your company.


That would have been something!

I was on a client-provided workstation, and it was the client project manager (!) who played the sound clip on my workstation.

I believe this was not their first rodeo, but it was embarrassing as he??. And I don't even think we fired the customer!


Can you open source this version?


This sounds awesome. Also what kind of workplace was this and did he ever find out?


Did he ever figure out why these "features" happen to him?


Eliminating guesswork from minesweeper kills a subtle metagame. The minesweeper metagame is not about how best to win a particular playthrough, but rather, how to proceed so as to achieve the fastest record time after many playthroughs.

Thus, the metagame includes knowing when to guess (since, for time-beating purposes, it is optimal to instantly guess as soon as you identify that a guess is necessary, not just to speed up that particular playthrough, but more importantly because it will allow more playthroughs to be performed in less time).

Similarly, part of the metagame includes figuring out how best to make initial guesses. Is it better to always initially make 1 guess, or 2, or 3, or does it depend on how much of the board the first guess opens up? Etc.


This is why I always click all four corners first. If there are mines there, I'd rather start a new game immediately rather than end with a guess.


> for time-beating purposes, it is optimal to instantly guess as soon as you identify that a guess is necessary

Often that is the case, but sometimes you reach a point where you ultimately need to guess, but you can make an informed guess based on the number of mines remaining. Then the question becomes, is it worth guessing and potentially losing faster, or are you having a really good game and want to risk losing late in the game?


Wait, there's a timer involved? I always ignore those.


Me too.


The optimal strategy is to fail-fast.


so you're saying that it's a different game.


Does not take all manners of deduction into account.

For instance if there are a 10 unknown spots left on the board, and only two mines left with an unknown location, so there I can limit the the spots that potentially have a mine to the two sets of two spots adjacent to specific numbers, and thus deduce that the uncovered spot adjacent to only uncovered spots must not be a mine.

In such a scenario, the game penalized for me a deduction that it though was a guess. Causing the game to end, but it was impossible for that spot to be a mine!


+1. I lost the game by clicking on a space that could not have possibly been a mine, based on the # of mines left. If there were a mine there, then the total number of mines would have had to be N+1, not N.


Mines from Simon Tatham's Portable Puzzle Collection also doesn’t require guessing and does take that case into account:

> you are guaranteed to be able to solve the whole grid by deduction rather than guesswork. (Deductions may require you to think about the total number of mines.)

https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/mine...


There's a version that fixes this bug (and I think a few others) on the google play store:

https://play.google.com/store/apps/details?id=com.LukeVideck...


One thing I rarely see mentioned is that it's pretty common to have situations in Minesweeper where you need to guess, but the probability of each square being a mine is not the same. While each individual square has the same probability of being a mine in isolation, the numbers leak information: eg. if you have a set of numbers that could be fulfilled by one or two mines, it's statistically more likely that the one-mine solution is correct.

One example: https://math.stackexchange.com/questions/2511421/correct-pro...


Rarely mentioned, except in this very article.

> If I was feeling especially mean, I could insist that the player choose the square with the best odds of being safe, rather than simply judging whether or not each square is theoretically knowable. But I think that would be taking things too far.


I liked the metagame here of guessing the guess which would make the rest of the puzzle as solveable as possible.

P.S. Document how to flag mines in the text (ctrl-click)


The game follows standard 'sweeper conventions. The user is expected to already know them. LMB to reveal, RMB to mark, chord LRMB to complete from a reveal.


Assuming you're not on e.g. Mac with one mouse button. Or mobile, with touch.


Most Macs nowadays will let you do a two-finger click to emulate a right-click (as, indeed, will pretty much any touchpad with multi-finger support).


It extends pretty naturally, as both of those have left- and right-click analogues. Long-press works fine on mobile.


... and if you get to the very end of the map, with everything clear, and find you need to flag the bombs, do you take the risk?

That's the user experience.


One needs to be careful when calculating exact probabilities.

http://nothings.org/games/minesweeper/

previous discussion: https://news.ycombinator.com/item?id=13566730


Drew Roos wrote this code to calculate the exact probabilities: https://github.com/mrgriscom/minesweepr/


Notice that in the example the field 'H' has much higher probability to contain a mine than the fields 'I' and 'F'. This can be very unintuitive. The reason is when counting configurations one needs to consider the placement of all the mines, not only the ones that have a neighbour uncovered. When this is considered then there are (76 choose 6) configurations that have a mine on 'H' and (76 choose 5) configurations that have mines on 'I' and 'F'. (76 choose 6) is a much larger number than (76 choose 5).

In general I found that in a normal game when a guess is needed then it's better to guess for configurations that have fewer number of mines on the perimeter of the uncovered area, as they have higher probability.


See also: https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/mine... - no guessing ever required

https://pwmarcz.pl/kaboom/ - if you guess and you could have deduced, you always die; if you can't deduce, you're always safe.


Cool concept, matches how I want to play Mindsweeper (though others are pointing out some interesting parts of the game that this approach removes).

Played through it once and was confused by why a bomb exploded. Can somebody help me interpret? I'm especially having trouble figuring out what the dashes are in this end-of-game explainer text. Take the space diagonally top-right from the one flagged bomb (the asterix). This had a visible "1" on the board, but is marked as a dash here.

Made a mine because the user clicked it when there was a safe space at 6, 2. Can't be a mine because

  011--1?????????
  12*101?????????
  ??2211?????????
  ???????????????
  [6 rows clipped]
  + 29 mines left to find becomes

  011--1-????????
  12*101-????????
  ??2211*????????
  ????---????????
  [6 rows clipped]
  + 28 mines left to find)


Dashes seem to be places that might be a mine but also might not (because the game has to reserve the right to move mines around depending on where you click).

In this case it's telling you that 6 over (zero indexed) and 2 down (the spot is marked with an asterisk in the second diagram) is safe, because of the pattern of "ones" on the left edge.


If you like this kind of game, you'll probably like the Hexcells series (https://en.wikipedia.org/wiki/Hexcells).

Every game is guaranteed to be solvable without guesswork. The deductions can get a lot more complicated than minesweeper. And it has some nice relaxing background music.

I have all 3 games in the series and I beat all of them in campaign mode without cheating (i.e. without watching other people do it on YouTube or Twitch).

The third and last game in the series, "Hexcells Infinite", has an "infinite" mode where it can generate 100,000,000 different starting boards.


Hexcells Infinite is currently being updated, if you opt in to the beta program on Steam you can try out the new puzzle generation algorithm. Infinite mode is much more challenging now.


I didn't know about that. Thanks for the heads-up!


Hexcells is great, when you figure out a cell by complex set of deductive rule applications, it results a very satisfying feeling.


Fun fact. This game is accessible to screen reader users.

It's just a table we can navigate with standard table-navigation commands, which advanced screen reader users are familiar with.

Unmarked fields are announced as "blank", the rest have either numbers or emoji on them, which is read properly.

The hardest action is flagging a mine, but routing the mouse to where the screen reader is, and then performing an actual right click seems to work.


I prefer the version by Magnus Hovland Hoff [1], which makes the guessing explicit. There is a "Request Help" button that will let you reveal any square you want - but only if there is no other way to progress without guessing (otherwise you lose). This turns Minesweeper into a neat little puzzle game.

[1]: https://magnushoff.com/articles/minesweeper/


I really enjoy this game. I got pretty addicted a couple years back and decided that to truly "beat" the game, I'd learn c# and program a bot that could beat it faster than I could. My handiwork is here: https://github.com/Loufe/GroundPenetratingRadar . I'm not a career programmer so it's not great and the main solving uses heuristics (but I intentionally avoided looking up how others programmed their solver). Still a great, simple game.


I thought the original Minesweeper’s first move wasn’t a risky guess because the board was seeded after clicking the first spot?

Not that I played a ton but I don’t recall ever losing on the first click.


It's actually seeded before the first click, but if you would have hit a mine, the mine is moved to the first available empty spot in the top left (which means the top left corner is slightly more likely than other squares to be a mine).


Nice, so my typical starting move of clicking top left first was not only safe, but also didn't leave me with a corner guess at the end.


Yes, the original Minesweeper never allows you to lose on the first click. This version is an extension of that behavior: it will “cheat” in your favor anytime you are forced to guess (not just on the first move).

> [...] you have to guess the first move and maybe it’ll be a mine. In this case, Windows Minesweeper quietly chooses a different arrangement of mines and pretends like you got lucky after all — but it doesn’t do that if you’re stuck at the end.

> So what if we went further? Below is a version of Minesweeper where you will never be penalised when forced to guess. Any time there simply isn’t enough information to deduce a safe move, we’ll pull Windows’s trick and quietly rearrange the mines so you don’t get penalised.


The first game I played, it gave me a corner with a forced random choice:

    1 *
  | 1 3 *
  | ? ? * *
  | ? ? 3 2
  + - - -
I assume that's the exact situation it was written to avoid, right?

I clicked one of the 3 possibilities and it gave me a mine and ended the game. By the description, I expected it would have created an alternate universe where there was no mine in the square I chose.

So I guess it needs more work.

But I did like being able to click anywhere on an empty board and have it open up a "safe" area. That was always the annoying thing about the original.


Do *s represent flags in this diagram? If so then you can proceed because the 1 and 3 at the top are both saturated, so the two cells below them are safe.


Ugh. I must have copied across wrong. I've closed the tab, so I can't go back and look at the puzzle in question anymore, but the cell I clicked to get the mine was the top right, so the upper-left "1" must not have been satisfied.

Sorry about that.


It's interesting I actually made a similar version of this called "quantum immortal minesweeper" in which upon clicking a bomb it would check whether or not you could calculate the bomb was there, if you could not, it would change the position of the bomb to another possible location.

People ended up being confused by this idea, so I instead made a button that they could click if they thought it was not possible to figure out the next mine. It's a little bit janky but if anyone is interested you can check it out here: qims.greg-mitten.dev


A bit janky indeed - could not figure out how to actually play the game? any hints? (in text, if you can, hate to watch instruction videos)


Fancy a challenge? Join others solving this 1000x1000 board:

http://mega-minesweeper.com/


> More importantly, I would like to make the game recognise when there’s a forced guess _coming_ — currently if there’s a 50/50 chance in one corner of the grid that you’re clearly going to have to take eventually, you have to wait until that’s all there is. If you take the chance when there was a safe space available elsewhere, you’ll always lose.

Before you play, please note that this implementation changes everything.

In the conventional minesweeper, the best strategy is always take the guess first. Since any further play won't increase the chance of correct guess, and if you guess wrong, all the efforts are wasted. But here you are forced to complete all determined safe moves first.

I find myself losing again and again, and finally noticed this rule.


Downloaded Mineswifter yesterday:

https://apps.apple.com/gb/app/mineswifter-minesweeper/id1521...

Nice iOS app that will never force you to guess. What’s more fun though is he made the inverse: Evil Mineswifter - will always make you guess

https://apps.apple.com/gb/app/evil-mineswifter-minesweeper/i...

By far the best looking mine sweeper apps I’ve seen on iOS


I went ahead and played this without reading the description. I'm not sure if it's just me, but it seems like the game starts with a lot of 1s and 2s, and a few 3s, and later on, it's mostly 4s and 5s.

It's intriguing to see a game change by how the players play - like if there was a 50% chance of losing, you'll either have a 100% chance of winning or losing. Something like XCOM can just change difficulty by making a 'default lose' difficulty or 'default win' on easier ones.


I somehow managed to break it https://share.getcloudapp.com/6quexyvk

Clicking on any of the remaining spaces results in:

    Uncaught Error: what
      at LogicGrid.updateKnowledge (logic-grid.js:431)
      at LogicGrid.resolveCell (logic-grid.js:175)
      at LogicGrid.reveal (logic-grid.js:96)
      at HTMLElement.reveal (grid.js:111)
      at HTMLElement.<anonymous> (grid.js:61)


I really like this version, especially that it makes sure you lose if you guess, you can't get lucky. It definitely makes me rethink wether I have to guess or not every time, and it makes me so happy to see a number when I do instead of a mine.

This arrangement made it crash though: https://imgur.com/a/TDj7afQ

Nothing happens if you click on any of the white squares. "Uncaught Error: what"


Love it. It feels like a simulation of many-worlds quantum mechanics. Whenever there's no clear next move, the board is in a quantum superposition. The waveform partially collapses whenever there's a definite choice, but I generally want to avoid that as long as possible because as long as it's not collapsed (there are multiple choices), I can enjoy the quantum immortality of clicking anywhere.


Doesn't this require a guess, and should therefore be safe?

Either the 1st and 3rd or 2nd and 4th available spaces would satisfy the board.

https://imgur.com/ZoyjCBZ

I noticed in the html there's a "knownSafe" class which was populated periodically throughout the game. It did not apply to any of the squares in question, yet when I guessed, I lost.


Yes, if there're 2 mines left, that would require a guess. But not so if only 1 mine is left (or 3 of them)


Pretty sure there's bugs. http://9ol.es/unsolvable.png I don't think any more logical deductions can be made here.

edit 1: got past it presuming that more complex cases weren't being accounted for and yes, there's clearly some cases not being considered.

edit 2: I can now proceed pretty reliably working around that hole.


When you can't make logical deductions, the game lets you take a guess and rearranges the hidden mines so that you don't lose. It's not guaranteeing that you can solve the whole thing with only logical deductions.

(If you guess when you shouldn't, then it instead rearranges the hidden mines to make you lose.)


Offshoot. Are there any always solvable solitaire games out there? I couldn’t find one on the App Store last time I checked.


16 years ago, a man named Eric Sink decided to document the process of creating, marketing and selling a small piece of software he had always wanted to build, "Winnable Solitaire" which is, as you describe, always solvable.

His series of articles coined the term "Micro-ISV" which was a once-common term for a small software company with approximately one employee. A category that is now covered under "Indie" developers.

Here's the article that started it:

https://ericsink.com/entries/Announcing_Winnable_Solit.html

(He didn't end up selling many copies, but we all learned a lot on the journey, it was very interesting at the time.)


The best collection I know is https://www.chiark.greenend.org.uk/~sgtatham/puzzles/ which has ports for various platforms (in my case using android, but apparently there's an iOS port too, see links at the end).

The games have various difficulty levels to choose from.


I’ve recently learned about Spider Solitaire, after getting Clubhouse Games for Switch.

That game seems highly unsolvable most of the time, and have thought many times how it’s be great if there were a version that generated only solvable seeds, as you can sink a lot of time into that game for it to only be unsolvable.

For example, I finally beat it after probably over 150 plays.

Then again, it’s also easy to get yourself in a jam from your own decisions, and I probably am just bad at it.


I think Flipflop Solitaire is supposed to be always solvable. It's also very well made.


This is a great idea!

However I don't understand what happened here: https://imgur.com/1R3BROM

The game claims that the "2 at 4, 0 is done" - in what sense is it "done"? I hadn't marked two mines next to it yet.


It’s “done” because the numbers around it leave no option to move its mines around. Since the mine locations have been fixed in that particular part of the game board, you’re guaranteed that the square at 3,0 is safe. Instead, you clicked on a square you couldn’t possibly know was safe (in the middle of nowhere) when there was at least one square that was definitely known to be safe, so the game punished you for it, exactly as promised.

I played a few rounds on an iPad, so I had no way to mark mines, and the game works just fine. Marking mines has always been for your benefit, to make it easier to remember where the mines are.


Thanks, I think the problem was indeed the way I was interpreting the output!


The square at coordinates x=3, y=0 counting from the top-left cannot hold a mine (the one next to the 2). Try to assume a mine is there and calculate where the other mines would have to be to satisfy the 2 and the 3 below. It's impossible, therefore that top-left square is safe and because you guessed when you didn't need to, you lost the game.

I agree that the game doesn't make it very clear why you lost.


Thanks, I think the problem was indeed the way I was interpreting the output!


After playing a couple of games with three+ lucky strikes, there comes very uneasy feeling that you exhausted your luck for today at least twice. This game will drive you away from reality if played too much. Maybe quantum gods can play this way, but not mere mortals.


Interesting, but you can make the game crash (firefox) if you keep "reaching" out when you have ambiguous mine placements. I'm guessing it has to keep rearranging until it finds a valid board placement.


Crashed with "Error: Infinite loop suspected while learning"


Heh, i happened to have just written a minesweeper clone https://desu.io/minesweeper.html


This runs really slowly, surprising for such a simple game, must be using some super inefficient algorithms for generating the mine placement.


Love it. Can you please make it so the missed safe space is highlighted after the loss?


Since this website only has one narrow column, the reading experience on this is smooth


Weird, for me it's the opposite. I would prefer it to be 2.5x wider.


firefox esr (68) breaks on the optional chaining :(


Tangent:

If I don’t like Minesweeper or Chess, am I still a smart? I really think these games stink.

Need to know guys.


A few years ago, an HN'r posted his "bugsweeper" version here (https://www.ronilan.com/bugsweeper/). I have wasted hundreds of hours playing that game. If you haven't wasted countless hours, then you are at least smarter than me.


“Smart” isn’t a useful concept, or identity. I strongly recommend doing away with mentally picturing people as various gradients of smart. What matters in life is effort. Of course not enjoying chess has no relation to intelligence.

If you give it some time, chess is an extremely rewarding activity. I don’t meditate, but chess and cycling are quite close. It’s a hard departure from the speed of modern life.

One comment I will make, is that expressing ones dislike of an activity, rather than either staying silent or joining, is certainly not a good sign for being “a smart” though. Life is too short to be negative!


Some activities are destructive.

One has a responsibility to complain about those.


Define 'smart'?

For me, smart means not only knowing things, but knowing WHAT to do with that knowledge and how to apply it beyond what they learnt.

As an aside, High IQ != Smart




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: