Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
selfgol [2007-06-07 12:02] – created nikselfgol [2020-10-22 15:13] (current) nik
Line 11: Line 11:
  
   selfgol -g [-y=## -x=##] [< gamefile] plays the Game of Life with its own source code or an arbitrary file, with optional height and width restrictions.   selfgol -g [-y=## -x=##] [< gamefile] plays the Game of Life with its own source code or an arbitrary file, with optional height and width restrictions.
-  +
   selfgol -d[=bannertext] displays a rotating banner with the provided text. If no text is provided, it uses the program name as the text.   selfgol -d[=bannertext] displays a rotating banner with the provided text. If no text is provided, it uses the program name as the text.
  
 SelfGOL was written to win all four categories in the Obfuscated Perl contest (3rd year, I believe, whose web pages are no longer available) and still comply with other restrictions of not using modules and being under 1000 bytes. Alas, the rules were drastically changed for the following year's contest, and so it was never entered. SelfGOL was written to win all four categories in the Obfuscated Perl contest (3rd year, I believe, whose web pages are no longer available) and still comply with other restrictions of not using modules and being under 1000 bytes. Alas, the rules were drastically changed for the following year's contest, and so it was never entered.
  
-the self-replicating code, used the standard quine code:+the self-replicating code is based on the standard [[quine]] in perl
  
-<code> +<code perl
-  @s=( + @s=( 
     q[printf pop@s, @s],      q[printf pop@s, @s], 
     q[@s=(q[%s],q[%s])x2;%s],      q[@s=(q[%s],q[%s])x2;%s], 
   )x2;    )x2; 
   printf pop @s, @s;    printf pop @s, @s; 
 +</code>
 +
 +...expanded into this Obfuscation
  
-#!/usr/bin/perl -s  +<code perl> 
-$;=$/;seek+DATA,!++$/,!$s;$_=<DATA>;$s&&print||$g&&do{$y=($x||=20)*($y||8);sub +#!/usr/bin/perl -s 
-i{sleep&f}sub'p{print$;x$=,join$;,$b=~/.{$x}/g}$j=$j;sub'f{pop}sub +$;=$/;seek+DATA,undef$/,!$s;$_=<DATA>;$s&&print||(*{q;::\; 
-n{substr($b,&f%$y,3)=~tr,O,O,}sub'g{$f=&f-1;($w,$w,substr($b,&f,1),O)[n($f-$x)+ +;}=sub{$d=$d-1?$d:$0;s;';\t#$d#;,$_})&&$g&&do{$y=($x||=20)*($y||8);sub 
-n($x+$f)-(substr($b,&f,1)eq+O)+n$f]||$w}$w="\40";$b=join'',@ARGV?<>:$_,$w +i{sleep&f}sub'p{print$;x$=,join$;,$b=~/.{$x}/g,$;}sub'f{pop||1}sub'n{substr($b, 
-x$y;$b=~s).)$&=~/\w/?O:$w)ge;substr($b,$y)=q++;$g='$i=0;$i?$b:$c=$b; +&f%$y,3)=~tr,O,O,}sub'g{@_[~~@_]=@_;--($f=&f);$m=substr($b,&f,1);($w,$w,$m,O) 
-substr+$c,$i,1,g$i;$g=~s?\d+?($&+1)%$y?e;$i-$y+1?eval$g:do{$i=-1;$b=$c;p;i +[n($f-$x)+n($x+$f)-(${m}eq+O=>)+n$f]||$w}$w="\40";$b=join'',@ARGV?<>:$_,$w 
-1}';sub'e{eval$g;&e}e}||eval||die+No.$;+x$y;$b=~s).)$&=~/\w/?O:$w)gse;substr($b,$y)=q++;$g='$i=0;$i?$b:$c=$b; 
 +substr+$c,$i,1,g$i;$g=~s?\d+?($&+1)%$y?e;$i-$y+1?eval$g:do{$b=$c;p;i}'; 
 +sub'e{eval$g;&e};e}||eval||die+No.$;
 __DATA__ __DATA__
-if($j){{$^W=$|;*_=sub{$=+s=#([A-z])(.*)#=#$+$1#=g}} +$d&&do{{$^W=$|;*_=sub{$=+s=#([A-z])(.*)#=#$+$1#=g}} 
-@s=(q[$_=sprintf+pop@s,@s],q[ +@s=(q[$_=sprintf+pop@s,@s],";\n"->($_=q[ 
-if($j){{$^W=$|;*_=sub{$=+s=#([A-z])(.*)#=#$+$1#=g}}     #_The_Perl_Journal_# +$d&&do{{$^W=$|;*_=sub{$=+s=#([A-z])(.*)#=#$+$1#=g}}' 
-@s=(q[%s],q[%s])x2;%s;print"\n"x&_,$_;i$j;eval} +@s=(q[%s],q[%s])x2;%s;print"\n"x&_,$_;i;eval}; 
-])x2;$_=sprintf+pop@s,@s;print"\n"x&_,$_;i$j;eval}$/=$y;$"=",";print +]))x2;$_=sprintf+pop@s,@s;print"\n"x&_,$_;i;eval};$/=$y;$"=",";print 
-q<#!/usr/local/bin/perl -sw +q<#!/usr/bin/perl -sw 
-if(!$s){>.($_=<>).q<}else{@s=(q[printf+pop@s,@s],q[#!/usr/local/bin/perl -sw +!$s?{do{>.($_=<>).q<}:do{@s=(q[printf+pop@s,@s],q[#!/usr/bin/perl -sw 
-if(!$s){>.(s$%$%%$g,tr=[=[===tr=]=]=||&d,$_).q<}else{@s=(q[%s],q[%s])x2;%s}+!$s?{do{>.(s$%$%%$g,y=[====y=]==||&d,$_).q<}:do{@s=(q[%s],q[%s])x2;%s}
 ])x2;printf+pop@s,@s} ])x2;printf+pop@s,@s}
 > >
 </code> </code>
  
-or download -> [[/pub/Libarynth/SelfGOL/SelfGOL.tgz|SelfGOL.tgz]] 
  
----- +==== some (other) perl quines ====
-loosely related,.. some perl quines from -> http://www.nyx.net/~gthompso/quine.htm+
  
 +loosely related,.. from -> http://www.nyx.net/~gthompso/quine.htm
  
 Author: Tushar Samant Author: Tushar Samant
-Note: This will produce itself, and will do so no matter what you set $a to in the beginning. So if the length of $a is n, and the size of the allowed character set is C, then at least C**n out of C**(n+K) strings are self-reproducing Perl programs.+Note: This will produce itself, and will do so no matter what you set $a to in the beginning. So if the length of $a is n, and the size of the allowed character set is C, then at least <nowiki>C**n out of C**(n+K)</nowiki> strings are self-reproducing Perl programs.
  
 <code> <code>
Line 60: Line 64:
  
 Author: Brian Raiter Author: Brian Raiter
-<code>+<code perl>
 $_=q{$_=q{Q};s/Q/$_/;print};s/Q/$_/;print $_=q{$_=q{Q};s/Q/$_/;print};s/Q/$_/;print
 </code> </code>
  
 Author: V Vinay Author: V Vinay
-<code>+<code perl>
 $_=q(print"\$_=q($_);eval;");eval; $_=q(print"\$_=q($_);eval;");eval;
-paper on writing quines (in C) http://www.cs.washington.edu/homes/csk/paper/ 
 </code> </code>
 +
 +paper on writing [[quines]] (in C) http://www.cs.washington.edu/homes/csk/paper/
  
 ---- ----
 Libarynth >  Libarynth Web > ComputerScience > GeneticProgramming > SelfGOL r5 - 30 Sep 2006 - 16:29  Libarynth >  Libarynth Web > ComputerScience > GeneticProgramming > SelfGOL r5 - 30 Sep 2006 - 16:29 
 ---- ----
  • selfgol.1181217764.txt.gz
  • Last modified: 2007-06-07 12:02
  • by nik