From a30c092df74b9a3425fd99c9fb35b782496f28f4 Mon Sep 17 00:00:00 2001 From: untakenstupidnick Date: Mon, 13 May 2019 18:28:19 +0430 Subject: [PATCH] Version 2 --- README.md | 18 +-- sources/.fifteen.c.swp | Bin 0 -> 24576 bytes sources/Makefile | 16 ++- sources/checkers.c | 3 +- sources/fifteen.c | 247 +++++++++++++++++++++++++++++++++++++++ sources/memoblocks.c | 254 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 522 insertions(+), 16 deletions(-) create mode 100644 sources/.fifteen.c.swp create mode 100644 sources/fifteen.c create mode 100644 sources/memoblocks.c diff --git a/README.md b/README.md index 48def19..d559aa3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # New BSD Games - + *You have a computing machine from 1980's and you wonder how you can use it?
You deal with a GUI-less machine at work and are looking for ways to kill time?
You have to make a Reversi AI for your homework and you don't know where to copy it from?
@@ -8,8 +8,7 @@ **Don't worry** anymore as you've got nbsdgames now! -I originally made these to be added to NetBSD ( but the few i talked with preferred to have games in the repositories rather than in /usr/games itself) . - +I originally made these in hope of them being added to NetBSD ( but the few i talked with preferred to have games in the repositories rather than in /usr/games itself) . These include: @@ -22,7 +21,8 @@ These include: * SOS * Rabbithole (A maze-exploring game where you have to gather items from all around the maze rather than reaching an end, the idea maybe mine) * Pipes (Same as the famous Pipe Mania, unplayable on the environments that don't support the line characters) - +* Fifteen +* Memoblocks (or Memory blocks. A similar game was included in Windows 7) ## Prerequisites * git (optional) @@ -41,7 +41,7 @@ These include: Like this: ``` sh - git clone https://github.com/untakenstupidnick/nbsdgames + git clone https://github.com/untakenstupidnick/nbsdgames cd ~/nbsdgames/sources export PREFIX= ~/bin make install @@ -58,8 +58,8 @@ It's been made available for openSUSE thanks to Zinjanthropus: https://build.ope ## How to contribute -Thanks for your generousity! You can... +Oh, You are so kind! You can... * Share these with your friends -* Tell me your suggestions, bug reports, games you want to be added etc. -* Make a package for your distro ( This additional repo is made to make it easier https://github.com/untakenstupidnick/nbsdgames-sources ) -* Port it to other OSes with help from PDcurses (Not very hard, but there are incompatibilities between PDcurses and ncurses) +* Tell me your feature requests, bug reports, games you want to be added etc. +* Make a package for your distro +* Tell me if you're interested in porting it to non-Unix (Possible in theory since there is PDCurses for SDL, and SDL for everything) diff --git a/sources/.fifteen.c.swp b/sources/.fifteen.c.swp new file mode 100644 index 0000000000000000000000000000000000000000..f2860220cede1d846032f043700a7fa5ba07f466 GIT binary patch literal 24576 zcmeI33y@@0d4QXTk`6(Lo6<@tcz1DkdbWF}XJ#Kfc6wo$?b#ifomu9w?7F)QJ>7Sv zFVoYvx%bXaUv?L%#7adiLBTT7M8$+4B^V?jph7}ffe=bSLxCU=HO7hsMJY*8sv?kl z|2g+|-|m@aADWldUGvSo_dNddpZ}cuIOqIlrf2u?PUF1pjWK>_#bW1x3mlIH7QNZ7^Us*t(AV1|+0I?F+F14WspFB*PTRIX+X8J1v@OuKK-&Us z3$!iJwm{ng|IaPpRZfk4fI6HU)T1*vp44=FOK|=E;Mma=e`;`jX>j~fQ~W8x^*O<@ zCnz8+CkSpI+7@VAplyM+1=<#9TcB-$wguW2Xj`Cdfwl$O7HC`Gzrg~zLM&#T9*cGU z2EtkY56Ay6of(Tg0}sNN;j{2zxCV+)fGc4?jKgJMz+d1ua2I?U{s4}^0_0#D{3g77 zMlALO+zlUtkAe-CK^ju2Nx2aAw`HE;&J8jr>P86Jn*;RYx{ z9xjG0a2{-gK6o#j0zdw>SnNA+Kimp8!F6yLieN$>X5egi>a@{IC*kXG2iyjK2Dd-~-Uk=KW=O!CI+T285`Nw zAgi}WgzX)hG6n}mje(JgF=J{XYfSFQ8au~0TOE~C(_n*SGK}^7RMNq*(aG_#kqH$N z&7n#zuT*fKh&XH*hlfYA6OHxjRZ;u*rw>O(nNH3%6DWVswhBhkEL9S6)_Ev)Bo>b^ zmgh__Urclu9a2AQHi0=Ri(dDP>*YMtSZ5?InVOs&8||AO92p+GG`sDvzTOaCcN(2h zIs4141nGRewS44qOmERC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6aApK7J zAg&S2LfMXFlkxvg7*o28Pi6cc?(cttvHsKW0Nf1M!9F-2WG>)k#`xcb=iyfP9k>n- z!XWg(8h9t11TQkie-yq9pMgWL1Rgjr2HT(;-U;Fd@G86l&%!hCCvX_1VHAd7D{O%a z;3Rl~F~0Z&+yycpFb(_R{jdQN@OJn)zvQ z{3m1o$3W%?J`bM-nJc&+EZ76PAq(RFpM+KLPuTe{;nN^Ce+gcM@4@r%4162@0qzD# zD|-Y!2_J!LLG}jhf%m}xY=(Ek^UNDO2hYHh@BrKax5LeFBYX&C??4{*!U$}G3t=_9 z16ILVa1zMAfgix%!#(gtm;srGX#d(4Xj|Y{)dJxw$EdvrPiz-WDCZXxGai)_J?HC) z4L-|5k;8ucvMO27xlB{yODx8a@11QPSob5 z$W?e6ZICdmLAx+8JT^og$2O?e`6Ds4)7nWZy+bu{kd1y+Hf^|4- z*$`QeHJtCzDkPrU(#nMS^*POqHd; zLxD+^jtdO2triv1p80`;e$eJpJp{?-rZ|FS%U!UaNpD(Fb7a~yCLw0^Kt^AM`zDl1 zqQBBHlj%jXT6N^INkL`A`bH#ao?uF1CH3l!!WIlQbHP!~ht#@CM4gP`uNQ&ID!%em zs_PWS651AO?C#SMiMNO=zAgtD^L+kw^yxIEPxpJ^` zOz$2!@hZiG9RZ>UQtEpL!qsS1XEmSI^kj(c35v88Hb|!nmMg2&k$X6*u91m0N2lJ1 z7OC`#wq2nQgzu#K6Cn%DnW(k5m<1J;ftg4+XgV^Z Z=b3Y+BU2WRDbG>%Ij|o +#include +#include +#include +#include +#include +/* +.-- +|__ +| IFTEEN + +Authored by Hossein Bakhtiarifar +No rights are reserved and this software comes with no warranties of any kind to the extent permitted by law. + +compile with -lncurses +*/ +typedef signed char byte; +byte size; +byte py,px; +byte ey,ex; //the empty tile +chtype green=A_BOLD; //bold when there is no color +void rectangle(byte sy,byte sx){ + for(byte y=0;y<=size+1;y++){ + mvaddch(sy+y,sx,ACS_VLINE); + mvaddch(sy+y,sx+size*2,ACS_VLINE); + } + for(byte x=0;x<=size*2;x++){ + mvaddch(sy,sx+x,ACS_HLINE); + mvaddch(sy+size+1,sx+x,ACS_HLINE); + } + mvaddch(sy,sx,ACS_ULCORNER); + mvaddch(sy+size+1,sx,ACS_LLCORNER); + mvaddch(sy,sx+size*2,ACS_URCORNER); + mvaddch(sy+size+1,sx+size*2,ACS_LRCORNER); +} +void logo(byte sy,byte sx){ + mvaddstr(sy,sx, ".--"); + mvaddstr(sy+1,sx,"|__"); + mvaddstr(sy+2,sx,"| IFTEEN"); +} +//convert integer to representing sign +char int2sgn(byte num){ + if(!num) + return ' '; + else if(0< num && num <= 9) + return num+'0'; + else if(10<=num && num <=35) + return num-10+'a'; + else if(36<=num && num <=51) + return num-36+'A'; + return 0; +} +/*bool isinorder(byte board[size][size],byte y,byte x){ using check[][] is much cheaper + return (board[y][x] == y*size+x+1); +} */ + +//display +void draw(byte sy,byte sx,char board[size][size],char check[size][size]){ + rectangle(sy,sx); + chtype prnt; + byte y,x; + for(y=0;y=0 && y=0 && x7){ + fprintf(stderr,"3<=size<=7\n"); + return EXIT_FAILURE; + } + } + signal(SIGINT,sigint_handler); + srandom(time(NULL)%UINT_MAX); + initscr(); + mousemask(ALL_MOUSE_EVENTS,NULL); + noecho(); + cbreak(); + keypad(stdscr,1); + if(has_colors()){ + start_color(); + use_default_colors(); + init_pair(1,COLOR_GREEN,-1); + green=COLOR_PAIR(1); + } + char board[size][size]; + char check[size][size]; + fill(check); + int input; + Start: + py=px=0; + ey=ex=size-1; + curs_set(0); + fill(board); + shuffle(board); + while(1){ + erase(); + logo(0,0); + draw(3,0,board,check); + refresh(); + if(issolved(board,check)) + break; + input = getch(); + if( input==KEY_F(1) || input=='?' ) + help(); + if( input==KEY_F(2) ) + gameplay(); + if( input==KEY_MOUSE ) + mouseinput(); + if( (input=='k' || input==KEY_UP) && py>0) + py--; + if( (input=='j' || input==KEY_DOWN) && py0) + px--; + if( (input=='l' || input==KEY_RIGHT) && px +#include +#include +#include +#include +#include +/* +. . _ +|\/| |_) +| |EMORY|_)LOCKS + +Authored by Hossein Bakhtiarifar +No rights are reserved and this software comes with no warranties of any kind to the extent permitted by law. + +compile with -lncurses +*/ +typedef signed char byte; +typedef unsigned char ubyte; +byte size,size2;//size2 is there to avoid a lot of multiplications +byte py,px; +byte fy,fx; //the first tile +chtype colors[6]={0}; +void rectangle(byte sy,byte sx){ + for(byte y=0;y<=size+1;y++){ + mvaddch(sy+y,sx,ACS_VLINE); + mvaddch(sy+y,sx+size2+1,ACS_VLINE); + } + for(byte x=0;x<=size2+1;x++){ + mvaddch(sy,sx+x,ACS_HLINE); + mvaddch(sy+size+1,sx+x,ACS_HLINE); + } + mvaddch(sy,sx,ACS_ULCORNER); + mvaddch(sy+size+1,sx,ACS_LLCORNER); + mvaddch(sy,sx+size2+1,ACS_URCORNER); + mvaddch(sy+size+1,sx+size2+1,ACS_LRCORNER); +} +void logo(byte sy,byte sx){ + mvaddstr(sy,sx, ". . _"); + mvaddstr(sy+1,sx,"|\\/| |_)"); + mvaddstr(sy+2,sx,"| |EMORY|_)LOCKS"); +} +//convert integer to representing sign +char int2sgn(byte num){ + if(0< num && num <= 9) + return num+'0'; + else if(10<=num && num <=35) + return num-10+'a'; + else if(36<=num && num <=51) + return num-36+'A'; + else if(52<=num && num<=64) + return num-52+'!'; + return 0; +} +//display +void draw(byte sy,byte sx,chtype board[size][size2],bool show[size][size2]){ + rectangle(sy,sx); + byte y,x; + chtype prnt; + for(y=0;y=2){ + size=atoi(argv[1]); + if(size<3 || size>19){ + fprintf(stderr,"3<=size<=19\n"); + return EXIT_FAILURE; + } + if(!strcmp("help",argv[1])){ + printf("Usage: %s [size]\n",argv[0]); + return EXIT_SUCCESS; + } + } + signal(SIGINT,sigint_handler); + srandom(time(NULL)%UINT_MAX); + initscr(); + mousemask(ALL_MOUSE_EVENTS,NULL); + noecho(); + cbreak(); + keypad(stdscr,1); + if(has_colors()){ + start_color(); + use_default_colors(); + if( has_colors() ){ + start_color(); + use_default_colors(); + init_pair(1,COLOR_YELLOW,-1); + init_pair(2,COLOR_GREEN,-1); + init_pair(3,COLOR_BLUE,-1); + init_pair(4,COLOR_CYAN,-1); + init_pair(5,COLOR_MAGENTA,-1); + init_pair(6,COLOR_RED,-1); + for(byte b=0;b<6;b++){ + colors[b]=COLOR_PAIR(b+1); + } + } + } + else if(size>8)//big sizes depend on color display + size=8; + size2=size*2; + chtype board[size][size2]; + bool show[size][size2]; + int input; + time_t tstart,now; + Start: + tstart=time(NULL); + py=px=0; + fy=fx=-1; + curs_set(0); + memset(show,0,size*size2); + fill(board); + shuffle(board); + while(1){ + erase(); + logo(0,0); + draw(3,0,board,show); + refresh(); + if(issolved(show)) + break; + input = getch(); + if( input==KEY_F(1) || input=='?' ) + help(); + if( input==KEY_F(2) ) + gameplay(); + if( input==KEY_MOUSE ) + mouseinput(); + if( (input=='k' || input==KEY_UP) && py>0) + py--; + if( (input=='j' || input==KEY_DOWN) && py0) + px--; + if( (input=='l' || input==KEY_RIGHT) && px