Annotation of 43BSD/games/robots/rnd_pos.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1980 Regents of the University of California.
        !             3:  * All rights reserved.  The Berkeley software License Agreement
        !             4:  * specifies the terms and conditions for redistribution.
        !             5:  */
        !             6: 
        !             7: #ifndef lint
        !             8: static char sccsid[] = "@(#)rnd_pos.c  5.1 (Berkeley) 5/30/85";
        !             9: #endif not lint
        !            10: 
        !            11: # include      "robots.h"
        !            12: 
        !            13: # define       IS_SAME(p,y,x)  ((p).y != -1 && (p).y == y && (p).x == x)
        !            14: 
        !            15: /*
        !            16:  * rnd_pos:
        !            17:  *     Pick a random, unoccupied position
        !            18:  */
        !            19: COORD *
        !            20: rnd_pos()
        !            21: {
        !            22:        static COORD    pos;
        !            23:        static int      call = 0;
        !            24:        register int    i = 0;
        !            25: 
        !            26:        do {
        !            27:                pos.y = rnd(Y_FIELDSIZE - 1) + 1;
        !            28:                pos.x = rnd(X_FIELDSIZE - 1) + 1;
        !            29:                refresh();
        !            30:        } while (Field[pos.y][pos.x] != 0);
        !            31:        call++;
        !            32:        return &pos;
        !            33: }
        !            34: 
        !            35: rnd(range)
        !            36: int    range;
        !            37: {
        !            38:        unsigned int    rand();
        !            39: 
        !            40:        return rand() % range;
        !            41: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.