Joined: Jan 14, 2010 Posts: 6058 Location: Moon Base
Audio files: 728
Posted: Sun Jan 13, 2019 3:10 pm Post subject:
Conway's Game of Life Subject description: and other cellular automata
IT'S ALIVE!
I thought it would be nice to have a general thread to discuss how cellular automata can be used for music and how to create them.
In case you have no idea what I am talking about:
"A cellular automaton consists of a regular grid of cells, each in one of a finite number of states, such as on and off (in contrast to a
coupled map lattice). The grid can be in any finite number of dimensions. For each cell, a set of cells called its neighborhood is defined
relative to the specified cell. An initial state (time t = 0) is selected by assigning a state for each cell. A new generation is created
(advancing t by 1), according to some fixed rule (generally, a mathematical function) that determines the new state of each cell in
terms of the current state of the cell and the states of the cells in its neighborhood." - source: wikipedia
The most well known cellular automaton is probably Conway's Game Of Life. I don't remember when I first came across it
but I have always been intrigued by it. The rule set if very simple:
1. Any live cell with fewer than two live neighbors dies, as if by underpopulation.
2. Any live cell with two or three live neighbors lives on to the next generation.
3. Any live cell with more than three live neighbors dies, as if by overpopulation.
4. Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction.
Despite these simple rules it is capable of creating very complex patterns. The most basic ones die out or end in a stable state but
there are also patterns that oscillate, move across the grid, clone themselves or birth new patterns, reflect or destroy and a whole lot
more. If you want to see some amazing examples go visit the conwaylife forum.
It can also create some nice psychedelic patterns by bending the rules a bit: https://www.youtube.com/watch?v=XVVyjIbypwM
or how about a clock: https://www.youtube.com/watch?v=3NDAZ5g4EuU
So it can be used to create trigger signals and you could use it to create midi data or control voltages but maybe there are other interesting
possibilities. I was thinking that it would also be nice to just use it as a visualizer responding to music. Again this could be done with midi,
triggers, or cv's, maybe something similar to a spectrum analyzer based on frequencies.
Game of Life isn't the only automaton of course and you can create all kinds of rule sets with different results, you can also add dimensions
or use different shaped grids. For those who like to simulate logic circuits there is wireworld. _________________ "My perf, it's full of holes!" SoundCloudBandCampMixCloudTwitchYouTube The Golden Shrimp Guild
Joined: Jan 14, 2010 Posts: 6058 Location: Moon Base
Audio files: 728
Posted: Sun Jan 13, 2019 4:15 pm Post subject:
ah so the wren version is multi purpose, that is of course a big advantage with software you can 'easily' add a lot of functionality and quickly test what works.
Joined: Jan 14, 2010 Posts: 6058 Location: Moon Base
Audio files: 728
Posted: Sun Jan 13, 2019 7:56 pm Post subject:
* this is probably going to be one of those long posts that hardly anyone understands or cares to read, but I'll give it a try *
One reason I started this thread is of course because I'd like to make a hardware version of Conway's Game of Life. It's been brewing in the
back of my mind for a while and I couldn't resist any longer. The most efficient way of doing it is with a microprocessor and I'll probably do that
but I was curious what it would take to make it without one. The idea is to make single cells with 8 inputs and 1 output that can be linked together.
Initially I thought of using logic chips, it is afterall just 0's and 1's. Synchronization is easy to do with a latch before the output so all cells can be
clocked from a single source, although it could also be interesting to make an asynchronous version so each cell has a build in oscillator with a
different frequency. However, decoding the 8 inputs is not that easy or at least takes quite some logic gates to accomplish. I did figure out a way
to do it with some adders and also found some similar circuits here. Another way would be to use some logic gates to link a couple of muxes together
which gives the option of changing the rule set. You need a lot more than 1 cell to actually make it useful though so the circuit should be very small
and that's just not going to work with pure digital logic.
There is another way that I had been thinking about which is analog. The hardest part to do digital is to determine how many inputs are high
for which you need a majority gate. Analog this is quite easy to make with a resistor network and a comparator or in this case 3 of them.
So that's what I did and I came up with a working circuit
Version 1 was the first working idea and version 2 is a further developed even smaller one but the input section is the same on both. The 8 inputs
(from neighboring cells) are each connected to a resistor network that forms a voltage divider with a 9th resistor to GND. I initially added this resistor
because I was thinking of using diodes on the inputs but it turned out to be very useful when calculating the appropriate resistor values. For every
input that is high the output voltage of this network rises by 1/9 * V. With all the inputs low the output is 0/9 * V, with 1 input high it is 1/9 * V,
with 2 inputs high it is 2/9 * V, etc all the way up to 8/9 * V. (The circuit is designed for signal voltages that are the same as the supply voltage 'V'
but since it is all about ratios the actual value of this voltage doesn't really matter)
I slightly rewrote the rules (but they function the same) which translates into 4 useful voltages:
< 2/9 * V: Any cell with fewer than two live neighbors dies.
= 2/9 * V: Any cell with two live neighbors doesn't change state (lives on, or stays dead)
= 3/9 * V: Any cell with three live neighbors lives (lives on, or becomes a live cell)
> 3/9 * V: Any cell with more than three live neighbors dies.
3 comparators are needed to turn these 4 voltages into useful (digital) signals.
These are configured in such a way that the treshold levels lie exactly between 2 of the voltages for reliable triggering.
the first comparator (U1d) triggers when the voltage is between 1/9 and 2/9, which is 3/18 * V
the second comparator (U1c) triggers when the voltage is between 2/9 and 3/9 which is 5/18 * V
the third comparator (U1b) triggers when the voltage is between 3/9 and 4/9 which is 7/18 * V
just for "fun" let's use a voltage of 5V
0 inputs high 0/9 * 5 = 0V
1 input high: 1/9 * 5 = 0.56V
- first comparator triggers at 3/18 * 5 = 0.83V
2 inputs high: 2/9 * 5 = 1:11V
- second comparator triggers at 5/18 * 5 = 1.39V
3 inputs high: 3/9 * 5 = 1.66V
- third comparator triggers at 7/18 * 5 = 1.94V
4 inputs high: 4/9 * 5 = 2.22V
5 inputs high: 5/9 * 5 = 2.78V
....
To create the correct voltages for the treshold levels the resistors need to have a ratio of 3/18, 2/18, 2/18, 11/18,
which is very convenient because the E24 series contains resistors of 30K, 20K and 110K (33K, 22K, 120K should also work fine)
This results in the following bits (for version 1):
- less than 2 live neighbors: 000
- exactly 2 live neighbors: 001
- exaclty 3 live neighbors: 011
- more than 3 live neighbors: 111
All that's left is to translate these signals to a 0 or 1 according to the rules and my first idea was to use a mux for this:
000 -> 0
001 -> depends on the current state so the output of the cell is fed back into this input of the mux.
011 -> 1
111 -> 0
The output of the mux is then fed into a latch so that a new state appears on every low to high clk transition. Because it is important
that the output stays as close to the supply voltage as possible I connected the LED to the /Q output so that it doesn't cause a voltage
drop on the Q output. (The LED goes on when /Q is 0). Using a transistor as a buffer would be a nicer solution but I tried to keep the
component count as low as possible.
Although version 1 works I couldn't shake the feeling that there might be a way to do it without the mux, maybe by using the spare latch
and/or comparator.
I had to bend my mind a bit but today I figured it out
Note that for version 2 the inputs of the 3rd comparator are swapped which results in:
- less than 2 live neighbors: 100
- exactly 2 live neighbors: 101
- exaclty 3 live neighbors: 111
- more than 3 live neighbors: 011
however, this isn't really true as the comparators have an open collector output, so it's actually:
- less than 2 live neighbors: X00
- exactly 2 live neighbors: X0X
- exaclty 3 live neighbors: XXX
- more than 3 live neighbors: 0XX
(X is a floating state)
A nice thing with open collector outputs is that you can connect them together without shorting the outputs. Comparators 1 and 3 are directly
connected together and with the pullup resistor and diode on the output of comparator 2 this results in the following states:
- less than 2 live neighbors: 0
- exactly 2 live neighbors: X
- exaclty 3 live neighbors: 1
- more than 3 live neighbors: 0
The output from the cell is also connected to this point through a resistor so when the output of comparators 1 or 3 is low it is pulled to GND
and when the output is floating (exactly 2 live neighbors) it is whatever the current output state is. When it is pulled high by the resistor on
the output of comparator 2 it forms a voltage divider with the resistor feeding back from the output which results in a level between 0 and 1
if the output is low. This is why the extra comparator (U1a) is used. The output of this comparator is connected to the latch as in version 1.
but wait there is more,..
Because there was still an unused latch I wondered if it could be used to make a switch that can toggle the cell between dead or alive with
a single button for programming the initial state. The idea being that you could make cells with illuminated push buttons. This got a little bit
more complicated than I hoped because the latch remains in the last state it was set and doesn't follow the output. So if the last state was 0
and the ouput of the cell is 0 nothing happens, neither would it work if both are 1. To solve this I added 2 AND gates made with diode logic.
In practise it is still not efficient because you need quite a lot of cells and its use is very limited compared to what you can do with a microprocessor.
The costs can also go up pretty fast. I think a cell might be doable for about 2,- maybe a bit more with a dedicated PCB although those can be pretty
cheap when kept small and this would be a nice circuit for SMD components. But with a 8x8 matrix this already adds up to 128,- (without fancy
illuminated buttons) compared to say an arduino with an 8x8 led matrix which could be done for < 5,- which is also a lot smaller. Not to mention that
so far it only lights up some LEDs so if you want to use it for music you need some extra circuitry.
I am still a bit tempted to create a very small matrix though but I am not sure yet how to connect cells together without using jumper wires,
I think you'd need some sort of octagon or circular shape, on the other hand jumper wires might look nice (but it needs a lot).
Of course you could also make cells with a single microprocessor each or even better the kits that adafruit sells which can be linked and each have
a 4x4 matrix. This also solves the problem of how to connect them without jumper wires. But in the end a single microprocessor will be the most
efficient and versatile option. I do have another idea though which I might actually be able to build and doesn't require a microprocessor but I
need to bend my mind a bit further to figure out if it is possible.
TL;DR I designed a circuit for Conway's Game of Life cells which can be linked together and now I need a cup of tea.
Conway's Game Of Life cell V1.gif
Description:
Filesize:
70.88 KB
Viewed:
915 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.
Conway's Game Of Life cell V2.gif
Description:
Filesize:
69.95 KB
Viewed:
946 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.
Really nice idea!
I have been pondering about something similar for quite some time now, but mostly the ideas didn't work out, but I'm still playing with the idea of having a melodic sequence that is more or less defined by the preceding chord(s) added with some form of randomness.
Like HERE _________________ my synth
Joined: Jan 14, 2010 Posts: 6058 Location: Moon Base
Audio files: 728
Posted: Mon Jan 14, 2019 8:52 am Post subject:
@Grumble
interesting, I hadn't seen that thread. I only read the first post sofar but I think I understand what you are trying to do.
Very similar to something I'd like to do which is have something create semi-random melodies that actually sound musical
based on a set of rules (I see how it ties in with this). Instead of something simple like the game of life the new note(s)
would be based on several previous iterations instead of just the last one. It would probably also require some sort of repetition.
The rules would be based on musical theory which is where I'd get stuck at the moment as I don't know enough of it.
If I did I would actually know what keys to press when jamming In that regard it reminds of making a cheat sheet for
a school test (which I never did of couse) where you learn by creating it so that you don't actualy need it anymore once finished.
One of the things I would love to do is my own (automated) interpretation of Crater Dust.
It would also be nice to do this with a couple of people where everyone creates a patch or system that plays it and they all
get mixed together live. You could even send something like midi data over the internet so they can somewhat communicate
with eachother.
@Blue Hell
Thanks for taking the time to read, I hope there was something inspiring in there
crater dust, never heard of it, there are sound files here at E.M. and I am listening right now. Great drones....
I would love to make drones, but I can’t find the right patch on my synth to make a satisfying drone right now
Also something to look at: http://www.hooktheory.com/blog/chord-progression-search-patterns-and-trends/ _________________ my synth
Joined: Jan 14, 2010 Posts: 6058 Location: Moon Base
Audio files: 728
Posted: Tue Jan 15, 2019 12:32 pm Post subject:
to clarify,
The Moore neighborhood counts 8 neighbors which can be written down as a byte where a 1 represents a live cell.
I mapped the numbers from 0 to 255 on a 16x16 grid (top left to bottom right) and colored the cells according to the number of live neighbours.
"Life in Gray" uses the same map but with Game of Life rules applied. Dark gray = dead cell, ligh gray = life cell and in between are the
"Schrödinger" cells.
I was curious what it would sound like so I thought about converting the colored map to a control voltage, where each color is a different voltage.
Initially I was thinking I needed an arduino and a DAC untill I woke up and realized I only needed a binary counter and a resistor network.
So that's what I did and I used Mutable Instrumets' Rings as a voice.
PHOBoS - A walk through the Moore neighborhood.mp3
I have been fascinated with this cellular automata and cybernetics stuff for years, although I never really understood it much. I like the idea of a "living" circuit that could generate music by itself. In fact, I see Lunettas a bit like that... even though they are based on logic circuits (which also fascinate me), one can have complex patterns.
(pure randomness is not very interesting musically, a certain amount of repetition and variation is)
A couple of years ago I was sketching some ideas using a network of 3-input logic gates made with the 4051 LUT circuit (also discovered by JingleJoe as the 4051 ANY gate), and triangles and vertices of platonic solids. But then I realized that the system was fixed and would produce no variation ever, so I abandoned the whole thing.
There was a simple XOR chain circuit that I used in a Lunetta thing. It was by "ezekiel" over on the former The Sound of Logic forum, and it apparently implemented Wolfram Rule 90 C.A. That's the closest I got and ever will get to implementing any C.A. stuff.
But I will enjoy seeing/hearing what you people come up with.
Joined: Jan 14, 2010 Posts: 6058 Location: Moon Base
Audio files: 728
Posted: Thu Jan 17, 2019 8:12 am Post subject:
yeah it can be tricky to find a nice balance between pure random and structured. I guess the mind likes patterns but also surprises.
When I make music on a computer I often try to add variations between every measure. Not so much that it's all over the place
but just enough to keep it interesting without being too prominent.
Quote:
I like the idea of a "living" circuit that could generate music by itself
.
If you take the "living" part a bit too literal you'll end up with cellF
Joined: Jan 14, 2010 Posts: 6058 Location: Moon Base
Audio files: 728
Posted: Fri Feb 01, 2019 9:02 am Post subject:
PHOBoS wrote:
I do have another idea though which I might actually be able to build and doesn't require a microprocessor but I
need to bend my mind a bit further to figure out if it is possible.
This other idea was using an EPROM since I now have a lot of those (thanks jan )
Decoding the inputs to the appropriate output state according to the game of life rules is easy to do, it's pretty much just the data from "Life in Gray".
What I wondered about is if I could also put the latch function in it by feeding back some data outputs to the address inputs. Does that work ?
Well, yes and no. I did some experiments and kept getting some weird oscillations. Initially I thought I might have made an error somewhere and had
two addresses pointing to eachother but that wasn't the case. I am not exactly sure what causes it but I though it might have something to do with the
slew rate of the outputs which causes the input to get a state between 0 and 1. So I tested with putting some schmitt triggers between the outputs and
inputs and that did indeed get rid of the oscillations. However the idea was using just an EPROM without any need for an extra chip so if I need some schmitt
triggers I might aswell just use a latch instead. I tested this aswell and that works fine but needing an EPROM and a latch per cell does get a bit too silly.
I think I should be able to do 4 cells with a single 512Kb EPROM though and I do have a bunch of octal latches aswell (thanks jan ). Of course you still
need a lot of them but maybe someday I design some PCB's and actually build it as some sort of art project.
For now I switched to an arduino and an 8x8 LED matrix. I did some tests with it creating simple midi note on/off signals and the next thing I want
to add is a midi input. The idea being to have some sort of game of life based arpeggiator where you play some notes and it generates new notes from
it. I am not sure yet how to implement it as you need a couple of cells to be turned on that are next to eachother otherwise they just die out. I guess
I could have it generate different 'sprites' for each note. _________________ "My perf, it's full of holes!" SoundCloudBandCampMixCloudTwitchYouTube The Golden Shrimp Guild
What I've found useful additions for generating music :
- add a fault rate, every so often flip the result of the calculation, this will cause a stuck pattern to eventually continue.
- count the live cells, and when that drops below a certain number fill the grid at random with :
- a controllable random density.
- make row outputs on each of the rows of the grid, and run a cursor over that grid from left to right. Whenever the cursor hits a live cell it will output a pulse on the row output. This will give you as many inter-related pattern sequencers as you have rows. (and could add column patterns too with some logic combination on the cell values)
- Sum the number of live cells in each column, and run a cursor over the grid. Whenever the cursor steps calculate the sum of live cells in the column. Some rules can then be applied to that sum .. I have linear sum, exponential sum (like an R2R networrk on the column cells), lowest index, average index, etc. This will be nice to control pitch or cutoff frequency. And could add row sumes too).
- there are alternate rules as well, like : highlife, daynight, 2x2, 34life, amoeba, gnarl, seeds, serviettes, stains, pseudo, move, starwars, inverse (pixel color inversion), and more .. use google :-)
- A reverse input, to reverse the cursor direction.
- You may want to make a toroid out of the grid by connectiong top to bottom and left to right, so when stuff runs off it will come back on the other side.
- When doing a software version its easy to make a large game, but it could be interesting to set a limited number of rows / columns to be actually used.
Joined: Jan 14, 2010 Posts: 6058 Location: Moon Base
Audio files: 728
Posted: Sat Feb 02, 2019 12:10 pm Post subject:
Thanks for all the useful tips
Quote:
count the live cells, and when that drops below a certain number fill the grid at random
I was thinking of testing how many cells have changed which would get rid of stuck patterns and empty grids. When I counted the number
of live cells I noticed that this does mostly change all the time so that makes it easier to do. So now I just set a limit to the number that the
amount of live cells repeats. (+ a minimum of live cells)
Quote:
a controllable random density
15% seems to be the lower limit before cells die out to quickly, at least with a an 8x8 grid and no wrapping. 25% works nice.
Here's the result of a very simple implementation that simply converts the number of live cells to a note. Not the most interesting thing
to do with it but it gave me some nice music combined with a lightshow. (I am thinking of adding a kaleidoscope mode). I also added
some extra repeating notes. All sounds come from the Proteus 2000 (thanks bob )
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum