Wednesday, June 26, 2013

Simmunity: A New Game of Life

Simmunity: A New Game of Life

Conway invented the Game of Life in 1970; A "zero-player"game which demonstrated that a complex and sophisticated system can be created by a simple set of rules on a cellular automaton given only its initial condition. It is one of the most amazing AI experiments I've studied.

I was inspired by an entry in the list of Under Graduate Research Projects by CS Department of the Princeton University, to build a variant of Conway's Game of Life to Simulate an Immunity System [which has been now removed in recent updates; someone may have done it or it may have become archaic, don't know].

I then began studying about Conway's Game of Life and it's extrapolated conclusions on Evolutionary Science. A simple program with a beautiful visual display with a nostalgic video-game style simulation, made me very happy and interested to do this project. It's graphic display would also be a good project to show-off to non-computer science people. And, thus began my journey.

On the way, I found a lot of knowledge missing in me and had to improvise to generate, share and visualize the Immunity System as a Game of Life. I did not have enough know how to build GUIs in Java (one of my strong and comfortable languages) and thus had to generate universe matrix in Java and then write them to text files in CSV(Comma Separated Values) format. This CSV was next read by a MATLAB program and visualized in a colored grid. The series of grids were saved as frames and animated to show each step of change in the universe step-by-step.

The Rules of Simmunity are:

  1. Regeneration Step: 10% RBC (Red Blood Cells) are regenerated in a random fashion in empty places (i.e occupied by Blood-Plasma) after every step.
  2. Regeneration Step: 10% WBC (White Blood Cells) are regenerated in a random fashion in empty places (i.e occupied by Blood-Plasma) after every step.
  3. Pathogen Spread Step: Pathogen (denoted by black in the graphics grid) eats and replaces (i.e.copies itself in) any one of the 8 neighboring adjacent cell if populated by an RBC.
  4. WBC Spread Step:  WBC eats and replaces (i.e.copies itself in) any one of the 8 neighboring adjacent cell if populated by Pathogen.
  5. Starvation Death Step:  When a Pathogen cell is not surrounded by any RBC for more than three steps/iterations the Pathogen dies to leave Plasma (empty cell) behind.
  6. Starvation Death Step:  When a WBC is not surrounded by any Pathogen cell for more than three steps/iterations the WBC dies to leave Plasma (empty cell) behind.
  7. Natural Death Step: A RBC dies after a few iterations simulating natural death of RBCs.

 The Outcomes:

The body/system/universe heals successfully or fights off the disease/infection and no pathogen is left in the system. The WBC and RBC attain maximum levels flooding the universe and then attain an equilibrium of death and regeneration.

 OR

The body/system/universe succumbs to the disease and the pathogen spreads to dominate the universe for the stipulated number of iterations. Note: The body/system/universe will recover in later steps when the pathogen starts dying out of starvation and regenerating WBC will strike back with a vengeance. Also the RBC count will increase by regenration.

OR

The fight is still going on and the stipulated number of steps by the user has to be increased.

Additions:

I later added the facility to choose the size of the universe (i.e. grid/matrix) and the number of steps to be iterated. Another MATLAB program, I wrote, would count the number of RBCs, WBCs, Blood-Plasma(water) and Pathogen(virus etc) and record its step by step statistics which would be displayed as a net graphical outcome of the set of rules applied to the system and observe outliers or deviations.

***Addendum***

 I recently re-run my Simmunity program and found a few of my folders misplaced from the Desktop which may cause trouble. Thus, I'm adding this note here;
"You need to create a Directory called SIMMUNITY on the Desktop with two sub-directories, Outputs and Universes Collection."
 The Outputs sub-directory will contain FirstStat.txt and SimData.txt files auto-generated by the Java AI program. These contain a CSV matrix for processing by Matlab M-Files. The Universes Collection sub-directory will contain a Random Universe.txt file that will contain the size of the simulated cellular universe (i.e the grid or matrix) for the Matlab M-Files to run loops accordingly and create a simulation. You do not need to create these text files.

Screen Shots: 




 Download Source Code:

*Comments/Critiques are welcomed and appreciated.

No comments:

Post a Comment