Minisweeper is a Minesweeper clone created in 1015 compressed bytes for the PICO-1K Jam 2024. To win, correctly place a flag on every mine in the grid. There are two difficulty levels:
- Easy: A 10x9 grid with 10 mines
- Hard: A 16x15 grid with 36 mines
Can you beat both?
Controls:
- Arrow Keys: Select difficulty / cell
- Z: Open cell
- X: Place / remove flag
@F1Krazy
Not bad, squeezing minesweeper in 1K is not easy. I agree with the cut of chording, no bomb on 1st reveal, or colored numbers, but feel that auto clear on 0 is really missing.
Let's see if there's characters to retrieve to add that to the game ....
Booleans :
LUA treats NIL as false so
add(gr,{b=false,o=false,a=0,f=false})
can become
add(gr,{a=0})
Anything other than NIL and false is considered true, so
c.b=true
becomes
c.b=1
Same for s.o=true
Rather than testing grid boundaries when counting bombs, we could use a fixed 0..17 0..17 grid.
There's also the cursor controls that can be optimised by doing computations on btnp() without parameters, and by having ?"\ag2" only once.
I think the recursive clear can barley fit if we do all those optimisations.
In all honesty, that was less a matter of token count, and more the fact that I simply didn't know how to do it. Every time I try dealing with recursion in a 2D grid in Lua, I end up causing infinite loops, performance issues, or incorrect behaviour, and it just melts my brain. Rather than deal with all that and the token constraints, I decided to just not bother.
Thanks for the optimization suggestions, though, I'm out of time to make any real changes for the jam but I can at least bear them in mind for next time.
@F1Krazy
Did the previously suggested optimizations, plus an extra unreadable toggle game parameters with subtraction, and with the characters gained, I added recursive clear and grid warp. I tried to fix some bugs (you can clear flags and mess the game state) but it lead to going over 1K, so I removed the checks. Correctness is not the main focus for miniminal size jams.
To save characters, recursion uses only PX and PY globals and a reordered unrolled loop, like we did in microsoft basic in the 80s (gosub had no way to pass parameters)
@RealShadowCaster Amazing, thanks! I'll take note of that code for next time.
[Please log in to post a comment]