o1-preview-2024-09-12· OpenAI
WildChat-4.8M (AI2)
Create an obfuscated c program that is a simple 2d roguelike terminal game. code only,…
- User
Create an obfuscated c program that is a simple 2d roguelike terminal game. code only, less than 50 lines
- Assistant
#include<stdio.h>#include<termios.h>#include<unistd.h>#define H 10#define W 20 char m[H][W+1],*p;m[0][W]=0;int x=H/2,y=W/2,c;struct termios o,n; main(){tcgetattr(0,&o);n=o;n.c_lflag&=~(ICANON|ECHO);tcsetattr(0,TCSANOW,&n); for(;;){for(int i=0;i<H;i++)for(int j=0;j<W;j++)m[i][j]='.'; m[x][y]='@';for(int i=0;i<H;i++)puts(m[i]);c=getchar(); if(c=='q')break;m[x][y]='.';if(c=='w'&&x>0)x--; if(c=='s'&&x<H-1)x++;if(c=='a'&&y>0)y--;if(c=='d'&&y<W-1)y++; printf("\033[%dA",H);}tcsetattr(0,TCSANOW,&o);}