Files
Cody Boone Ferguson 9357123aca Fix 1991/rince and add two alt versions
The program was supposed to print a message that indicates whether you
won or lost but it did not show up because of endwin() being called
after it. To keep the code as close to the original as possible that
part was left in but an additional call to printf() was made after
endwin() is called.

The first alt version removes the maximum number of moves so that
everyone can finish, even people not good at this kind of puzzle. The
second alt version allows you to reconfigure (at compile time) the
maximum number of moves even if you wish to make it harder to win.

Format fix README.md file.

At this time I believe the edits necessary for 1991/rince are complete.
2023-11-05 06:06:54 -08:00

13 lines
1.8 KiB
C

#include <curses.h>
int X[]={-1,0,0,1},Y[]={0,1,-1,0},x,y,D,i,j,a;
char o,m,*t,*O="MNOH",*k="hjkl",*s="######\0######\0######\0 \0 \0 \0 ___ \0 / \\\0 \\___/\0 ___ \0 /@@@\\\0 \\@@@/\0| | /\\\0----||\0 \\/\0 /--\\\0 \\/ \0 ==| \0 ==| \0 /\\ \0 \\--/\0 /O__o\0 \\___/\0 /_\\_ \0 << \0 << \0 << \0 \0vvvvvv\0 \0 \0^^^^^^\0 \0 /\\ \0 < > \0 \\/ \0o__O\\ \0\\___/ \0 _/_\\ \0 O__O \0/----\\\0_/ \\_\0 ^__^ \0/----\\\0_/ \\_" ,
M[12][22]={"AAAAAAAAAAAAAAAAAAAAAA" ,"ALCABBBBBBBABBCBBCABBA", "ACCABAKAAABAFBABABAEBA", "ABBBBABBIBBBBBEEABACLA", "ACCBNIBBAAAAGALBBBABCA", "AAAAAAAJACBABBCABAABCA", "ALLAACCBACBAAALLCABBBA", "ABDLAAABABCAAAALCABBLA", "ABCBIBBBBBBBBAAAAACBBA", "ABCCAABBADBBBBDBDBDBCA", "ALBBACCCCDBCABBBDBBBBA", "AAAAAAAAAAAAAAAAAAAAAA" };main(){initscr();clear();
noecho();cbreak();x=y=4;D=39,o='M';m=M[y][x] ;while(D){for(i=j=a=0;j<7;!(mvaddstr(
j*3+a,i*6,s+(((M[((y-1)/5)*5+j][((x-1)/10)*10+i]-'A')*3+a++)*7)),a^3)&&(a=0,!
(++i^12))&&(a=i=0,j++));refresh();M[y][x] ='B';if(t=(char*)strchr(k,getch())){int e=
x,g=y,f=x,h=y,d=t-k;o=O[d];f=(e=x+X[d])+X[d];h=(g=y+Y[d])+Y[d];switch(M[g][e] ){case
'B':x=e;y=g;break ;case 'C':if(M[h][f] =='B')M[h][f] =M[g][e] ,x=e,y=g; else if(M[h][f] =='C')M[h][f] =M[g][e] ='L';break ;case 'D':if(M[h][f] =='B')M[h][f] =M[g][e] ,x=e,y=g; break ;case'L':x=e;y=g;D
--;break ;case 'E':if(M[h][f] =='B')M[h][f] =M[g][e] ,x=e,y=g; else if(M[h][f] =='I'&&d==0)M[h][f] =M[g][e] ='B';break ; case 'F':if(M[h][f] =='B')M[h][f] =M[g][e] ,x=e,y=g; else if(M[h][f] =='J'&&d==1)M[h][f] =M[g][e] ='B';break ; case 'G':if(M[h][f] =='B')M[h][f] =M[g][e] ,x=e,y=g; else if(M[h][f] =='K'&&d==2)M[h][f] =M[g][e] ='B';break ; }}m=M[y][x] ;M[y][x] =o;}clear();mvaddstr(12
,31,"Well done!");move(23,0);refresh();endwin();printf("Well done!");return 0;}