Author Topic: Observations of Cellular Automata simulating particles  (Read 12167 times)

0 Members and 1 Guest are viewing this topic.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Observations of Cellular Automata simulating particles
« on: November 18, 2012, 06:20:34 pm »
I long while ago, when I was working on Grammer and adding in the particle effects stuff, I added this particular ruleset:

Move down if the space below is unoccupied
Move left or right if the previous move was not possible
Move up if none of the other moves were possible

If you remove the last rule, the particles move kind of like a liquid. The reason that I added the last rule was to allow the particles to navigate obstacles. Otherwise, this happens:


A real liquid would have "leveled out" so to speak. My thought was that adding the ability to move up would result in more properties of a liquid, including fixing this problem. So, lets see how it worked:


I decided to try another method by letting the particles always be connected to a specific particle. This way, in order for one to move, they all had to go in the same general direction:

I called them worms and they could do some pretty cool things, such as exhibit capillary action. However, this is very clearly not working like a liquid (Well, if you got a bunch of worms together, it probably would act very much like a liquid, except that they can crawl up each other with no external support!)

However, though it isn't as fluid as the worms, the ruleset I originally gave also exhibits capillary action:


Anyways, I thought I would share this :) If you can think of other cool effects, feel free to share !

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: Observations of Cellular Automata simulating particles
« Reply #1 on: November 18, 2012, 07:07:20 pm »
I love the improved water CA sim. One thing I've been screwing around with is this:

A langton's ant-style CA, where each cell stores a state with only one moving, but you also consider whether the given Y-coord and X-Coord are odd or even.

Code: [Select]

All occasions toggle the state of the cell. If they didn't it would get stuck on certain values.

           #X%2 Y%2 S
move right #0   0   1
move down  #0   1   1
move left  #1   0   1
move up    #1   1   1
move left  #0   0   0
move up    #0   1   0
move up    #1   0   0
move down  #1   1   0

It gives an interesting pattern as a result. When even dimensions, it will draw vertical lines, then erase them. When odd dimensions, it does the same thing, but with some chaos introduced.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Observations of Cellular Automata simulating particles
« Reply #2 on: November 19, 2012, 01:08:29 am »
Wow those screenshots looks nice. Two of them almost looks like you're simulating Pepsi/Coke O.O

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: Observations of Cellular Automata simulating particles
« Reply #3 on: November 19, 2012, 01:38:18 am »
I wonder what it would look like to have a physics object like a box hit that water.

Offline ralphdspam

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 841
  • Rating: +38/-1
  • My name is actually Matt.
    • View Profile
Re: Observations of Cellular Automata simulating particles
« Reply #4 on: November 19, 2012, 03:18:39 am »
These look really neat!  Someone should really make a game based on the capillary action...
ld a, 0
ld a, a

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Observations of Cellular Automata simulating particles
« Reply #5 on: November 19, 2012, 04:43:16 am »
That kind of physics stuff can't stop to amaze me, it's really cool ! (for such small ruleset !)

these "fuild" mechanics reminded me of a simulation ported to nspire (3.2, because physics) : https://github.com/slembcke/Chipmunk-Physics/blob/master/Demo/Buoyancy.c

My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Observations of Cellular Automata simulating particles
« Reply #6 on: November 19, 2012, 07:14:05 am »
I was going to do a simulation where there were several particles (one grayscale, the other black, so you could distinguish between the two. You could have a simple fluid one, plus the modified rule and I believe they should interact pretty nicely. If I were to drop a box, there would be no splash (the rules do not take into account transfer of energy), but it would probably sink in the "Pepsi/Coke" one and stay afloat in the other one :D

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: Observations of Cellular Automata simulating particles
« Reply #7 on: November 19, 2012, 12:56:50 pm »
By the way, the fact that it just happened to exhibit capillary action is pretty cool. :D

How much is surface tension reflected? :P The worms might do well at that.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Observations of Cellular Automata simulating particles
« Reply #8 on: November 19, 2012, 01:13:50 pm »
It would be very cool to see how the worms react with an object affected by gravity :D As to surface tension, the rule that has capillary action would exhibit good surface tension under certain conditions (the object would need to be big enough), otherwise, it would sink. It would also need to be flat, because if it was pointed, the particles would move out of the way. However, with just the sand/water rule, the surface tension would basically be "perfect" meaning nothing would be able to pass through it. If I added in a way to transmit energy and momentum between particles, that would help things out, too. Lat week, I gave a presentation (it only went about 70 minutes) on cellular automata and in it I described a ruleset that I still need to test. It works like this:

Take all the rules from the "pepsi/coke" ruleset and add in the following:
If the particle didn't move, add 1 to its "energy" level. Then, on the next cycle, check the pixel below. Even if it is black, if the energy level of the pixel below is smaller, swap the two coordinates. Otherwise, check left or right with the same conditions, and then finally check up.

That should cause currents in the particles and it could transfer energy to blocks pretty easily (every time it collides with a block, take a single energy unit and give it to the block, giving it some momentum and possibly buoyancy). It would also maintain capillary action. My hope is that this will give more relatable effects, even if it isn't true to nature :) I imagine that waves and whatnot would be possible, and if energy is only lost to the environment, this would cause a "splash" effect if you drop a bunch of particles at once.

Meh, I really need to find time to actually test this stuff :[

Offline ruler501

  • Meep
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2475
  • Rating: +66/-9
  • Crazy Programmer
    • View Profile
Re: Observations of Cellular Automata simulating particles
« Reply #9 on: November 19, 2012, 01:16:30 pm »
I'd love to see how this works. I've never real done much cellular automata but it seems interesting
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: Observations of Cellular Automata simulating particles
« Reply #10 on: November 19, 2012, 08:53:10 pm »
* shmibs decided to give it a shot as well.
this uses a random insert to avoid too much in the way of predictable patterns. it's not as good at evening out, but it doesn't look as fizzy either.
Code: [Select]
:.A
:DiagnosticOff
:Fix 5
:ClrDraw
:ClrDrawr
:Full
:For(L,0,713
:95→{L1+L}End
:0→A→B→C+1→E
:Repeat getKey(15)
:.D
:If getKey(3)
:→E
:A<95+A→AEnd
:If getKey(2)
:→E
:A-(A>0)→AEnd
:If getKey(1)
:→E
:B<63+B→BEnd
:If getKey(4)
:→E
:B-(B>0)→BEnd
:If E
:If getKey(48)
:Pxl-Change(A,B)r
:0→E
:End
:End
:If getKey(55)
:ClrDrawr
:End
:.END D
:
:RecallPic
:.DRAW/MOVE
:For(L,0,356
:L*2+L1→S
:{S}→T
:{S+1}→U
:
:If T<96 and (U<64)
:!If pxl-Test(T,U+1
:U++
:Else
:If pxl-Test(T+1,U) and pxl-Test(T-1,U
:U--
:Else
:!If rand^4
:U--
:End
:rand^3-1+T→T
:End
:End
:
:!If pxl-Test(T,U
:T→{S}
:U→{S+1}
:End
:Pxl-On(T,U
:End
:
:End
:.END DRW/MV
:
:.ADD
:If getKey(54)
:!If pxl-Test(A,B
:rand^357*2+L1→S
:If {S}>95 or ({S+1}>63)
:A→{S}
:B→{S+1}
:End
:End
:End
:.END ADD
:
:Pxl-Change(A,B)
:DispGraphClrDraw
:End

oh, and how exactly did you manage those worms, xeda?
« Last Edit: November 19, 2012, 08:54:57 pm by shmibs »

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Observations of Cellular Automata simulating particles
« Reply #11 on: November 19, 2012, 09:00:36 pm »
That's pretty cool :D

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: Observations of Cellular Automata simulating particles
« Reply #12 on: November 20, 2012, 02:00:44 am »
The fiziness is actually quite realistic. We just happen to be looking at very, very small amounts of water. Fish breathe the 'fizz' in real water.

You know what this needs? Fancy CG shaders and stuff.

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Observations of Cellular Automata simulating particles
« Reply #13 on: November 20, 2012, 05:47:18 am »
Are you hinting at the 84C? :P
I'm not a nerd but I pretend:

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Observations of Cellular Automata simulating particles
« Reply #14 on: November 20, 2012, 08:11:49 am »
The worms were pretty simple. All I did was make a small buffer for each worm (if it was 35 units long, use a 70-byte area). Then, get the coordinates of the tail, Pxl-Off( at that coordinate, then shift all of the coordinates down 2, get the coordinate of the head and do the same rules as the fizzy effects (move down if possible, move left/right if it couldn't move down, move up if there are no other options). Here is an older screenshot: