ライフゲーム #17

次に、画像化用の属性を付与するフィルタvis_alive.gを変更する。

vis_alive.g
BEGIN {
  if (ARGC != 1) {
    printf(2, 'usage: gvpr -cf vis_alive.g -a size\n');
    exit(0);
  }

  double size = ARGV[0];
  if (size <= 0) {
    printf(2, 'error: size must be positive value: %f\n', size);
    exit(0);
  }
}

N [alive] {
  fillcolor = 'blue';
  style = 'filled';
}

N {
  width = size;
  height = size;
  shape = 'box';
  color = 'grey';
  pos = sprintf('%f,%f!', xOf(name) * size, yOf(name) * size);
}

E {
  style = 'invis';
}
gvpr -f gen_mesh.g -a 6,6 | gvpr -c "N[name=='1,1'||name=='1,2'||name=='2,1'||name=='2,2'||name=='3,3'||name=='3,4'||name=='4,3'||name=='4,4']{alive=1;}" > beacon_0.gv
gvpr -cf vis_alive.g -a .1 beacon_0.gv | neato -Nlabel="" -T png -o beacon_0.png

Beaconパターン。

ImageMagickのconvertでanimated GIFに変換してみた。

ぴこぴこ。