Move 1988-2004 entries into subdirs
We we move 1988-2004 entries from all of a year's winning entries in a single directory to each winner being in their own sub-directory under the given year directory.
This commit is contained in:
1 parent
1e82e8aa3e
commit
d2a42f42e8
478 files changed
No files matched your search
+121
@@ -0,0 +1,121 @@
|
||||
#include <unistd.h>
|
||||
#include <curses.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#define o0(M,W) mvprintw(W,M?M-1:M,"%s%s ",M?" ":"",_)
|
||||
#define O0(M,W) M##M=(M+=W##M)-W##M
|
||||
#define l1(M,W) M.tv_##W##sec
|
||||
#define L1(m,M,l,L,o,O) for(L=l;L--;)((char*)(m))[o]=((char*)(M))[O]
|
||||
#define I1 lL,(struct sockaddr*)&il
|
||||
#define i1 COLS
|
||||
#define j LINES
|
||||
#define L_ ((j%2)?j:j-1)
|
||||
|
||||
fd_set I;struct socka\
|
||||
ddr_in il;struct host\
|
||||
ent*LI; struct timeval
|
||||
IL,l;char L[9],_[1<<9]
|
||||
;void ___(int __
|
||||
){_[__--]=+0;if(
|
||||
++__)___(--__);_
|
||||
[__]='=';}double
|
||||
o,oo=+0,Oo=+0.2;
|
||||
long O,OO=0,oO=1
|
||||
,ii,iI,Ii,Ll,lL,
|
||||
II=sizeof(il),Il
|
||||
,ll,LL=0,i=0,li,
|
||||
lI;int main(int\
|
||||
iL,char *Li[]){\
|
||||
initscr();cbreak
|
||||
();noecho();nonl
|
||||
();___(lI=i1/4);
|
||||
_[0]='[';_[lI-1]
|
||||
=']';L1(&il,&_,\
|
||||
II,O,+O,+lI);il.
|
||||
sin_port=htons((
|
||||
unsigned long)(\
|
||||
PORT&0xffff));lL
|
||||
=l_;if(iL=!--iL)
|
||||
{il. sin_addr .\
|
||||
s_addr=0;bind(I1
|
||||
,II);listen(lL,5
|
||||
);lL=accept(I1,&
|
||||
II);}else{oO-=2;
|
||||
LI=gethostbyname
|
||||
(Li[1]);L1(&(il.
|
||||
sin_addr),(*LI).
|
||||
h_addr_list[0],\
|
||||
LI->h_length,iI,
|
||||
iI,iI);(*(&il)).
|
||||
sin_family=(&(*\
|
||||
LI))->h_addrtype
|
||||
;connect(I1,II);
|
||||
}ii=Ii=(o=i1*0.5
|
||||
)-lI/2;iI=L_-1;O
|
||||
=li=L_*0.5;while
|
||||
(_){mvaddch(+OO,
|
||||
oo,' ');o0(ii,iI
|
||||
);o0(Ii,Il-=Il);
|
||||
mvprintw(li-1,Il
|
||||
,"%d\n\n%d",i,LL
|
||||
);mvhline(li,+0,
|
||||
'-',i1);mvaddch(
|
||||
O,o,'*');move(li
|
||||
,Il);refresh();\
|
||||
timeout(+SPEED);
|
||||
gettimeofday(&IL
|
||||
,+0);Ll=getch();
|
||||
timeout(0);while
|
||||
(getch()!=ERR);\
|
||||
if(Ll=='q'&&iL)\
|
||||
write(lL,_+1,1);
|
||||
if(ii>(ll=0)&&Ll
|
||||
==','){write(lL,
|
||||
_,-(--Il));}else
|
||||
if(Ll=='.'&&ii+\
|
||||
lI<i1){write(lL,
|
||||
_+lI,++Il);}else
|
||||
if(iL||!Il)write
|
||||
(lL,_+lI-1,4-3);
|
||||
gettimeofday(&l,
|
||||
0);II=((II=l1(IL
|
||||
,)+(l1(l,u)-=l1(
|
||||
IL,u))-l1(l,)+(\
|
||||
l1(l,)-=l1(IL,))
|
||||
)<0)?1+II-l1(l,)
|
||||
+1e6+(--l1(l,)):
|
||||
II;usleep((II+=\
|
||||
l1(l,)*1e6-SPEED
|
||||
*1e3)<0?-II:+0);
|
||||
if(Ll=='q'&&!iL)
|
||||
break;FD_ZERO(&I
|
||||
);FD_SET(lL,&I);
|
||||
memset(&*&IL,ll,
|
||||
sizeof(l));if((\
|
||||
Ll=select(lL+1,&
|
||||
I,0,0,&IL)));{if
|
||||
(read(lL,&L,ll+1
|
||||
)){if(!*L){ll++;
|
||||
}else if(*L==ll[
|
||||
_]){ll--; }else\
|
||||
if(*(&(*L))==1[_
|
||||
]){break;}}else{
|
||||
break;}}O0(o,O);
|
||||
O0(O,o);if(o<0){
|
||||
o*=-1;Oo*=-1;}if
|
||||
(o>i1){o=i1+i1-o
|
||||
;Oo*=-1;}if(o>=(
|
||||
Ii+=ll)&&O<1&&oO
|
||||
<0&&o<Ii+lI){O=2
|
||||
;oO=~--oO;Oo+=ll
|
||||
*4e-1;}if(O<0){O
|
||||
=iI;LL++;}if(o>=
|
||||
(ii+=Il)&&O>iI-1
|
||||
&&oO>0&&o<ii+lI){O=iI-
|
||||
2;oO=~--oO;Oo+=Il*4e-1
|
||||
;}if(+O>+iI){O-=O;i++;
|
||||
}}endwin();return(0);}
|
||||
|
||||
@@ -0,0 +1,195 @@
|
||||
Best Curses Game:
|
||||
|
||||
Kevin Pulo
|
||||
School of Information Technologies
|
||||
Madsen Building F09
|
||||
University of Sydney, NSW, 2006
|
||||
Australia
|
||||
|
||||
http://www.kev.pulo.com.au/
|
||||
|
||||
|
||||
Judge's Remarks:
|
||||
|
||||
To build:
|
||||
|
||||
make kev
|
||||
|
||||
Try:
|
||||
|
||||
./kev
|
||||
|
||||
and then in another window,
|
||||
|
||||
./kev localhost
|
||||
|
||||
Continuing with this year's "retro game" theme, this is another old game;
|
||||
arguably, one of the oldest. Requires a functioning network, and curses.
|
||||
|
||||
The graphics aren't the impressive part; the graphics and network are.
|
||||
How many games come out at $50 and still require you to wait for a patch
|
||||
to come out before you can play multiplayer? This one works out of the
|
||||
box.
|
||||
|
||||
|
||||
Selected Author's Comments:
|
||||
|
||||
NETWORK P*NG!
|
||||
[=================]
|
||||
|
||||
Kevin Pulo
|
||||
kev@pulo.com.au
|
||||
|
||||
|
||||
REQUIREMENTS
|
||||
------------
|
||||
|
||||
* TCP sockets
|
||||
* curses
|
||||
* usleep
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
This program is a two-player networked version of the eighties
|
||||
arcade classic, "pong". It uses standard TCP sockets to
|
||||
communicate over the net, and ncurses for display. It supports
|
||||
variable terminal sizes (though both players must have the same
|
||||
terminal size) and game speeds. Each player has a paddle to hit
|
||||
the ball, and you get points for getting the ball past your
|
||||
opponent's paddle. It's pretty fun! :)
|
||||
|
||||
|
||||
RUNNING
|
||||
-------
|
||||
|
||||
Run the server first without any command line arguments, ie.
|
||||
|
||||
./kev
|
||||
|
||||
Then run the client with a single command line argument which is
|
||||
the name of the machine running the server, eg.
|
||||
|
||||
./kev localhost
|
||||
|
||||
Make sure that the terminals on both ends are the same size.
|
||||
Also, the TCP port number specified in the build file mustn't be
|
||||
blocked by a firewall.
|
||||
|
||||
Here's a good quick example to see it in action on your own
|
||||
machine, assuming you have Xwindows:
|
||||
|
||||
xterm -geometry 80x40 -fg green -bg black -fn 9x15bold -e ./kev &
|
||||
xterm -geometry 80x40 -fg green -bg black -fn 9x15bold -e ./kev localhost&
|
||||
|
||||
|
||||
PLAYING
|
||||
-------
|
||||
|
||||
Your paddle is the one at the bottom of the screen, your opponent
|
||||
is at the top. To move your paddle left, hold down ',' (ie. '<'
|
||||
but don't press shift). To move your paddle right, hold down '.'.
|
||||
To quit, either player may press 'q'.
|
||||
|
||||
The current score is shown on the left side of the halfway line.
|
||||
Your score is the lower number, your opponents score is the upper
|
||||
number. Your score is the number of times your opponent has
|
||||
missed the ball.
|
||||
|
||||
You can control the speed of the ball by the motion of your paddle
|
||||
when the ball hits it. If your paddle is still, then the ball
|
||||
just bounces normally off it. If your paddle is moving in the
|
||||
same direction as the ball, then the ball's speed in that
|
||||
direction will increase. If your paddle is moving in the opposite
|
||||
direction to the ball, then the ball's speed in that direction
|
||||
will decrease (or if the ball is going slowly enough, it'll turn
|
||||
around).
|
||||
|
||||
You might want to increase your keyboard repeat rate before
|
||||
playing. On the Linux console try "kbdrate -r 24.0 -d 250"
|
||||
(kbdrate might be "hidden" from normal users in /sbin, and you
|
||||
might need to be root anyway), in Xwindows try "xset r rate 250
|
||||
24" (find out your current rate first with "xset q", so that you
|
||||
can reset it later).
|
||||
|
||||
Look below in the Building section for info on how to speed up or
|
||||
slow down the game (useful if your increase or decrease the
|
||||
terminal size).
|
||||
|
||||
|
||||
BUILDING
|
||||
--------
|
||||
|
||||
Just run the Makefile as above. The "SPEED" variable in the Makefile
|
||||
controls the speed of the game (defaults to 50). This speed is
|
||||
the delay between frames in milliseconds. Thus a value of 0 will
|
||||
make the game go as fast as your network can handle, and values
|
||||
less than 50 are useful for larger terminals or more exciting
|
||||
games. The program needs bandwidth equal to 1/s bytes per second
|
||||
(where "s" is the speed value). Any latency on the network will
|
||||
be added to s - so you should probably subtract any latency from
|
||||
the value of s you want to have. Given that loopback and fast
|
||||
Ethernet LANs are both much less than 1ms of latency, you should
|
||||
only need to worry about this if you plan on playing over a slower
|
||||
link like a cable modem, DSL, or (God-forbid) dialup.
|
||||
|
||||
The TCP port to use for network communications is specified by the
|
||||
"PORT" variable in the Makefile. If the default of 5455 is
|
||||
blocked for whatever reason, you can change it to something else.
|
||||
Of course if you use a port < 1024, you'll need to be root.
|
||||
|
||||
|
||||
OBFUSCATION
|
||||
-----------
|
||||
|
||||
The program's broad structure is fairly straightforward, but
|
||||
individual tasks are rarely done in a straightforward manner. ;)
|
||||
|
||||
Identifier names have mostly been chosen to resemble paddles and
|
||||
balls, and to generally decrease readability.
|
||||
|
||||
The source has been cleverly formatted to resemble one of the
|
||||
paddles from the game, rotated 90 degrees. ;) (The "source
|
||||
paddle" has approximately the same aspect ratio as the game at 80
|
||||
columns wide, which is 1:10.)
|
||||
|
||||
Finally, the number of "non-whitespace characters" (as defined by
|
||||
the rules) in the file is exactly 2048, which I think is rather
|
||||
unexpectedly cool. :)
|
||||
|
||||
|
||||
BUGS
|
||||
----
|
||||
|
||||
There are 3 warnings when I compile with gcc 2.95.3 (-Wall -ansi
|
||||
-pedantic) on my Linux system, but all are completely harmless.
|
||||
|
||||
I don't like the curses and/or termcaps/terminfos on IRIX and
|
||||
Solaris (the only two non-Linux systems I have access to).
|
||||
Despite calling timeout(0), notimeout(win, TRUE), nodelay(win,
|
||||
TRUE) and/or keypad(win, FALSE), it still seems to force a delay
|
||||
into calls to getch() - I'm guessing at a termcap/terminfo level.
|
||||
At any rate, I can't seem to force no delay. This is a shame,
|
||||
because it basically plays havoc with the input code, particularly
|
||||
the read-ahead canceller. It still works, but not nearly as well
|
||||
(keypresses are dodgey and holding down keys doesn't always work),
|
||||
and so I _much_ prefer and recommend Linux libncurses.
|
||||
|
||||
Sometimes when 'q' is pressed in one, the other will crash out
|
||||
with "Broken pipe".
|
||||
|
||||
If the specified port can't be bound or connected to, the program
|
||||
segfaults.
|
||||
|
||||
If your terminal is too wide (we're talking gigantic here - over
|
||||
500 characters wide) then the program can segfault. It's also
|
||||
possible to crash the program a player scores over a billion
|
||||
points (1e9). Maybe you can consider that the goal... ;)
|
||||
|
||||
If you run the client and server on different architectures, both
|
||||
architectures need to have the same character systems (ie. don't
|
||||
try mixing ASCII and EBCDIC). It is independent of endianness
|
||||
though.
|
||||
|
||||
|
||||
Reference in new issue
Block a user