
Snek: An experimental system for writing generative art systems - drdre2001
http://inconvergent.net/snek-is-not-an-acronym/
======
MooMooMilkParty
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](http://imgur.com/a/BoKdy)

Repo at: [https://github.com/inconvergent/differential-
line](https://github.com/inconvergent/differential-line)

------
inconvergent
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/](http://inconvergent.net/snek-is-not-an-acronym/) .

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

~~~
inconvergent
i'm glad to hear it!

------
octref
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/](http://inconvergent.net/generative/)

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

------
pka
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?

~~~
inconvergent
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/](http://inconvergent.net/a-method-for-mistakes/).

~~~
pka
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).

~~~
inconvergent
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/](http://inconvergent.net/arbitrary-alterations/). this is so that
i can control the order in which they are applied, eventually.

~~~
pka
> 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-...](http://hypirion.com/musings/understanding-persistent-vector-pt-1)

~~~
inconvergent
this link looks interesting, thanks.

------
kowdermeister
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?

~~~
inconvergent
you manipulate a data structure that contains vertices and edges. there is
more about it here [http://inconvergent.net/snek-is-not-an-
acronym/](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.

~~~
pje
so...snk is a graph?

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

