Tuesday, January 15, 2013

Units

A friend has queued me in on cellular automata.
https://scimusing.wordpress.com/2013/01/14/sunday-project-one-dimensional-cellular-automata/

I don't like to call them cells because these "cells" can actually represent anything so I guess I will refer to them as "units". The first interesting hurdle I have come to is how do two of these units interact. They have a basic function i.e. moving around an xy plane and then happen to try and occupy a space that either another unit occupies or the same space another unit is trying to occupy at the same time. What to do?

There is a simple answer. The interaction either causes something to happen or it does not. Simple. But the interaction can be slightly more complex than that. Say we are talking about proteins then we can say, the interact either effects the Boltzmann distributed state of the protein or not. How much? Do I really want to give each unit a distribution of states akin to the partition function?

What about ion diffusion? Can I recapitulate ion diffusion to the extent that I can make a self-organizing system? I guess that is basically what molecular dynamics tries to do but I guess I am trying on a simpler level.

I think I need to setup a goal for these units and then give them choices and figure out how simple systems solve problems. How they communicate.. &c.

I know everyone hates Perl but go cry to your mommy here is the basic outline code I am thinking about:


#!/usr/bin/perl


# $grid[256][256];

$grid[0][2] = 5;

print "$grid[0][2]";

for($a = 0;$a < $numcells;$a++)
{

  $x = int(rand(255));
  $y = int(rand(255));
  $grid[$x][$y] = 1;
}

for($b = 0;$b < $rounds;)
{
  for($gridx = 0;$gridx <= 255;$gridx++)
  {
    for($gridy = 0;$gridy <= 255; $gridy++)


    {
      if($grid[$gridx][$gridy] == 1)
      {
        $randx = int(rand(2));
        $randy = int(rand(2));
        $grid[$gridx][$gridy] = 0;

        switch($randx)
        {
           case 0:
           case 1:
           $gridx++;
           case 2:
           $gridx--;
        }

        switch($randy)
        {
           case 0;
           case 1:
           $gridy++;
           case 2:
           $gridy--;

        }
        if($grid[$gridx][$gridy] == 1)
        {
          #what to do if someone is already here?
        }
      }
    }
  }
}