Hacker News new | ask | show | jobs
by hkdobrev 1738 days ago
Where is Minesweeper example? :-D
1 comments

That would be hard to do. Checkboxes can only be in two distinct states.
Three, if you count disabled.
And partial, no? So four states.
We can go higher:

    <input type="checkbox" />
    <input type="checkbox" checked />
    <input type="checkbox" indeterminate />
    <input type="checkbox" disabled />
    <input type="checkbox" disabled checked />
    <input type="checkbox" disabled indeterminate />
Right. But that still isn't enough for minesweeper, where a cell can be: covered, marked, uncovered with no mines next to it, uncovered with one mine next to it, uncovered with two mines next to it… etc until uncovered with eight mines next to it.

So except if you limit the game to having no cells with more then one neighbors with a mine, it won't work.

What I'd do:

• All squares start off as unchecked boxes.

• Marked squares are partially-checked boxes.

• Revealed bombs (e.g. player lost, show the board) are fully checked.

• Uncovered squares are deleted, and a number is placed in the space as simple text.

You could absolutely argue the last point is cheating, but, meh, I feel it's within the spirit of the idea.

(Undecided on whether to use disabled checkboxes to mark the perimeter of the playing field; I'd have to try it and see what felt right.)

See the snake game on the website.