frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

O(1) memory, no-preprocessing reachability algorithm for 2D grids

2•MatthiasGibis•22h ago
I’ve been working on a reachability checker for 2D grids that:

- uses *O(1) memory* - requires *no preprocessing* - handles *arbitrary obstacle maps* - and finishes in under 0.1ms even on large grids (e.g. 16,000×16,000 from bottom-left to top-right)

It works without BFS, DFS, A, or flood fill. The core idea is a hybrid of greedy movement toward the goal and robust outline-following (wall tracing) that switches direction when needed and detects loops to ensure correctness.

The algorithm is fully deterministic and guarantees correctness for any map and any pair of walkable start/end points.

My motivation: I want to make traditional flood fill obsolete for any project that uses it purely for reachability checks. In many real-time systems (like games), a full BFS/DFS or even region-preprocessing is overkill when you just need to answer: “Can I reach tile B from tile A?”*

Here’s the Swift version of the main logic

https://github.com/MatthiasGibis/2D-Grid-Reachability-Check/blob/main/mgReachabilityCheckGibis.swift

A variant that considers *height differences* is also available.

https://github.com/MatthiasGibis/2D-Grid-Reachability-Check/blob/main/mgReachabilityCheckGibisWithHeight.swift

Comments

gus_massa•15h ago
Clicky (repo) https://github.com/MatthiasGibis/2D-Grid-Reachability-Check

Ask HN: Any good tools for viewing congressional bills?

21•tlhunter•1h ago•13 comments

Ask HN: What are some good resources for coding best practices?

3•genericmask•1h ago•2 comments

Ask HN: Should I build a directory product?

3•alizaid•2h ago•2 comments

Ask HN: Startup getting spammed with PayPal disputes, what should we do?

275•june3739•2d ago•179 comments

Ask HN: Has anybody built search on top of Anna's Archive?

282•neonate•2d ago•146 comments

Ask HN: Anyone else feeling increasingly alienated from the industry?

15•saubeidl•8h ago•14 comments

Ask HN: What are your fav/goto decision making hacks/heuristics?

4•ottaborra•9h ago•7 comments

Ask HN: Who is hiring? (June 2025)

365•whoishiring•4d ago•463 comments

Ask HN: How do I learn robotics in 2025?

395•srijansriv•4d ago•99 comments

Ask HN: Running AI agents in isolated environments

4•polycaster•11h ago•0 comments

Ask HN: How do I learn practical electronic repair?

180•juanse•6d ago•112 comments

Ask HN: Anyone making a living from a paid API?

247•meander_water•6d ago•172 comments

Ask HN: What do you put in claude.md and what you leave out?

5•bognition•1d ago•2 comments

Ask HN: Options for One-Handed Typing

92•Townley•2d ago•93 comments

Ask HN: Walking while working and having meetings

3•martythemaniak•15h ago•5 comments

Ask HN: Who wants to be hired? (June 2025)

125•whoishiring•4d ago•384 comments

Ask HN: Who's Using the Origin Private File System?

4•ChadNauseam•15h ago•1 comments

Ask HN: What Does Your Self-Hosted LLM Stack Look Like in 2025?

17•anditherobot•1d ago•6 comments

O(1) memory, no-preprocessing reachability algorithm for 2D grids

2•MatthiasGibis•22h ago•1 comments

Ask HN: What tools are you using for AI evals? Everything feels half-baked

4•fazlerocks•22h ago•2 comments

Ask HN: What is the best LLM for consumer grade hardware?

238•VladVladikoff•1w ago•182 comments

Ask HN: Where do you go for cutting-edge dev news and info?

2•TimTheTinker•1d ago•9 comments

Ask HN: How are parents who program teaching their kids today?

101•laze00•5d ago•91 comments

Ask HN: Dealing with Vibe Coding Depression?

16•softirq•1d ago•23 comments

Reaching my first 100 users without money or audience (at 10K users now)

32•felixheikka•3d ago•11 comments

How do you store and maintain your CV/resume over time?

10•xantin•2d ago•16 comments

Ask HN: List of skills to survive the AI tsunami

16•cookiemonsieur•1d ago•6 comments

Ask HN: What's with the repeated job posts on "Who's hiring"?

85•rafavento•2d ago•41 comments

Ask HN: Is Adrian Colyer of "The Morning Paper" fame ok?

10•yencabulator•16h ago•0 comments

Ask HN: Best way to get laid off

10•jakamm•1d ago•24 comments