Hacker News new | ask | show | jobs
by shagie 1035 days ago
Some points...

There are three different tile sets: hex, square, and triangle. There are also infinite versions of each. Hex are the easiest, triangles are the hardest. Infinite repeating planes make some things much more complicated.

You start out with simple constant based rules.

    5
    ┌──────┐
    │ 4    │
    │  ┌───┼──┐
    │  │ 2 │  │
    └──┼───┘  │
       │     2│
       └──────┘3
The 5 region and the 3 region can't be resolved directly, but you can say:

    * the 4 cells within the 5 region must either be a 3 region or a 4 region
    * the 2 cells in both regions must either be a 1 region or a 2 region
    * the 2 cells in the 3 region must either be a 1 region or a 2 region
So you would create those as rules.

Later, you get to use variables (they get tricky to think about)

    X+
    ┌──────┐
    │ 0    │
    │  ┌───┼──┐
    │  │ ? │  │
    └──┼───┘  │
       │     ?│ +1
       └──────┘X
A region with X+ (e.g. 3+ which says that this region has 3 or more mines) that overlaps a region that has one more than the number of mines in the X+ (e.g. if the X+ was 3+ then the second region would be 4) and there is no part of the X+ region that does not overlap the X +1 region... and I don't care about the actual values designated by the '?'

The intersection of the two regions is either X or X+1 (3 or 4).

But that rule can be applied for a 1+ and 2 region, or a 2+ and 3... and so on.

And then you get more variables that you can use.

     +Y
    X
    ┌──────┐
    │ ?    │
    │  ┌───┼──┐
    │  │ ? │  │
    └──┼───┘  │
       │     0│ 
       └──────┘X
The X+Y region that does not overlap the X region has Y mines in it. So a region of 8 that overlaps a region of 5 (and all the 5 is in the 8) has 3 mines in the non-overlapping area.