Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /branches/lamont/test/life-global.diderot
ViewVC logotype

View of /branches/lamont/test/life-global.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2354 - (download) (annotate)
Sun Apr 7 05:22:22 2013 UTC (6 years, 3 months ago) by glk
File size: 1159 byte(s)
Life, with iter as global
input int iterMax = 50;
int sizeX = 640;
int sizeY = 480;
real rr = sqrt(2)+0.001;

//field#0(2)[] init = tent ⊛ image("../data/life-ggun.nrrd");
field#0(2)[] init = tent ⊛ image("../data/life-breeder.nrrd");

int iter = 0;

// ============================ begin setting up gridding of domain
vec2 xDom = [0,sizeX-1];
vec2 yDom = [0,sizeY-1];
real xSamples = floor((xDom[1] - xDom[0])/rr);
real ySamples = floor((yDom[1] - yDom[0])/rr);
vec4 qWinDim = [xDom[0],xDom[1],yDom[0],yDom[1]];
vec2 qGridDim = [xSamples,ySamples];
vec2 qCellDim = [(xDom[1] - xDom[0])/xSamples,(yDom[1] - yDom[0])/ySamples];
// ============================ end setting up gridding of domain

strand cell (vec2 pos0, int val0) {
  vec2 pos = pos0;
  output int val = val0;

  update {
    if (iter >= iterMax)
      stabilize;
    int nn = 0;
    foreach (cell c in sphere(rr)) {
      nn += c.val;
    }
    val = (1 if (3 == nn) else
           (val if (2 == nn) else
            0));
  }
}

global {
  iter += 1;
  print("iter = ", iter, "\n");
}

initially [ cell([ii, jj], 1 if init([ii,jj]) > 0.5 else 0)
             | jj in 0..sizeY-1,
               ii in 0..sizeX-1 ];

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0