Live data from Hacker News

Show HN: Lights Out: my 2D Rubik's Cube-like Game

raymondtana.github.io

21–28 of 28 posts

Re: Show HN: Lights Out: my 2D Rubik's Cube-like Game

#21
There are two significant ways in which this differs from a Rubik's cube.

1. It's abelian. Moves can be done in any order, to the same result.

2. there's a simple algo to solve this. Working from top to bottom, left to right: click the first white cell, then click the cell below it. (Then there's a simple endgame at the end once the bottom row is reached.)

Re: Show HN: Lights Out: my 2D Rubik's Cube-like Game

#22
post #16

Not to be confused with the other grid based light flipping game, Lights Out, from 1995. https://en.wikipedia.org/wiki/Lights_Out_(game) Math article https://matroidunion.org/?p=2160

Or 80s Merlin’s Magic square game. https://en.wikipedia.org/wiki/Merlin_(console) Which was only 3x3. But red LEDs which were all the rage in handhelds in the 80s. When learning JavaScript I made a dupe of the Merlin game in JavaScript. It’s really old but still seems to run. Lacks the depth of this game with its larger grid. https://www.aramcomjean.com/magic_squares.html

Amazing. I had one of these, and playing your version just took me back to the frustration I had figuring out that game when I was 7 years old.

Re: Show HN: Lights Out: my 2D Rubik's Cube-like Game

#23
Hi everyone, I'm the OP and wanted to share a few comments that might come as spoilers. So read with caution!

1. The default game has a simple winning strategy: the app begins with a 5x5 board under the "Same Row & Column" variant. Some here have already figured out how to get all reds: [Memorize all the white squares on the board at some fixed moment, and click those cells in any order.] Some of the info below helps see why.

2. The game is always winnable: the app is set up to secretly begin with all reds and then perform many random clicks to mess it up; it's always reversible.

3. The order of clicks doesn't matter: the click actions commute.

4. Every click is self-inverse: clicking a cell twice under any variant leads to the same board as before.

5. A winning strategy need only list out which cells to click once: Because of the properties of commutativity and self-inverse, any winning strategy could be freely shuffled in order and have any duplicate clicks cancel out, leading to a strategy of cells meant to be clicked just once---the rest ignored.

6. Suppose "n" is odd and play the "Same Row & Column" variant. Then, the n-by-n board is solvable by the strategy of "click all the cells that were white." But when "n" is even, then this strategy fails on the n-by-n board. However, there indeed is another strategy that solves those systematically.

7. Very little is known about the other variants, nor about other sizes and dimensions of boards. And it is not true in general that any random pattern of white-and-red can be turned into all-reds. Try to find a good heuristic for separating out winnable vs. unwinnable boards!

8. I did forget to mention other versions of Lights Out besides the handheld game. Other physical games and video games used the 5x5 "Adjacent" variant, too.

Bonus Questions:

1. Can you think of an interesting clicking-rule variant that would not be commutative?

2. Can you come up with the winning strategy for winning n-by-n boards when n is even under the "Same Row & Column" variant?

3. Can you figure out any winning strategy for the other variants? I haven't found any good way to proceed without just memorizing the solutions.

Thanks for the comments!

Re: Show HN: Lights Out: my 2D Rubik's Cube-like Game

#24
I loved that handheld as a kid! I was discovering how powerful vibecoding was last year and used this exact game to show some friends https://drive.google.com/file/d/1jVLpVfUWDkdgImLo45VDtroB-EZ...

One other variant that I've made in the past is cells have N states which increment and cycle mod N.

Re: Show HN: Lights Out: my 2D Rubik's Cube-like Game

#25

Hi everyone, I'm the OP and wanted to share a few comments that might come as spoilers. So read with caution! 1. The default game has a simple winning strategy : the app begins with a 5x5 board under the "Same Row & Column" variant. Some here have already figured out how to get all reds: [Memorize all the white squares on the board at some fixed moment, and click those cells in any order.] Some of the info below help…

Among the 2^n configurations, how many are solvable?

Re: Show HN: Lights Out: my 2D Rubik's Cube-like Game

#26

Earlier quoted context omitted.

Why does that work?

If you think of each button press as a matrix being added to the board state where only the row and column are set to 1, along with the commutative nature of the moves (order doesn't matter), then as long as the total number of "flips" from the cumulative matrices of moves is odd, then it will reset the board. Mathematically I might say that the system's precomputed solution vector is readily apparent.

I think this only works with an odd grid size. With an even grid size you might have to do it twice.

Re: Show HN: Lights Out: my 2D Rubik's Cube-like Game

#27
Here’s my solution: clicking four boxes that form the corners of a rectangle will flip them leaving the rest of the board unchanged. Using this move you can find sets of rectangle corners with more white than red and just click them. This will converge to a solution. If you can find a symmetric board where all rectangle corners have equal red and white then this method would fail. I haven’t found one yet.

EDIT: I found some positions where this technique cannot be directly applied.

Re: Show HN: Lights Out: my 2D Rubik's Cube-like Game

#28
post #25

Hi everyone, I'm the OP and wanted to share a few comments that might come as spoilers. So read with caution! 1. The default game has a simple winning strategy : the app begins with a 5x5 board under the "Same Row & Column" variant. Some here have already figured out how to get all reds: [Memorize all the white squares on the board at some fixed moment, and click those cells in any order.] Some of the info below help…

Among the 2^n configurations, how many are solvable?

In the n-by-n case when n is even, all of them are possible :)

In the n-by-n case when n is odd , that's not the case... it breaks into a few equivalence classes that you can separate out by looking at the "mod 2 sums" across each of the rows and columns.

Post reply on HN