/* ** CORRUPTION **  by Sam Adam-Day */   /* This is Corruption. You are a single block character. The universe in which you live is the code for the universe in which you live (it's very meta). There
 is code that allows you to move and code that gives you points but also code that reduces your points and code for baddies. You must traverse this world carefully, taking care not to destroy your own
 capacity to exist. */ /* |Universe| There are lots of discrete bits of code, each of which does different things (see |Statements| for a description of these). If a piece of code is red then it is co
rrupted, and no longer has an effect (this may only be temporary). To gain points, you must eat yin-yangs or umlaut characters *//* |Controls| Use [arrow keys] to move around. Press [r] to randomly sh
uffle the universe, at the cost of some points. Once the universe is corrupted beyond repair, press [q], [backspace], or [esc] to see your final score. You can press [space] whenever you want to begin
 playing. */ /* |Statements| The statements that exist in this universe do the following: - initialise the universe - allow you to move around - allow you to randomise the universe - display your scor
e - add space - remove space - duplicate statements - swap adjacent statements - generate yin-yangs - reduce your score - self replicate and eat yin-yangs (the viruses) - spawn and move umlaut-monster
s that eat yin-yangs - add clean orginial statements into the universe - add road-blocks (the faster you go the more are produced) */ /* |A Bit More| The game is by nature quite varied. It helps if yo
u're familiar with computer programming (the language of the universe is javascript). Sometimes statements combine in unexpected ways to produce really weird results; be ready for this. If there's mor
e than one block character, you control the earliest one. Big yin-yangs are made of smaller yin-yangs. When a virus eats a yin-yang, it leaved behind a #. */ /* |Credits| This game uses the Keypress j
avascript library made by David Mauro, and highlight.js made by many people. */ /* |Source| This game is open source, and you can find it at Github. */   /* ENJOY! */   function l() {eval(s[1]); s.pus
h(s[1],s[1],s[1],s[2],s[2]); for(i=0;i<5;i++){k1=u(r()*(s.length-1));k2=u(r()*(s.length-1));s.splice(k1,0,s[k2]);} for (i=s.length-1;i>0;i--){j=u(r()*(s.length-1));t=s[i];s[i]=s[j];s[j]=t;} b=c(s).spl
it(S);for(i=0;i<140;i++){k=u(r()*(b.length-1));b=b.slice(0,k).concat(b[k]+new Array(u(r()*50+1)).join(S),b.slice(k+1));}s=d(b.join(S)); k=u(r()*(s.length-1));s.splice(k,0,P); b=c(s).split(t=new Array(
L).join(S));k=u(r()*(b.length-1));s=d(b.slice(0,k).concat(b[k]+G,b.slice(k+1)).join(t)); _z=0;5;s[0]='score='+f+';z=1';_z=11;5; if ( r ( ) < 0.1 * Math . pow ( Math . max ( v . UP [ 1 ] , v . DOWN [ 1
 ] , v . LEFT [ 1 ] , v . RIGHT [ 1 ] ) / Q , 2 ) ) { b = c ( s ) . split ( t = S + S + S + S + S ); k = u ( r ( ) * ( b . length - 2 ) ) ; s = d ( b . slice ( 0 , k ) . concat ( b [ k ] + R  + b [ k 
+ 1 ], b . slice ( k + 2 ) ) . join ( t ) ) ; if ( r ( ) < 0.1 ) b = c ( s ) . split ( C ) , k = u ( r ( ) * ( b . length - 2 ) ) , b . splice ( k , 2 , b [ k ] + B + b [ k + 1 ] ) , s = d ( b . join 
( C ) ) } _z = 13 ;5;0;for ( i = 0 ; i < ( z && v . UP [ 1 ] / 100 ) ; i ++ ) { b = c ( s ) ; p = b . indexOf ( P ) ; x = p % W ; y = ( p - x ) / W ; y = Math . max ( 0 , y - 1 ) ; m = b [ y * W + x -
 1 ] ; if ( m != B ) { if ( /[ÄËÏÖÜ]/ . test( m ) ) f += J ; if ( m == C ) f += I ; t = b . replace ( P , S ) ; s = d ( t . slice ( 0 , y * W + x - 1 ) + P + t . slice ( y * W + x ) ) } } z = z && ! i
 ; _z = 1;0;5;0;for ( i = 0 ; i < ( z && v . DOWN [ 1 ] / 100 ) ; i ++ ) { b = c ( s ) ; p = b . indexOf ( P ) ; x = p % W ; y = ( p - x ) / W ; y = Math . min ( Math . ceil ( b . length / W ) - 1 , y
 + 1 ) ; m = b [ y * W + x + 1 ] ; if ( m != B ) { if ( /[ÄËÏÖÜ]/ . test( m ) ) f += J ; if ( m == C ) f += I ; t = b . replace ( P , S ) ; s = d ( t . slice ( 0 , y * W + x + 1 ) + P + t . slice ( y 
* W + x + 2 ) ) } } z = z && ! i ; _z = 1;0;5;0;for ( i = 0 ; i < ( z && v . LEFT [ 1 ] / 100 ) ; i ++ ) { b = c ( s ) . replace ( /\n/g , '' ) ; p = b . indexOf ( P ) ; x = p % W ; y = ( p - x ) / W 
; x = Math . max ( 0 , x - 1 ) ; m = b [ y * W + x ] ; if ( m != B ) { if ( /[ÄËÏÖÜ]/ . test( m ) ) f += J ;  if ( m == C ) f += I ; t = b . replace ( P , S ) ; s = d ( t . slice ( 0 , y * W + x ) + P
 + t . slice ( y * W + x + 1 ) ) } } z = z && ! i ; _z = 1;0;5;0;for ( i = 0 ; i < ( z && v . RIGHT [ 1 ] / 100 ) ; i ++ ) { b = c ( s ) . replace ( /\n/g , '' ) ; p = b . indexOf ( P ) ; x = p % W ; 
y = ( p - x ) / W ; x = Math . min ( W - 1 , x + 1 ) ; m = b [ y * W + x ] ; if ( m != B ) { if ( /[ÄËÏÖÜ]/ . test( m ) ) f += J ;  if ( m == C ) f += I ; t = b . replace ( P , S ) ; s = d ( t . slice
 ( 0 , y * W + x ) + P + t . slice ( y * W + x + 1 ) ) } } z = z && ! i ; _z = 1;0;5; if ( r ( ) < 0.001 ) { k = u ( r ( ) * ( s . length - 2 ) ) ; t = s [ k ] ; s [ k ] = s [ k + 1 ] ; s [ k + 1 ] = 
t } _z = 2 ;5; if ( r ( ) < 0.01 ) { k1 = u ( r ( ) * ( s . length - 1 ) ) ; k2 = u ( r ( ) * ( s . length - 1 ) ) ; s . splice ( k1 , 0 , s [ k2 ] ) } _z = 3 ;5; if ( r ( ) < 0.04 ) { b = c ( s ) . s
plit ( S ) ; k = u ( r ( ) * ( b . length - 2 ) ) ; s = d ( b . slice ( 0 , k ) . concat ( b [ k ] + S , b . slice ( k + 1 ) ) . join ( S ) ) } _z = 4 ;5; if ( r ( ) < 0.04 ) { b = c ( s ) . split ( S
 + S ) ; k = u ( r ( ) * ( b . length - 2 ) ) ; b . splice ( k , 2 , b [ k ] + S + b [ k + 1 ] ) ; s = d ( b . join ( S + S ) ) } _z = 5 ;5; if ( r ( ) < 0.06 ) { b = c ( s ) . split ( t = S + S + S +
 S + S + S ); k = u ( r ( ) * ( b . length - 2 ) ) ; s = d ( b . slice ( 0 , k ) . concat ( b [ k ] + G  + b [ k + 1 ], b . slice ( k + 2 ) ) . join ( t ) ) ; } _z = 6 ;5; if ( r ( ) < 0.1 ) { f-- } _
z = 7 ;5;s=r()<.5?d(c(s).replace(/\s{155}/m,D+s[_i]+D)):s;if(r()<.07)b=c(s).split(C),k=u(r()*(b.length-2)),b.splice(k,2,b[k]+'#'+b[k+1]),s=d(b.join(C));_z=8;5; if ( r ( ) < 0.03 ) { b = c ( s ) . spli
t ( t = new Array ( 7 ) . join ( S ) ); if ( b . length > 2 ) { w = [ 'Ä' , 'Ë' , 'Ï' , 'Ö' , 'Ü' ] [ u ( r ( ) * 4 ) ] ; k = u ( r ( ) * ( b . length - 2 ) ) ; s = d ( b . slice ( 0 , k ) . concat ( 
b [ k ] + '/*' + w + '<>' [ u ( r ( ) ) ] + w + '*/'  + b [ k + 1 ], b . slice ( k + 2 ) ) . join ( t ) ) ; } } _z = 9 ;5; a1 = '\\/' ; a2 = '\\*' ; t = C + a1 + a2 + S + B + 'ÄËÏÖÜ#><' ; s = d ( c ( 
s ) . replace ( new RegExp ( '([^' + t + '])' + a1 + a2 + '([ÄËÏÖÜ])<[ÄËÏÖÜ]' + a2 + a1 , 'g' ) , '$1/*$2>$2*/' ) . replace ( new RegExp ( '([' + t + '])' + a1 + a2 + '([ÄËÏÖÜ])<[ÄËÏÖÜ]' + a2 + a1 , '
g' ) , '/*$2<$2*/' + S ) . replace ( new RegExp ( a1 + a2 + '([ÄËÏÖÜ])>[ÄËÏÖÜ]' + a2 + a1 + '([^' + t + '])' , 'g' ) , '/*$1<$1*/$2' ) . replace ( new RegExp ( a1 + a2 + '([ÄËÏÖÜ])>[ÄËÏÖÜ]' + a2 + a1 
+ '([' + t + '])' , 'g' ) , S+'/*$1>$1*/' ) ) ; _z = 10 ;5; if ( r ( ) < 0.01 ) { s . splice ( u ( r ( ) * ( s . length - 1 ) ) , 0 , o [ u ( r ( ) * ( o . length - 1 ) ) ] ) } _z = 12 ;5; if ( v . R 
) { f -= E ; for ( i = s.length - 1 ; i > 0 ; i -- ) { j = u ( r ( ) * ( s . length - 1 ) ) ; t = s [ i ] ; s [ i ] = s [ j ] ; s [ j ] = t } } _z = 14}$l.unregister_combo("space");M=250;W=200;X=50;I=
40;J=20;E=300;D="/**/";P="\u2588";G="/*\u262f\u262f*/";C="\u262f";R="/*\u00d7*/";B="\u00d7";S=" ";L=6;Q=350;A=";5;";f=0;$g=0;v={"UP":[0,0,0],"DOWN":[0,0,0],"LEFT":[0,0,0],"RIGHT":[0,0,0],"R":0};$e=0;f
unction $w(){$z=setInterval(function(){$b=$c(s);$x=$b.search(/\S/);if($x!=-1){$r=new RegExp($b[$x].replace(/([.\\+*?[^$()])/,"\\$1"),"g");s=$d($b.replace($r," "))}else{if($m)clearInterval($m);n.innerH
TML="<span class='statement-c-1'>"+hljs.highlight("js","/* ** THE UNIVERSE HAS BEEN CORRUPTED ** */").value.replace("CORRUPTED","<strong>CORRUPTED</strong>")+"</span>"+hljs.highlight("js","   /* Your 
final score is: */ $g = "+$g+";   /* Press [F5] to play again. /*").value;clearInterval($z)}},50)}$l.register_many([{"keys":"up","on_keydown":function(){v.UP[0]=true;if(v.UP[1]<Q)v.UP[1]++},"on_keyup"
:function(){v.UP[0]=false}},{"keys":"down","on_keydown":function(){v.DOWN[0]=true;if(v.DOWN[1]<Q)v.DOWN[1]++},"on_keyup":function(){v.DOWN[0]=false}},{"keys":"left","on_keydown":function(){v.LEFT[0]=t
rue;if(v.LEFT[1]<Q)v.LEFT[1]+=5},"on_keyup":function(){v.LEFT[0]=false}},{"keys":"right","on_keydown":function(){v.RIGHT[0]=true;if(v.RIGHT[1]<Q)v.RIGHT[1]+=5},"on_keyup":function(){v.RIGHT[0]=false}}
,{"keys":"r","on_keydown":function(){v.R=true}},{"keys":"q","on_keydown":$w},{"keys":"backspace","on_keydown":$w},{"keys":"escape","on_keydown":$w}]);r=Math.random;u=Math.round;$c=c=function($v,$y,$s)
{$y=typeof $y!="undefined"&&$y;$n=-1;$q=[];for($i in $v)if(typeof $v[$i]=="string"&&$v[$i]){$f=$v[$i];$h=($n+$f.length)%W;if($h+D.length>=W)$h=D.length-1;else $h+=D.length;if($n+$f.length+D.length>=W)
{$a=[$f.slice(0,W-$n-1)];for($j=0;$j<=Math.floor(($n+$f.length+D.length-W)/W);$j++)$a.push($f.slice(W-$n-1+$j*W,W-$n-1+($j+1)*W));$f=$a.join("\n")}if($y){$f=hljs.highlight("js",$f,true).value.replace(
new RegExp(C+C,"g"),"\u201e\u00f7").replace(new RegExp(C,"g"),"<span class='yin-yang-small'>"+C+"</span>").replace(/\u201e\u00f7/g,"<span class='yin-yang-large'>"+C+"</span>");$f="<span class='stateme
nt-c"+$s[$i]+"'>"+$f+"</span>"}$q.push($f);$n=$h}return $y?$q.join(hljs.highlight("js",D,true).value):$q.join(D)};$d=d=function($h){return $h.replace(new RegExp("\n","g"),"").split(D)};function q(){re
turn"score="+f+";"}o=s=(l+"").slice(14,-1).split(A);$m=setInterval(function(){if($e)return;try{$e=1;while(s.length>=X){$k=u(r()*(s.length-1));if(s[$k].indexOf(P)==-1)s.splice($k,1)}for($i in v)if(v[$i
][1]>0)if(!v[$i][0])if(v[$i][2]){v[$i][1]=0;v[$i][2]=0}else v[$i][2]=1;else v[$i][2]=1;else v[$i][2]=0;$t=s;$o=[];for(_i in $t){_z=0;try{eval($t[_i])}catch($u){console.log($u);_z=-1}$o[_i]=_z}v.R=0;$g
=f>$g?f:$g;n.innerHTML=c(s,1,$o)}catch($u){clearInterval($m);$w()}$e=0},M);