Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site dedalus.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!harvard!talcott!panda!genrad!decvax!mcnc!ncsu!ikonas!dedalus!roger From: roger@dedalus.UUCP (Roger L. Cordes Jr.) Newsgroups: net.sources.games Subject: Re: robots to "autorobots" conversion Message-ID: <711@dedalus.UUCP> Date: Wed, 31-Jul-85 13:01:07 EDT Article-I.D.: dedalus.711 Posted: Wed Jul 31 13:01:07 1985 Date-Received: Sun, 4-Aug-85 04:42:15 EDT Organization: Wm. Daniel & Assoc., Cary, N.C. Lines: 105 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