Hacker News new | past | comments | ask | show | jobs | submit login
Snek: An experimental system for writing generative art systems (inconvergent.net)
124 points by drdre2001 on June 11, 2017 | hide | past | favorite | 20 comments



I've used his differential-line repo to make some wall art for my apartment, it's some beautiful stuff:

http://imgur.com/a/BoKdy

Repo at: https://github.com/inconvergent/differential-line


Hi, I'm the author of the repo.

If you want to read about the "framework", rather than look at the code: http://inconvergent.net/snek-is-not-an-acronym/ .


Since that link gives more background, we've changed to it from https://github.com/inconvergent/snek. Thanks!


Great! I like the other stuff on your website too.


i'm glad to hear it!


The author also wrote On Generative Algorithms[0] which is a very inspiring overview for many types of generative art.

[0]: http://inconvergent.net/generative/


I follow this guy's (@inconvergent) generative art on twitter and I highly recommend it as it is awesome: organic and yet clearly procedural.


So if I'm understanding this correctly, you are generating a data structure describing geometry manipulations which can then be applied to a distinct geometry "instance?" If so, isn't this just a free monad?

Also, what are the advantages of this approach over simple function composition operating on immutable data structures/geometries?


i don't know what a free monad is.

not sure if there are any advantages. this is an experiment i'm working on because i find it interesting. separating the data structure from the instructions that attempt to manipulate it has the advantage of making it easier to deal with the state [the state is not changed inside (with-snek ...)]. basically it's a kind of map-reduce. i'm sure you can achieve this in multiple other ways as well.

one of the reasons i'm interested in this particular pattern is described further here: http://inconvergent.net/a-method-for-mistakes/.


It's indeed very interesting!

What I meant is that it might be simpler to just have pure functions operating on immutable data structures, which you could then compose in whichever you want. I.e. you could have a function collapse-vertices that takes some geometry and produces some new geometry (without altering the initial one!), which you could then compose with some other pure function, like produce-random-vertices, and so on, much like a Unix pipe.

A free monad is just a formalization of the command/interpreter pattern in a purely functional context (i.e. most useful in languages like Haskell or Clojure).


I'm not sure about how you would efficiently do this. (I'm not experienced with pure functional programming.) cloning the entire structure for every applied function sounds like it will be slow? is that not what you will have to do in practice?

i basically want the alterations to change the data structure, and i want them to do it according to a particular priority eventually. atm there is no priority ordering.

i can already make (almost) arbitrary functions, but you have to register them ahead of time, and they have to follow a particular pattern: http://inconvergent.net/arbitrary-alterations/. this is so that i can control the order in which they are applied, eventually.


> cloning the entire structure for every applied function sounds like it will be slow? is that not what you will have to do in practice?

In short, no - as an example, when an element is added to an immutable map, a big part of the newly produced map is structurally shared with the old one (check out [0].)

As for the ordering, you could have a list of geometry -> geometry functions. You could then take the initial geometry and apply the list of functions in order, or a permutation of it, or drop some functions, or apply some others multiple times, and so on.

But anyway, it's just an idea - thinking in terms of atomic geometry transformations instead of alternations may or may not be easier in more complex scenarios, I don't know :)

[0] http://hypirion.com/musings/understanding-persistent-vector-...


this link looks interesting, thanks.


Something doesnt necessarily have to be a free monad to be an internal dsl / interpreter. especially if you arent being strict about adhering to monadic rewrite laws.


I find the description confusing: "snek is a simple data structure for working with vertices and edges"

If I hear data structure lisp code is not on my mind, so it's rather an API or a drawing library?

What am I manipulating exactly?

    ; context start
   (with-snek (snk)
What's in `snk`? Sorry, I never used lisp before

Do you plan to write an API documentation?


If I hear data structure lisp code is not on my mind, so it's rather an API or a drawing library?

Most Lisps, especially Common Lisp which inconvergent is using, have plenty of data structures: http://www.lispworks.com/documentation/lw70/CLHS/Front/Conte...

Common Lisp doesn't have a nice literal structure for hash tables/maps/dicts but that is easily mended with a macro.

"(with-snek (snk) ..." is a macro which abstracts away lower level tedious boilerplate. It hands you "snk" on a platter so you can manipulate it.

Common Lisp itself also comes with some of these macros: http://www.lispworks.com/documentation/lw70/CLHS/Front/X_Alp...

"with-open-file" (skip to the examples) is a nice one since it takes care of opening and closing the file for you so you can write your block of code inside of it and be sure the file gets opened and closed properly:

    (with-open-file (f "/path/to/file" :direction :output :if-exists :supersede)
      ... your code writing to "f" comes here ...
      )


you manipulate a data structure that contains vertices and edges. there is more about it here http://inconvergent.net/snek-is-not-an-acronym/.

snk is an instance of snek, so it contains a realisation of the structure and its current state.


so...snk is a graph?


Most data structures are graphs. This one just happens to be "self-aware" enough to use graph terminology.


yes, it is.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: