4 ms·
> figure out a way to do upward movement that doesn’t require annoying special casing. If you figure it out, don’t tell me since it means I’ll have to make more
by abecedarius 4y ago
> figure out a way to do upward movement that doesn’t require annoying special casing. If you figure it out, don’t tell me since it means I’ll have to make more levels.
Don't read this, then (from a 2048 game instead of Sokoban, but same principle): https://github.com/darius/cant/blob/master/examples/games/2048.cant#L135-L137 https://github.com/darius/cant/blob/master/examples/games/20...
As long as I'm commenting, here are some links to other Sokobans I thought were fun (listed in the source code to mine). The sed one is nuts -- I had no idea it could do that: https://github.com/darius/cant/blob/master/examples/games/sokoban.cant#L20-L24 https://github.com/darius/cant/blob/master/examples/games/so...
- mzs 4y agoYour second link is the same as the first.
- abecedarius 4y agoThanks, oops, fixed.
- cole-k 4y agoI couldn't resist and clicked your link, but thankfully it is early and I couldn't quite understand how to port it to the `f . moveRight . f` format. So really it is a shame that nothing can be done about golfing this further and I will be content knowing that... is what I'd like to say if not for the several [1] characters [2] I have at my disposal for a last level. Thank you for sharing though, I also was amazed by the sed one. And just to make it clear since sometimes these things don't communicate well over the internet, I'm being a little facetious here: if you actually want to spell it out for me I'm not going to be upset (but if you don't, I'm also not going to be upset :) ). [1] https://news.ycombinator.com/item?id=34924577 https://news.ycombinator.com/item?id=34924577 [2] https://reddit.com/r/haskell/comments/11953ov/squeezing_a_sokoban_game_into_10_lines_of_code/j9nyk15/ https://reddit.com/r/haskell/comments/11953ov/squeezing_a_so...
- gdprrrr 4y agoI thought of group theory when I read this. The faf' pattern comes up quite a lot and is called conjugation. https://en.wikipedia.org/wiki/Conjugacy_class#Conjugacy_as_group_action https://en.wikipedia.org/wiki/Conjugacy_class#Conjugacy_as_g...
- abecedarius 4y agoYeah, I wanted to stay with your jokey tone. I was thinking along the same line as the parent comment at your link [2] -- really, I was too eager to play know-it-all. Just to explain the difference that may be unclear because of the language: the move functions I linked to call an `each` function which is like Haskell's `map`, only because these move functions all return a list of board states, for the sake of animating the moves in the 2048 game. These all work in terms of `left` in my code, vs. `moveRight` in yours. So the function that'd cause trouble is `down` instead of `moveUp`, if I'd tried to organize it exactly the way you did, versus just generally basing it on conjugation. I didn't try to golf this version, and I sure wouldn't bet on being able to as much as you did. Respect.