I implemented A* in Common Lisp for my Springer Verlag AI book (1998), so a bit of nostalgia for me.
SBCL is really an amazing ecosystem and I argue that it is a great example of the power of open source.
11–20 of 23 posts
I implemented A* in Common Lisp for my Springer Verlag AI book (1998), so a bit of nostalgia for me.
SBCL is really an amazing ecosystem and I argue that it is a great example of the power of open source.
Earlier quoted context omitted.
The "c++ implementations" are two stack overflow answers. I don't think the comparisons are representative of the performance of implementing A*: 1 - Is an innefficient and obfuscated BFS. It has no heuristics. (The lisp benchmark is using Manhattan distance. You can think of it as comparing walking blindfolded on a maze vs having a GPS that tells you how far you are from the exit) 2 - Is a person claiming numbers on…
>the implementations are two stack overflow answers. This is pretty uncharitable. One of the "answers" is just a link to the authors research paper. Not like it's just something they quickly threw together for some SO post. It is a bit strange that they link to the SO post and not the paper though.
Can someone explain why is this special? It doesn't look anything more than an algorithm implementation
I imagine this could be done with C++ templates as well, I’ve just never used them myself.
But this gives the compiler ample opportunities to optimize, since the code is specific to the desired domain. It also hides a bunch of the clutter that typically accompanies optimized Common Lisp code with all of the declares, declaims, and type specifiers.
It's quite a bit faster than my Lisp version, at least, though mine's an unoptimized (lots of lists) incompletely ported C++ version. Tempted to dig out the C++ version and compare since it was pretty fast... I originally ported it to make a joke about a vtuber's long neck: https://pbs.twimg.com/media/FAJQkskVQAoiGlT?format=png&name=... (Edit: screenshot from C++ version: https://www.thejach.com/imgs/visibility_with_astar.png Note how the shorter path would be going through the central chamber, but visibility is high there, so it goes down the corridors. Original had lots of extra features like fog of war, visibility tests/terrain analysis, smoothing and rubber-banding, a Floyd-Warshall implementation...)
I love seeing highly optimized Common Lisp code like this. I implemented A* in Common Lisp for my Springer Verlag AI book (1998), so a bit of nostalgia for me. SBCL is really an amazing ecosystem and I argue that it is a great example of the power of open source.
Can someone explain why is this special? It doesn't look anything more than an algorithm implementation
It’s also notable that the core algorithm is not a function, but a macro. That means that you end up with an exact representation of the algorithm to the constraints as defined, instead of a general purpose algorithm with parameters. I imagine this could be done with C++ templates as well, I’ve just never used them myself. But this gives the compiler ample opportunities to optimize, since the code is specific to the…
However I am also on for some Lisp love.
Earlier quoted context omitted.
>the implementations are two stack overflow answers. This is pretty uncharitable. One of the "answers" is just a link to the authors research paper. Not like it's just something they quickly threw together for some SO post. It is a bit strange that they link to the SO post and not the paper though.
But also, a ton of people use SO code verbatim.
Earlier quoted context omitted.
But also, a ton of people use SO code verbatim.
Do they? I very much doubt that.