Tuesday, 23 April 2019

Automata, Chaos and Emergent Behaviour

We were lucky to have Peter Marks visiting Cornwall to lead this meetup on Automata, Chaos and Emergent Behaviour.


Working examples, including code, are online: https://codepen.io/spluko/.


A similar session was already run in London previously, and was written up, so I won't repeat the content but focus on just the key points and differences to that session.


Automata

Mathematicians, scientists and indeed philosophers, often consider whether the natural world and its behaviour can be modelled as a collection of abstract objects following simple rules. Indeed, the justification of modelling real world behaviour isn't even necessary, we can be interested in objects following simple rules just because it is interesting.

Although there are very precise and formal definitions of automata, an informal definition is more understandable. Automata are abstract things - which take input, and follow simple rules to decide their next state, from where they can continue to take more input and continue to evolve.


The word state is just a technical term for the configuration of, and information in, an automaton.

It might be difficult to picture an "abstract" thing. It just means that many kinds of things can be automata - from small robot ants to pixels moving around a screen.

The reason they can be interesting is that from the simple rules can emerge interesting, and sometimes surprisingly sophisticated, behaviour.


Key Principles

Peter structured his talk by progressively exploring the key principles at play when modelling automata - iteration, multiplicity and interaction:

  • Iteration - the repeated application of rules, often mathematical rules.



  • Multiplicity - Creating and evolving many automata.



  • Interaction - Allowing the evolution of automata to depend on other automata, encoded again as the simple rules that define their next state.


Peter illustrated the principle of iteration with an object that just happened to be a circle. The rules that are applied to it increase its size. The state of the object changes over time - the circle grows. Although this example sounds a little laboured, it illustrates the concepts.


Peter proceeded to demonstrate the principle of multiplicity, creating many objects and allowing them to evolve according to the same simple rules.



These particles appear to move along different paths. The rules that apply to them are still the same, the different paths are due to their different initial starting states - they all have different initial speeds and directions (velocity).

Peter the proceeded to the interesting idea of chaos  - the apparent breakdown of a system into randomness. He explained that actually the chaotic systems we were looking at were not random, just so varied in their behaviour that it was had to predict their future state. Chaotic systems are very sensitive to their initial conditions, which contributes ti their difficult predictability.

A good example of a chaotic system is an ink drop falling into a glass of water. The ink molecules are start off in a relatively well defined small space, but then move around the glass in a very unpredictable way, and also along paths very different to molecules they started off as neighbours with.


The following curves are drawn according to positions which evolve in a chaotic manner.


Peter then proceeded to demonstrate the opposite effect - order out of chaos. Particles are created and moved according to the following fairly simple mathematical rules:
xt+1 = sin(a * yt) - cos(b * xt)
yt+1 = sin(c * xt) - cos(d * yt)
The initial impression is that the particles seem to follow a chaotic path with no order or pattern. However, creating many particles and following theirs allows a pattern to emerge.


You can find many more example of these beautiful forms online, here for example: http://paulbourke.net/fractals/peterdejong/, which includes:


Finally, Peter demonstrated automata whose behaviour depended on the state of other automata - interaction. Simple examples include balls that bounce off each other, transferring momentum to each other.

Peter showed how even simple rules can lead to emergent behaviour, for example the self-organising of objects according to their colour.

Before:


After:


More sophisticated example is of boids, where bird-like automata follow rules that encourage them to follow each other by matching velocities, but also not allowing them to get too close, whilst aiming to cohere towards a group or cluster. The resulting behaviour is very similar to birds flocking.



Here is another example showing the boids more clearly, from the processing website.



Conclusion

Peter took us through a well structured tour of automata, starting with very simple and easy to understand examples, and working through the principles of iteration, multiplicity and interaction.

For many, including myself, there is still the sense of excitement, surprise and wonder at how simple rules can lead to both chaos, and also emergent behaviour.

Peter's talk inspired some of the conversation after the session, which broadened out to how nature itself works and the role of simple laws of physics, chemistry and biology governing the emergence of the world we observe!


Tuesday, 16 April 2019

Art Hackathon - "Artificial Emotional Intelligence"

This month's London meetup was not a talk or tutorial but a hackathon.

The theme, to be interpreted freely, was "Artificial Emotional Intelligence".


In setting the theme I had hoped some would consider that, although AI has made huge leaps forward, they have been in the ability to repeat a task, rather than in the ability to interact with humans at an emotional level.


Art Hackathons

The normal format for our meetups is a talk or a hands-on tutorial, but there has always been demand for a session where members just code to create.

I'm not particularly experienced in organising hackathons (- should we use post-its? -) but we've run three before:

  • "Future Pangs" - [blog]
  • "I Want To Believe" - [blog]
  • "In The News" - [blog]


They seem to be fairly well received.


The key features are they everyone works on openprocessing.org so there is a common programming language (javascript and p5js) and an easy ability to share their art and code through a simple we URL.

Some people want to work together with others, some along, and depending on the night, there are a number of more experienced creative coders willing to help others. This is one area I need to organse better.

There are always newcomers and first-time coders. In addition to in-person help, onlien tutorials are helpful too. I'm pleased my own guide has been well received - ignore that it is labelled "for kids":



A unique feature of our art hackathons is setting the mood! We turn down the lights and project a nice ambient nature video with the beautiful but unobtrusive classical music - Gymnopedies 3, Satie.

Creative bliss!


Selected Works

I was again really taken by the broad diversity of interpretations and approaches to the theme. The following are selected works.


Peepl
In the work, the artist has the idea of small bodies moving around the space driven by their own speed and direction. However, when two such "people" come close to each other, they pause from their high speed dash and remain close to each other for a short while - as if having a conversation.


This is an interesting take on particle systems, one I've not seen before.


Colour Mind
In this work, the artists working as a team, developed the idea of taking a canonical list of emotions and using a hash function to convert them into colours.


The work itself presents itself as three buttons which the viewer is impelled to click, resulting in a series of circles, coloured and labelled with one the emotions.


The artists insisted that there was no intended correlation between the colour chosen by the hash function and the meaning of the chosen emotion word. The reason was to place meaning, interpretation, and reaction firmly in the space of the viewer, not the code.



Hamlet's Emotions
In this unique work, the artist has taken the text of Shakespeare's Hamlet and as his code reads it line by line, it picks out key emotive words, and visualises them. The words fall into three categories, broadly strong negative, intermediate, and strong positive.

It is interesting to see this chart grow as the code reads the text.


I particularly liked the graphs at the bottom, which looks like cpu or load monitors, evoking the feeling of a monitor, perhaps a medical monitor, keeping an eye on the emotions in Hamlet as the tale proceeds.



Dots
In this work, the artist started from the particles theme which looks fairly basic but as the particles interact they change and flash.


The code is online, but to run it effectively you should delete the debugging print statement first. I hope the artist continues to work on this code because the ideas are interesting and I think the fruits could be even more interesting.



Cellular Growth
This work is quite striking in how it is presented, growing out from the centre of the canvas.

The patterns formed by the colours seem natural, not entirely random, with a definite organic structure.


Looking through the code, I think I'm right that the pattern grows based on cell creation determined by its neighbours. It reminds me of code I first saw in the 1980s (!) which seemed to magically create detail based on a matrix of neighbouring cells, but following a formula that was sufficiently organic and not-so-random to make it feel natural.

Ben later explained that he wanted to show generations learning how best to communicate with their neighbours. He got as far as cells reproducing and their children taking traits from the parent(s). A cell's traits represent their emotional disposition, shown here by the red/blue colour. His intention was to use a genetic algorithm that learns an optimal way for cells to communicate, and the visualisation to show this learning over generations.

I can see echoes of the artist's previously presented work on grids and game theory!

You can try the code yourself:




(Miro-Like) Shapes
This work I is particularly effective. One one level it simply draws some simple shapes - circles and triangles, and some curling curves.


But the artists careful and thoughtful constraints on the colour palette, on the sizes and orientation of the shapes, the amount of curl and varying thickness of the wavy lines - all combines to create a powerful composition, very reminiscent of the works of Joan Miro.

The code produces different compositions every time it is run - and almost all of them seem to work.


Simple - yet sophisticated!

For me, I the algorithm that draws the swirls is particularly effective and I can't wait to explore the code to see how it works...



Thoughts

The art hackathons are always popular, and the show-n-tells at the end are, in my experience, the best part of the evening. It is inspiring and exciting to see the ideas that others have come up with, even if they haven't managed to finish them in the session itself.

I still feel I need to organise the hackathons better, and would love suggestions. At times they can feel like nobody knows what supposed to be happening. Maybe I can project a schedule of what's happening, and also make very clear that finished work is far from expected.

A useful feedback was to extend the coding time - one hour isn't enough!



I haven't run a creative coding hackathon in Cornwall yet, so that will happen at the next available date.