Last active
September 16, 2019 13:08
-
-
Save KvanTTT/483110279b507ba0f570 to your computer and use it in GitHub Desktop.
Game Snake in source code (Quine). One can play this with batch or power scripts. The game can be finished =)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo off | |
:LOOP | |
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" "QuineSnake.cs" | |
"QuineSnake.exe" > "QuineSnake.cs" | |
type "QuineSnake.cs" | |
goto LOOP | |
:END |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System;class E{static int A=4,B=10,M=1,D=5,Z=3,F=0;static int[]L={3,3}; | |
static string a2(){int a=A,b=B,c=0,e=3,g=0,h,i,j,k,l,m,p,q=L.Length;var r=false; | |
var t=new int[10,20];t[M,D]=8;if(F!=1)goto X;for(int u=0;u<q;u++){c=L[u];int d=u | |
==0?Z:L[u-1];if(d==0||d==2){k=0;l=2;m=1;p=3;j=2;h=0;i=1;}else{k=1;l=3;m=0;p=2;j= | |
1;h=1;i=0;}if(u==0){if((Z!=k||c!=l)&&(Z!=l||c!=k))e=Z;else e=c;g=e==k?-1:1;A=A+g | |
*h;B=B+g*i;if(A<0||A>=10||B<0||B>=20){F=2;goto X;}if(t[A,B]==8)r=true;t[A,B]=5;} | |
if(u!=q-1||r)t[a,b]=c==m||c==p?c==m^d!=k?3:4:j;else t[a,b]=d==0||d==2?7:6;if(c== | |
0)b++;if(c==2)b--;if(c==1)a++;if(c==3)a--;}if(t[A,B]!=5){F=2;goto X;}if(r){t[a,b | |
]=c==0||c==2?7:6;F=3;for(h=0;h<10;h++)for(i=0;i<20;i++)if(t[h,i]==0)F=1;if(F==3) | |
goto X;var v=new Random();for(;;){M=v.Next(10);D=v.Next(20);if(t[M,D]==0){t[M,D] | |
=8;break;}}var w=new int[q+1];for(g=0;g<q;g++)w[g+1]=L[g];w[0]=e;L=w;}else{for(g | |
=q-2;g>=0;g--)L[g+1]=L[g];L[0]=e;}X:var R="";var x="\r\n";var s=new string('/', | |
20+4);R+=x+s+x;var y=" |-\\/O\"=*";for(h=0;h<10;h++){R+="//";if(F==1)for(i=0;i< | |
20;i++)R+=y[t[h,i]].ToString();else{var z=F==2?"Game Over!":" Win!!! ";int C= | |
20/2;R+=new string(' ',C-5)+z+new string(' ',20-C-5);}R+="//";R+=x;}R+=s+ | |
" QuineSnake by KvanTTT for GoStash"+x;return R;}static void Main(){if(F!=0){ | |
int a=(int)Console.ReadKey(true).Key;Z=a<37||a>40?L[0]:a-37;}if(F==0)F=1;var R=a2();var s= | |
"using System;class E{{static int {10}={8},{11}={9},{12}={6},{13}={7},{14}={4},{17}={16};static int[]{15}={5};static string a2(){{int a={10},b={11},c=0,e=3,g=0,h,i,j,k,l,m,p,q={15}.Length;var r=false;var t=new int[10,20];t[{12},{13}]=8;if({17}!=1)goto X;for(int u=0;u<q;u++){{c={15}[u];int d=u==0?{14}:{15}[u-1];if(d==0||d==2){{k=0;l=2;m=1;p=3;j=2;h=0;i=1;}}else{{k=1;l=3;m=0;p=2;j=1;h=1;i=0;}}if(u==0){{if(({14}!=k||c!=l)&&({14}!=l||c!=k))e={14};else e=c;g=e==k?-1:1;{10}={10}+g*h;{11}={11}+g*i;if({10}<0||{10}>=10||{11}<0||{11}>=20){{{17}=2;goto X;}}if(t[{10},{11}]==8)r=true;t[{10},{11}]=5;}}if(u!=q-1||r)t[a,b]=c==m||c==p?c==m^d!=k?3:4:j;else t[a,b]=d==0||d==2?7:6;if(c==0)b++;if(c==2)b--;if(c==1)a++;if(c==3)a--;}}if(t[{10},{11}]!=5){{{17}=2;goto X;}}if(r){{t[a,b]=c==0||c==2?7:6;{17}=3;for(h=0;h<10;h++)for(i=0;i<20;i++)if(t[h,i]==0){17}=1;if({17}==3)goto X;var v=new Random();for(;;){{{12}=v.Next(10);{13}=v.Next(20);if(t[{12},{13}]==0){{t[{12},{13}]=8;break;}}}}var w=new int[q+1];for(g=0;g<q;g++)w[g+1]={15}[g];w[0]=e;{15}=w;}}else{{for(g=q-2;g>=0;g--){15}[g+1]={15}[g];{15}[0]=e;}}X:var R={1}{1};var x={1}{2}r{2}n{1};var s=new string('/',20+4);R+=x+s+x;var y={1} |-{2}{2}/O{2}{1}=*{1};for(h=0;h<10;h++){{R+={1}//{1};if({17}==1)for(i=0;i<20;i++)R+=y[t[h,i]].ToString();else{{var z={17}==2?{1}Game Over!{1}:{1} Win!!! {1};int C=20/2;R+=new string(' ',C-5)+z+new string(' ',20-C-5);}}R+={1}//{1};R+=x;}}R+=s+{1} QuineSnake by KvanTTT for GoStash{1}+x;return R;}}static void Main(){{if({17}!=0){{int a=(int)Console.ReadKey(true).Key;{14}=a<37||a>40?{15}[0]:a-37;}}if({17}==0){17}=1;var R=a2();var s={1}{0}{1};Console.Write(s,s,'{1}','{2}{2}',R,{14},{1}{{{1}+string.Join({1},{1},{15})+{1}}}{1},{12},{13},{10},{11},{1}A{1},{1}B{1},{1}M{1},{1}D{1},{1}Z{1},{1}L{1},{17},{1}F{1});}}}}{3}";Console.Write(s,s,'"','\\',R,Z,"{"+string.Join(",",L)+"}",M,D,A,B,"A","B","M","D","Z","L",F,"F");}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while ($true) { | |
&"C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" "QuineSnake.cs" | |
./"QuineSnake.exe" > "QuineSnake.cs" | |
type "QuineSnake.cs" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment