Very nice and satisfying, but I would suggest ramping up the difficulty a little faster. I got until lvl 15 by just flipping the obvious areas, taking no more than 2 seconds. It's otherwise very cool and minimalist.
Edit: limiting it to square flips was a great idea. There are just enough moves to make the answer non-obvious (after lvl 15), but not so many possible moves that you get overwhelmed.
---
Edit 2: I just remembered I made a similar "game"[1], where you select columns to XOR with other columns and try to reach the target pattern. Use the scroll wheel and shift+wheel to change the pattern and size.
That was actually part of a real research project in optimizing circuits for computing binary finite fields, where the "game" was a sandbox to try different algorithms. The best algorithm was actually found by someone playing in this sandbox and coming up with an efficient strategy.
I think if you make the par visible in the "result screen" and add a "try again" option to "next" this could make it more interesting without the need to ramp up difficulty. I think I solved a few cases with a bunch of random shifts, for example, and may have switched to thinking mode if I was faced with that.
The game is quite fun. But it seems the difficulty ramp quite late? It's not very difficult to get the answer with least step by solve the side first until about last 20 levels.
Also, the game does give you a hint about how to bruteforce the level if you only have one square left. Good job.
It took me a while to get past the instruction screen (I needed to press space, then "E" for english, then press escape) Now I can't seem to figure out the controls for the actual game.
I like it. Played a bunch of levels. I could feel my brain learning new patterns (like the card game Set). There are a handful of really useful primitives.
Worked fine for me on Firefox on Galaxy Note 20. I've never run into single finger back gestures that can start anywhere - seems like that would break almost everything that involves dragging.
Yeah, it's my plan to implement daily levels, as well as weekly levels.
I was thinking of making weekly levels be very big (like 12x12) where I don't know what the par is myself, and have it be a challenge to see who in the community can figure out a way to get the lowest number of moves.
And daily levels would probably be more similar to the regular levels.
Thanks for replying. Since you're considering bigger levels, maybe three daily levels: easy / medium / hard.
On my games I usually go with five levels [1], in different tabs that can be solved concurrently, from very easy to very hard. People seem to enjoy the progression.
(If I'm trying not to spoil anything, do I even post? Maybe I can encourage someone else to have fun giving it more thought.) At least one elegant and efficient answer is within reach for many. The person who first pointed it out to me didn't need to know the relevant branch of mathematics to do so; he intuited the shape of it without the formal terminology.
I'll be particularly curious to hear the pattern(s) in how many solutions there are, and/or the probability of a random board being solvable.
The haptic feedback on mobile is really on point in this implementation.
Regarding the number of solvable boards. It is actually possible to calculate the exact number. The solvable boards correspond to the image of the matrix of moves. It will be a vector (sub)space over Z/2Z, so it will always be a power of 2, and its size will be determined by the rank of the matrix. For example for 5x5, there are 2^22 valid boards.
And regarding the number of solutions to a given board, (assuming you ignore the order of moves, because it doesn't matter) it will always be the exact same number, and in the case of 5x5 it will be 2^8. 8 is the nullity of the matrix of moves.
Note that 22+8=30, which is 44+33+22+11, which is the number of possible moves.
We might be in pretty similar spots with respect to a solver, then. For one with no conscious linear algebra or deep programming background, as long as XOR or modular addition is familiar (which I suppose narrows it), I think a possible sequence of realizations is:
1. The flippable regions need be flipped at most once, in any order. So, one could think of a solution as a collection of boolean variables, one for each region, indicating whether to flip it (true/1 if so, false/0 otherwise, feels natural).
2. A tile needs to be flipped an even number of times if it starts in the desired state, and an odd number of times otherwise. So: Give each tile an equation by forming the XOR (or addition modulo 2) of the variables for all the regions it inhabits, and then setting that expression equal to 0 if the tile starts out in the desired state, otherwise 1.
3. Observe that such equations are always easy to rearrange so as to solve for any desired variable.
4. Observe that we can therefore run through a familiar substitution process, and good things will happen.
What I find elegant here is that the resulting algorithm is known to many from early algebra and has a much more clearly bounded runtime than the backtracking searches that suit other logic puzzles. Of course, as you've evinced, the fuller representation with linear algebra opens many doors to both implementing this well and exploring its other properties.
Finding par, on the other hand, I'll have to consider further. I suspect that, after representing the solution space succinctly, you could get a fair way with a backtracking search therein (where to make a forward step is to concretely assign a value to a variable), with the search tree trimmed via the best par observed so far. If you have something drastically better than that, I'm sure that would be interesting!
Looking forward to seeing what you do next, also perhaps the potential blog post you mentioned elsewhere in this thread, etc.
Tangentially related, have you heard of Bombe? It's a hexagonal minesweeper where you write rules to solve every possible scenario. It even checks your rules' satisfiability via SMT.
Yes I got stuck there for a while. I did a few more after that but my interest waned. I did spend a lot fo time feeling ike a pixel in Conway's game of Life.
i have a strong quibble about calling this XOR. XOR takes two arguments and one of the arguments here is implicit. The game inverts the square colors, which XORing with "1" will do, but it's not defined whether white or black is 1, it just inverts white and black.
The way I thought of it was 0=white 1=black. I used the term XOR when posting on hacker news because I thought people here might have an intuition about the kind of patterns it could form in 2D
Edit: limiting it to square flips was a great idea. There are just enough moves to make the answer non-obvious (after lvl 15), but not so many possible moves that you get overwhelmed.
---
Edit 2: I just remembered I made a similar "game"[1], where you select columns to XOR with other columns and try to reach the target pattern. Use the scroll wheel and shift+wheel to change the pattern and size.
That was actually part of a real research project in optimizing circuits for computing binary finite fields, where the "game" was a sandbox to try different algorithms. The best algorithm was actually found by someone playing in this sandbox and coming up with an efficient strategy.
[1] https://boppreh.com/source/playreduce/