DON'T EVER DO THIS!!!

Larry Wall lwall at sdcrdcf.UUCP
Wed Aug 7 11:14:08 AEST 1985


[Warning: long quote--hit TAB in rn if not interested]

In article <536 at aicchi.UUCP> ignatz at aicchi.UUCP (Ihnat) writes:
>I won't mention what program this comes from; it's been posted to the
>net, and (functionally) is quite interesting and enjoyable.  BUT--it
>mysteriously broke the 'C' compiler on an Altos 586 running Xenix 3.0b,
>and when I looked at it---well, you take a look.  DON'T *EVER* DO THIS!!
>		 .
>		 .
>		 .
>        while (--count &&
>               (!(rand_mod(prob)) ||
>                (obj = occupant[y=(curkl->posy+curkl->vely+YSIZE00)%YSIZE]
>                               [x=(curkl->posx+curkl->velx+XSIZE00)%XSIZE]) &&
>                (obj->type == Star ||
>                 ((rand_mod(100) <= smarts) &&
>                  !obj->vely && !obj->velx &&
>                  (obj->image == 'o' ||
>                   obj->image == 'O' ||
>                   obj->image == 'X'
>                  )
>                 ) ||
>                 (obj->type == Web &&
>                  (curkl->image != 'T' ||
>                   (count > 5 && obj->image ==
>                    (curkl->vely?
>                     (curkl->velx?
>                      (curkl->velx==curkl->vely?
>                       '\\'
>                      :
>                       '/'
>                      )
>                     :
>                      '|'
>                     )
>                    :
>                     '-'
>                    )
>                   )
>                  )
>                 )
>                )
>               )
>              ) {
>            if (massacre && curkl->image != 'T') {
>                curkl->vely = rand_mod(7) - 3;
>                curkl->velx = rand_mod(7) - 3;
>            }
>            else if (curkl->energy >= 2500 && curkl->image != 'T') {
>                curkl->vely = rand_mod(5) - 2;
>                curkl->velx = rand_mod(5) - 2;
>            }
>            else {
>                curkl->vely = rand_mod(3) - 1;
>                curkl->velx = rand_mod(3) - 1;
>            }
>        }
>================================> *WHEW!* <==============================

Me, oh, my.  My little skeleton in the closet has come marching out.  Blush.
Dave wouldn't say the name of the program, bless his heart, but they do say
confession is good for the soul.  The name of that program is warp, one of
my earlier efforts.  The earliest versions of warp were in, shudder, BASIC.
(Well, BASIC+, actually.)  C was such a breath of fresh air--I guess I went
wild or something...

The above doesn't look nearly so bad in pseudo-code:

	while (it's reasonable to think about changing enemy velocities)
		change enemy velocities;

Back when the only kind of enemies were Klingons, the thing was much simpler.
Then we added Romulans, Gorns, Tholians, planet munchers, web, Apollo,
homing and proximity torpedoes, difficulty levels, massacre mode, etc, and
it got a wee bit more complicated.  A brilliant example of stepwise
refinement, in fact.  :-)

One of these days when you guys stop pestering me about rn, I'll add the
Space Amoeba, unless warp turns into a Space Amoeba of its own accord...
Maybe I can retrofit a bit of wisdom into it at the same time.

Yah, don't *ever* do that.  (But if you do, have fun!)

Larry Wall
{allegra,burdvax,cbosgd,hplabs,ihnp4,sdcsvax}!sdcrdcf!lwall



More information about the Comp.lang.c mailing list