cellular automaton Fische; const dimension = 2; distance = 1; type animaltype = (none, exists, accepted); type celltype = record dir: celladdress; animal: animaltype; farbe: (lila, gelb, gruen, rot); end; global phase : (move, turn, choose); const cell = (*[0, 0]); const constantcell = [0,0,none,0]; initial [0,1,exists,random(3)] ~ prob(0.05) and option = 0; initial [1,0,exists,random(3)] ~ prob(0.05)and option = 0; initial [0,-1,exists,random(3)] ~ prob(0.05) and option = 0; initial [-1,0,exists,random(3)] ~ prob(0.05)and option = 0; initial [0,1,exists,random(3)] ~ prob(0.5) and x < 3*lx/5 and x > 2*lx/5 and y < 4*ly/5 and option = 1; initial [0,-1,exists,0] ~ (((x+y)mod 2) = 0) and prob(0.8) and x < 2*lx/5 and x > 0 and y < 3*ly/5 and option = 2; initial [0,1,exists,1] ~(((x+y)mod 2) = 0) and prob(0.8) and x > 3*lx/5 and x 2*ly/5 and option = 2; initial [1,0,exists,2] ~ (((x+y)mod 2) = 0) and prob(0.8) and y < 2*ly/5 and y > 0 and x > 2*lx/5 and option = 2; initial [-1,0,exists,3] ~(((x+y)mod 2) = 0) and prob(0.8) and y > 3*ly/5 and y abs(sumy) then begin cell.dir.x := sign(sumx); cell.dir.y := 0; end else begin cell.dir.x := 0; cell.dir.y := sign(sumy); end; end; if prob(0.01) then begin cell.dir.x := cell.dir.y; cell.dir.y := -cell.dir.x; end; if cell.dir = [0,0] and prob(0.1) then begin rand := random(3); case rand of 0: cell.dir := [0,1]; 1: cell.dir := [0,-1]; 2: cell.dir := [1,0]; 3: cell.dir := [-1,0]; end; end; end; if (phase = choose ) then begin // phase = choose if cell.animal = none then begin cell.dir := [0,0]; // Now can accept animal from another cell. if (*[0, 1].animal=exists and *[0, 1].dir = [0, -1]) then begin cell.animal := accepted; cell.dir := [0, -1]; cell.farbe := *[0, 1].farbe; end; if (*[0, -1].animal=exists and *[0, -1].dir = [0, 1]) then begin cell.animal := accepted; cell.dir := [0, 1]; cell.farbe := *[0, -1].farbe; end; if (*[1, 0].animal=exists and *[1, 0].dir = [-1, 0]) then begin cell.animal := accepted; cell.dir := [-1, 0]; cell.farbe := *[1, 0].farbe; end; if (*[-1, 0].animal=exists and *[-1, 0].dir = [1, 0]) then begin cell.animal := accepted; cell.dir := [1, 0]; cell.farbe := *[-1, 0].farbe; end; end; end; end; rule global begin phase := next(phase); end;