Bayesian Minesweeper

by ZankerH1 min read20th Sep 201121 comments

2

Personal Blog

This is an idea I've been throwing around in my head for the last couple of days, but finally got around to actually implementing in code today. I am now ready to subject the world to my terrible programming skills.

I suspect most computer users will be familiar with the game of minesweeper - it really isn't all that complex by itself. However, I've added a little twist to it. The idea is the following:

  1. Mines and people are randomly distributed across the minefield.
  2. The player can only detect mines, not people.
  3. The player can stop searching for mines at any time she/he desires.
  4. If the player opens a cell with a mine, all mines detonate.
  5. If the player stops searching, only the non-flagged mines detonate.
  6. Once the game ends, every person in an explosion or next to one dies.
  7. Every survivor contributes 10 pleasure.
  8. Every death contributes 10 pain.
  9. For every death, every survivor contributes 0.05 pain.
  10. There are 480 cells, 250 people and 99 mines.
  11. Your goal, should you choose to embrace it, is to maximise the pleasure/pain ratio.

That is all. The values I chose arbitrarily, but right now I feel it's pretty balanced. Once you flag around a third of the mines, the ratio starts rising considerably, but there is always an element of chance. If you hit a mine on your first try (or quit immediately), around 80% of the people will die on average.

SYSTEM REQUIREMENTS: Python 2.7, ncurses.

Update #1: Implemented JushuaZ's idea - if you flag an empty cell, all your flags are disregarded.

Update #2: Fixed bug spotted by DanielLC

Bayesian Minesweeper