roger@dedalus.UUCP (Roger L. Cordes Jr.) (07/31/85)
The following will convert `robots' as posted by
Stephen J. Muir to `nrobots', which allows the robots to
keep moving, even if you don't type a command.
At the beginning of each level, you are given the
chance to type a command before the robots start moving.
Furthermore, commands are processed in such a way that
you may move out of danger (i.e., faster than the robots move).
It is assumed that you have available the ioctl(2)
call FIONREAD, which returns the number of characters pending
for an input file descriptor.
You might modify the delay timer if performance seems
inadequate for an enjoyable game: this has been optimized for
our situation.
Our highest score to date in robots is 1,693,950 (level 15);
for nrobots, it is 35,696 (level 7).
We do not believe that `nrobots' is an improvement over
`robots' in any way.
R.
above main:
[1]: modify the score file definitions as indicated below:
#ifdef NROBOTS
# define HOF_FILE "/usr/games/lib/nrobots_hof"
# define TMP_FILE "/usr/games/lib/nrobots_tmp"
#else
# define HOF_FILE "/usr/games/lib/robots_hof" /* existing definition */
# define TMP_FILE "/usr/games/lib/robots_tmp" /* existing definition */
#endif
[2]: add a new global:
#ifdef NROBOTS
char numero_uno = 1;
#endif
in main:
[3]: within the first `for (;;)', at the beginning, add the following
statement:
#ifdef NROBOTS
numero_uno = 1;
#endif
[4]: within the `for (;;)' within the first `for (;;)' loop, add a
preprocessor condition for the following (existing) statement:
#ifndef NROBOTS
command();
#endif
in command():
[5]: within the `if (bad_move)' block, modify the `goto retry' statement
as follows:
#ifdef NROBOTS
return; /* robots still advance */
#else
goto retry; /* existing statement */
#endif
in robots():
[6]: insert the following between the end of the original data declarations
and the first statement:
#ifdef NROBOTS
int i;
long npending;
if ( numero_uno || running )
{
numero_uno = 0;
command();
}
else if ( !running && !last_stand )
for ( i=0; i<6000; i++ ) /* funky delay timer */
;
ioctl(0,FIONREAD,&npending); /* any tty input pending ? */
if ( npending > (long)0 )
return(command()); /* enable out-running */
#endif
[7]: and add a new last statement to robots():
#ifdef NROBOTS
refresh();
#endif
in Makefile:
[8]: add the following (actually, copy the lines for `robots' and
`install' and modify as appropriate for your machine):
nrobots: robots.c
cc $(CFLAGS) -DNROBOTS robots.c -o nrobots -lcurses -ltermcap
ninstall: nrobots
cp nrobots /usr/games/nrobots
chmod 4755 /usr/games/nrobots
touch /usr/games/lib/nrobots_hof
touch /usr/games/lib/nrobots_tmp
[9]: make ninstall