ã¯ãã°ãæ»è³ããå¸é½ã«ãããã¡ãMozilla24ã«åå ãã¦ãã¾ãããåå ããã¿ãªãããã¤ãããã¾ã§ããã¼ãããããªæ¹é¢ããããããããªäººããã¦ãã¨ã¦ããããããã£ãã
ååºæã£ã¦è¡ããªããã¦ç³ã訳ãªãã£ããã§ããã"ã¯ãã¹"ã¨ã"hakobe"ã¨ã id:hakobe932ã¨ãåä¹ã£ã¦ããã¯ãã¡ã§ããããä¼ãããã¿ãªããã楽ããã£ãã§ããã¾ãããä¼ãããæã¾ã§ã
ä»åã¯ãä¸è¬åå è ã¨ãã¦ç©è¦éå±±ã¨æ±ºãã¦ããã£ã¦ããã®ã§ãããæ¥é½LiveCodingã«Coderã¨ãã¦åå ãããã¨ã«ãªãã¾ããããã¾ãã«æ¥é½ããã¦ããã¬ãã·ã£ã¼Ãã®ãã©ã°ã常ã«ç«ã£ã¦ããããã¡ã¨ãã¾ãã¦ã¯ããã³ããä»ãªããããããã¨è¿·æãããã¦ãã¾ãã¾ããããã¾ãããªãã¨ããªã£ã¦ããã£ãã
ã¡ããã©ãMozilla24ã®ä¼å ´ã«åããåã«ã以ä¸ã®æ¬ãã¡ããã©èªãã§ãã¦ãããã«ã解説がdankogaiさんã ã¨ãããã¨ã ã£ãã§ãæ¬ã®å 容ã«å°ãä¼ã£ãセルオートマトンããé¡ã«é¸ãã§ã¿ã¾ããã
- ä½è : æç°éä¹
- åºç社/ã¡ã¼ã«ã¼: ã½ãããã³ã¯ã¯ãªã¨ã¤ãã£ã
- çºå£²æ¥: 2007/08/16
- ã¡ãã£ã¢: æ°æ¸
- è³¼å ¥: 6人 ã¯ãªãã¯: 104å
- ãã®ååãå«ãããã° (50件) ãè¦ã
ãä¸æ¬¡å ã»ã«ãªã¼ãããã³Webãµã¼ãã¹ãã¨ããã®ãä½æããã®ã§ãããããã°ã©ã ã¨ãã¦ã¯å ¨ç¶é£ãããªãã¦ãä¸æ¬¡å ã»ã«ãªã¼ãããã³ã®ãã©ã¡ã¼ã¿ãåãåã£ã¦çµæã®ãã¼ãã«ãJSONPã§è¿ãã¨ããã ãã§ããLiveCodingã§ä½æããCGIã®ã³ã¼ãã¯ã以ä¸ãä¼å ´ã§ã¤ãã£ãã¾ãã¾ãªã®ã§ããããããªã³ã¡ã³ãã¢ã¦ããæ®ã£ã¦ãã¾ãã
#!/opt/local/bin/perl use strict; use warnings; use JSON::Syck; use CGI; my $q = CGI->new; print $q->header(-type => 'application/javascript'); my $rule = $q->param('r') || 30; my $callback = $q->param('callback') || 'callback'; my $row = [(0) x 40, 1, (0) x 39 ]; my $grid = [$row,]; my @rule_table = reverse split //, (unpack("B8", pack("C", $rule))); for (0..30) { my $new_row = []; for my $i (0..@$row-1) { #print $row->[$i]; my $bits = '00000'; $bits .= $i - 1 < 0 ? 0 : $row->[$i-1]; $bits .= $row->[$i]; $bits .= $i + 1 > @$row -1 ? 0 : $row->[$i+1]; my $rule_index = unpack("C", pack("B8", $bits)); $new_row->[$i] = $rule_table[$rule_index]; #print $new_row->[$i]; } $row = $new_row; push @$grid, $row; #print "\n"; } #for my $x (@$grid) { # for my $y (@$x) { # print $y; # } # print "\n"; #} print $callback . '('; print JSON::Syck::Dump($grid); print ');';
åä½ã¯ãhttp://www.douzemille.net/labs/ca/ca.htmlã§ç¢ºèªã§ãã¾ãããã¢ããæã¯ãããããããããªãææ§ã ã£ãã®ã§ããã使ã£ã¦ããç´ æãããããªãã£ãã®ã§ãã¡ãã£ã¨å¯ãã表示ã§ããJavascriptãã¦ãã¨ã¼ã§ãªãããããéãã®ã§ãFirefoxãè¦ååºãããã
ruleã¨ãããã©ã¡ã¼ã¿ãããã£ã¦drawããã¨è¡¨ç¤ºããããã¾ãã90ã¨ããããããã§ãã
ãã®Perlã®ã³ã¼ãã§ä¸è¦ãããã«ããã®ã¯packã¨unpackãåºã¦ããã§ããã"Perl 2é²æ°"ã§ã°ã°ã£ã¦ã³ãããã¾ããã使ããã¨ããã¯ãããããã³ããã§ã
ã³ãããæãããª(don't be afraid to be a copycat)