frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

Show HN: Sokoban AI Solver

https://mkornreich.me/projects/sokoban/
41•enjoyyourlife•3h ago

Comments

GPerson•3h ago
“What runs here is a plain-JavaScript port of a native C++ optimal solver I wrote.”

Seems to be AI in the older sense from 10 years ago?

nairboon•2h ago
No, that's still AI in today's sense, just not an LLM.
GPerson•1h ago
On further reflection I actually now disagree that a an algorithm based puzzle solver was ever referred to as AI, even in the context of video games, in which AI refers to the behavior of NPCs.
dev_dan_2•2h ago
Hmm, I would say even older than that (which, of course, is in no way intended to be a value statement of any kind, I like the website and the project, cool idea! :D).

In 2015, https://en.wikipedia.org/wiki/AlphaGo came around and latest from there on, AI was associated heavily with NNs, deep learning and so on (but not with the transformer architecture which became popular later, the foundational paper itself was published in 2017: https://en.wikipedia.org/wiki/Attention_Is_All_You_Need).

If you squint a little, the linked project is basically a https://en.wikipedia.org/wiki/A*_search_algorithm with optimized implementation, heuristics and so on. I also think that A* was associated with AI due to its use in path finding in early robotics - But I am not sure!

mohamedkoubaa•3h ago
Terms like AI used to mean something specific
layer8•2h ago
Not really: https://en.wikipedia.org/wiki/Artificial_intelligence#Techni...
cbondurant•2h ago
While impressive that the optimal can be proven, I feel like the example puzzles here aren't ones that are particularly hard to find solutions for (when move count doesnt matter). I'd be interested to see at least one example that has a lot of tricky dead states that would act as traps.
Retr0id•2h ago
This was a coursework problem in my CS course, back in the day. For larger canvases, the state-space blows up and it gets slow/intractable to solve.
conmod278•2h ago
Imagine providing AI with ability to poke around a large bank of gridbased game problem instances. Ask it to solve them and learn from them and then generate new problem instances.
npinsker•2h ago
Intuitively, I feel like the final board might also be able to be tackled in browser, if you use WASM and speed up the solver.

I wonder: maybe the state is overly compressed? Could it speed things up to store (boxes, [every position the keeper can reach without pushing]) rather than (boxes, representative keeper position), so we can reduce recomputation of the keeper walking around?

I wonder: maybe A* is counterproductive, as obvious heuristics have traps? Maybe BFS is better?

I wonder: the search doesn't actually "skip over" walking states, it just hides them in the processing of each element in the queue, so adding them to the queue might actually be faster?

I wonder: are there any other simple pruning techniques that you could incorporate? Any learnings from state-of-the-art Sokoban solvers, like this one? -- https://ieee-cog.org/2020/papers/paper_44.pdf

Many interesting questions... sadly, the webpage is written by AI, so there's zero discussion of these tradeoffs, future avenues, or rejected ideas, in favor of meaningless self-congratulatory copy about the "provable optimum" and silly claims like a bucket queue being allocation-free.

throwaway219450•1h ago
Showing the exploration would be nice. À la RedBlob tutorials, seeing the solver work is part of the fun. As is I have no intuition for where the algorithm would spend all its time and where it can easily rule out. 1GB of RAM for the final puzzle isn’t too bad for a browser demo if you warn the user and don’t run automatically (is the state space compressible?)
qbane•2h ago
Compared to original sokoban game, the player's final position does not matter, and the number of boxes is strictly equal to the number of goal marks.
Sebastian_09•2h ago
Fun game! Solver seems really smart. It would be great to disable double tap to zoom or make it slightly more adapted to phone screen sizes
CatalystPz•2h ago
pretty cool stuff, enjoyed it
k2xl•2h ago
I wonder how this would do with Thinky.gg games (Pathology or Sokopath). Are you familiar with the site? There's a group of engineers working on various types of solvers in the thinky.gg discord too.
TimTheTinker•2h ago
I love seeing the term "AI" used in the classic sense. Old AI is full of fascinating developments. Expert systems, A* search, genetic algorithms over S-expressions for creating arbitrary solutions, and SAT algorithms were once thought to be that which would eventually scale into AGI.

I suspect that the next big AI breakthrough will result at least in part from constraining LLM decisions with old AI approaches. Frank Coyle presented the idea of ontologies constraining LLM output about a month ago: https://www.youtube.com/watch?v=Sir59K8ZDPU

Going beyond that, I wonder if an agent could keep a running list of assumptions & known facts (with confidence levels/intervals), test them (actively & passively), update them when observations contradict them, and act based on them -- not merely as an emergent behavior, but as a provably correct (old AI based) algorithm embedded in the transformer architecture.

dietr1ch•1h ago
> I suspect that the next big AI breakthrough will result at least in part from constraining LLM decisions with old AI approaches.

AFAIK bridging deductive and inductive AI has been understood as the trick for "AGI" for a long time, probably even before it was called AGI.

I really want this winter of deductive AI to be short. We need both sides and can't afford a long winter like the one inductive AI suffered.

Someone•7m ago
> I suspect that the next big AI breakthrough will result at least in part from constraining LLM decisions with old AI approaches.

> Going beyond that, I wonder if an agent could keep a running list of assumptions & known facts (with confidence levels/intervals), test them (actively & passively), update them when observations contradict them, and act based on them

I don’t think that’s “going beyond that”. It’s a blackboard system from the 1980s (https://en.wikipedia.org/wiki/Blackboard_system)

xpct•2h ago
Got me curious: is there some way to approximate solvability of a puzzle in a certain time frame, or is that completely intractable?

Also, what counts as "complexity" in Sokoban puzzles. Does it plateau at a point, where board size/box count starts scaling the solving time more linearly?

yobbo•1h ago
For games in general, one measure of complexity is branching factor. It means average number of possible actions or states at each turn. It is knowable.

"Solvability" would mean number of turns to solve the game. It is known for some puzzles and can be found by brute force, otherwise you need to figure out a proof.

xpct•1h ago
Thanks. Given a solver, could we extrapolate a problem's branching factor? For classic Sokoban, I'd guess it's on the lower side?
mightybyte•1h ago
I think there are two ways one could look at this. One is to make each move be a move of the player's location. If you do that, then the branching factor is obviously < 8. But there's a second way you could define a "move" for the purposes of a solver. And that would be to only consider pushes. In that case, the branching factor would be < 8*num_stones.

In either case, I think when trying to assess complexity it might also be useful to consider the "narrowness" of the winning move sequence. Positions where the number of moves that win/make progress towards the goal is a small fraction of the number of available moves would arguably be harder or more complex than positions where a larger percentage of the moves win/make progress. In other words, finding a smaller needle and/or in a larger haystack makes the problem harder / more complex.

epiccoleman•1h ago
I'm kind of surprised to find myself enjoying this because I've had a certain hatred for box pushing games. (maybe it's trauma from the sliding blocks in Pokemon games, heh). I guess I'm getting over it (maybe it's happy memories from Baba Is You).

Anyway, one thing that's fun here is that you can trigger the AI solve from any board state. So in particular on puzzle 12 I was interested to see that an initial push (to escape from the 'box' where you start) I'd written off as untenable turns out to be the optimal solution. Then of course it's fun to watch the solver tackle the initial conditions I solved under (and still beat my number of moves).

Might be kind of fun to play with "pessimizing" the puzzle - like, how can you move blocks around to provide a maximally adversarial place to hit the "solve with AI" button? (obviously you don't get to count your initial moves around the board, or you could just move back and forth to get the most pessimum (thanks, Mel) solution.)

Edit: Puzzle 14 feels odd. Super easy, why is it at 14? Maybe something tricky about it that I'm not seeing, perhaps the shape of the arena makes A* harder or something?

Also, 15 is interesting and highlights a theme I'd noticed, which is that often the initial moves of a puzzle seem pretty locked in, and the place where the AI shaves moves off my solution in in some clever approach to the "stacking" of boxes onto the goals. I guess that seems kind of obvious when I write it out.

Anyway, thanks for something to noodle on this morning!

cbondurant•9m ago
I think 14 exists as a test case for having a larger search space that needs to be efficiently ignored. Its not difficult solution wise, but if it is particularly slow that means you're doing a bad job at pruning potential steps. Making sure you're doing good early pruning of the empty chambers.
amelius•1h ago
Doesn't this break down quickly as the area increases? (Ironically, the complexity goes down as there are more squares to use).
xpct•41m ago
Hmm. The push representation makes sense because solve progress is entirely dependent on it. And the movement state tree can be reduced to the push tree, which would only prune useless paths. The push tree can probably also be pruned for moves that leave to softlock, but I wonder whether it can be reduced to a different representation still. Push tree already requires us to maintain a mask of where we can move to, so it's not computationally free. I can imagine representing box pushes as every position we can push it to in the current setup, but that would also make it more computationally expensive.

I feel like there's an interesting tradeoff of storing/computing cheap representations vs exploring a smaller tree.

jan_Inkepa•43m ago
There's computational complexity, then there's human complexity. I've thought a lot about this over the years (I've made a bunch of puzzle games, and puzzlescript, an engine/language for making grid-based puzzle games), and the only paper I've read that's made me think 'huh' was "Difficulty Rating of Sokoban Puzzle" by Jarušek and Pelánek ( https://www.fi.muni.cz/~xpelanek/publications/stairs2010-fin... ).

While I have a feeling that subject 'difficulty' is necessarily a slippery concept, they focus on 'context switching' as a key element of difficulty. In sokoban terms - how often you have to alternate between pushing one box and pushing another. This too can be gamed/trivialized, but, when I used it as a heuristic is was very good at generating the most horrifically difficult levels, much moreso than just going for 'solution length'.

On more general notions of complexity. In sokoban terms, the number of crates trumps everything else - for solvers I've written you quickly get exponential explosions with the number of crates. Nothing else really is significant.

I've also been working on solvers for more general classes of these games (puzzlescript games) and it's surprising how powerful generic solvers still are. PuzzleScript+MIS https://dekeyser.ch/puzzlescriptmis/ (not by me) is one powerful tool that uses PuzzleScript as a basis. I've worked on speeding up the solver a bunch (not currently integrated), figuring out good general heuristics for different kinds of games ( https://github.com/increpare/puzzlescript-labs has various experiments in this direction, including a modded version of PS+MIS). It's a nice optimizaiton problem for focusing on making numbers go down - there are lots of games to test on.

xpct•17m ago
Wow, thank you for your input! The "alternation" proxy for difficulty is fascinating to me, doesn't feel like something I would have thought of right away. And, I guess I wasn't aware of how much thought goes into designing Sokobans :)

I think the crates trumping other complexity metrics isn't entirely obvious to me. For problem 15 in the OP's post, author says it was too expensive to compute at runtime in the browser. From a human perspective, it's not apparent why, as a large part of the solution is very repetitive. It feels as if there should be a more condensed representation for iterating over problems like that one.

If I may gauge your opinion on it, have you looked into MazeBench? It comes from LLM benchmarking circles, but seems to suggest a search space that's too difficult for LLMs, even with tools, to solve. Curious how much overlap the PS/MIS solvers would have with solving something like this.

jan_Inkepa•7m ago
> From a human perspective, it's not apparent why, as a large part of the solution is very repetitive. It feels as if there should be a more condensed representation for iterating over problems like that one.

I'm not sure how 'in' you are, you might know this already, but for sokoban IIRC the recommended way is to treat things is topologically - you always do a flood-fill empty space from the player so that the decision isn't whether to go up/down/left/right on this turn but which accessible side of which crate to push. It decomposes quite well, and maybe makes the complexity a bit more obvious? Hmm...

I haven't looked into mazebench, but yes this is very related stuff.

FartyMcFarter•40m ago
According to Wikipedia Sokoban is NP-hard, which means there's no known polynomial time algorithm to solve it. It also means it's unlikely such an algorithm exists, as that would imply P=NP which is not believed to be the case.

Show HN: Sokoban AI Solver

https://mkornreich.me/projects/sokoban/
41•enjoyyourlife•3h ago•31 comments

Show HN: Learn Flags Quiz

https://flagquizzes.com/
16•artiomyak•2h ago•6 comments

Show HN: Saggar, a Mac terminal that keeps sessions and your attention organized

https://saggar.marginalutility.dev/
12•mcclowes•2h ago•2 comments

Show HN: Desktopcolors.com – A museum for solid background colors of classic OS

https://desktopcolors.com
96•vlowrian•8h ago•38 comments

Show HN: A community library for Claude Code status lines

https://statuslin.es
4•nastynate•3h ago•1 comments

Show HN: All roads lead home – a Google timeline replacement

https://takeallroads.com/
8•lizhang•2h ago•3 comments

Show HN: I backtested my own stock site's signals and published what failed

https://matterofstocks.com/
2•matterofstocks•2h ago•2 comments

Show HN: An RSS Feed for DeepSWE Benchmarks

https://rss.xlit.app/deepswe
3•ghasemi•3h ago•0 comments

Show HN: A public AI whose memory is shared across all users

https://wildstatic.com/
78•adjohu•1d ago•68 comments

Show HN: Mic Drop, a real-time multiplayer karaoke game

https://www.micdrop.gg/
86•johnsillings•1d ago•39 comments

Show HN: PageSieve, a web scraping browser extension

https://julius383.github.io/PageSieve/
17•kajm•1d ago•1 comments

Show HN: ThoughtDAG – An editable context graph for LLM conversations

https://chenxiachan.github.io/thoughtdag/
133•chatchan•2d ago•61 comments

Show HN: Flynt.js – 2.2kb, zero-build, CSP-safe reactivity library for MPAs

https://github.com/marsbos/flynt.js
12•bosmarcel•23h ago•1 comments

Show HN: Mole – Deep research agent for your terminal

https://github.com/lajosdeme/mole
100•lajosdeme•2d ago•14 comments

Show HN: Adding friction to my automatic open Claude reaction

5•aqureshi8•15h ago•0 comments

Show HN: Silent Shark – tactical map-based WWII submarine sim

https://silentshark.app/
78•epaga•4d ago•38 comments

Show HN: Deltix – AI Driven Testing

https://app.deltix.ai
54•oneounceman•2d ago•11 comments

Show HN: Bribes.fyi – Compare bribes statistics department wise

https://bribes.fyi/compare
53•neverenderr•1d ago•34 comments

Show HN: LuaCAD – Parametric CAD Scripted in Lua

https://luacad.ad-si.com
105•adius•3d ago•25 comments

Show HN: Convertix – Fast, 100% in-browser media and QR tools

https://convertix-fast-imager-co.blogspot.com/p/blog-page.html
3•convertix123•16h ago•0 comments

Show HN: PyScrappy, self-healing web scraping selectors plus an MCP server

https://github.com/mldsveda/PyScrappy
21•vedaant00•1d ago•2 comments

Show HN: A visual ping utility that is pretty

https://source.tube/ache/rusty-ping
3•_ache_•16h ago•0 comments

Show HN: A website for exploring historical photographs of my city

https://yesterdays.maprva.org/
35•uneekname•5d ago•16 comments

Show HN: Continuum – Financial simulations for DIY multimillionaires

https://continuum-app.xyz/
6•charleswcho•15h ago•9 comments

Show HN: SolidSync – Poorman's Solidworks PDM

https://github.com/baggiest/solidsync
2•Baggie•19h ago•0 comments

Show HN: FileIndexer (simple N-copies verification on ext USB drives)

https://www.thanassis.space/indexer.html
2•ttsiodras•19h ago•0 comments

Show HN: I shrank DeepSeek V4 Flash to 57GB and it wrote a compiler on my Mac

https://huggingface.co/steadfastgaze/DeepSeek-V4-Flash-0731-Coder-56.8GB-MoEspressoV2
19•hacklas•23h ago•3 comments

Show HN: Interactive component to map fibre breaks (OTDR)

https://react-networks-lib.rackout.net/otdr-strip
8•matt-p•20h ago•0 comments

Show HN: Lumabri – Run Moe Models on a P2P Swarm with Colibri

https://github.com/JustVugg/lumabri
48•vforno•3d ago•19 comments

Show HN: I built a native app for coding agents with Rust and GPUI

https://waku.sh
39•0x142857•1d ago•15 comments