Annotation of 43BSDReno/games/backgammon/common_source/allow.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1980 Regents of the University of California.
        !             3:  * All rights reserved.
        !             4:  *
        !             5:  * Redistribution and use in source and binary forms are permitted
        !             6:  * provided that: (1) source distributions retain this entire copyright
        !             7:  * notice and comment, and (2) distributions including binaries display
        !             8:  * the following acknowledgement:  ``This product includes software
        !             9:  * developed by the University of California, Berkeley and its contributors''
        !            10:  * in the documentation or other materials provided with the distribution
        !            11:  * and in all advertising materials mentioning features or use of this
        !            12:  * software. Neither the name of the University nor the names of its
        !            13:  * contributors may be used to endorse or promote products derived
        !            14:  * from this software without specific prior written permission.
        !            15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
        !            16:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
        !            17:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            18:  */
        !            19: 
        !            20: #ifndef lint
        !            21: static char sccsid[] = "@(#)allow.c    5.4 (Berkeley) 6/1/90";
        !            22: #endif /* not lint */
        !            23: 
        !            24: #include "back.h"
        !            25: 
        !            26: movallow ()  {
        !            27: 
        !            28:        register int    i, m, iold;
        !            29:        int             r;
        !            30: 
        !            31:        if (d0)
        !            32:                swap;
        !            33:        m = (D0 == D1? 4: 2);
        !            34:        for (i = 0; i < 4; i++)
        !            35:                p[i] = bar;
        !            36:        i = iold = 0;
        !            37:        while (i < m)  {
        !            38:                if (*offptr == 15)
        !            39:                        break;
        !            40:                h[i] = 0;
        !            41:                if (board[bar])  {
        !            42:                        if (i == 1 || m == 4)
        !            43:                                g[i] = bar+cturn*D1;
        !            44:                        else
        !            45:                                g[i] = bar+cturn*D0;
        !            46:                        if (r = makmove(i))  {
        !            47:                                if (d0 || m == 4)
        !            48:                                        break;
        !            49:                                swap;
        !            50:                                movback (i);
        !            51:                                if (i > iold)
        !            52:                                        iold = i;
        !            53:                                for (i = 0; i < 4; i++)
        !            54:                                        p[i] = bar;
        !            55:                                i = 0;
        !            56:                        } else
        !            57:                                i++;
        !            58:                        continue;
        !            59:                }
        !            60:                if ((p[i] += cturn) == home)  {
        !            61:                        if (i > iold)
        !            62:                                iold = i;
        !            63:                        if (m == 2 && i)  {
        !            64:                                movback(i);
        !            65:                                p[i--] = bar;
        !            66:                                if (p[i] != bar)
        !            67:                                        continue;
        !            68:                                else
        !            69:                                        break;
        !            70:                        }
        !            71:                        if (d0 || m == 4)
        !            72:                                break;
        !            73:                        swap;
        !            74:                        movback (i);
        !            75:                        for (i = 0; i < 4; i++)
        !            76:                                p[i] = bar;
        !            77:                        i = 0;
        !            78:                        continue;
        !            79:                }
        !            80:                if (i == 1 || m == 4)
        !            81:                        g[i] = p[i]+cturn*D1;
        !            82:                else
        !            83:                        g[i] = p[i]+cturn*D0;
        !            84:                if (g[i]*cturn > home)  {
        !            85:                        if (*offptr >= 0)
        !            86:                                g[i] = home;
        !            87:                        else
        !            88:                                continue;
        !            89:                }
        !            90:                if (board[p[i]]*cturn > 0 && (r = makmove(i)) == 0)
        !            91:                        i++;
        !            92:        }
        !            93:        movback (i);
        !            94:        return (iold > i? iold: i);
        !            95: }

unix.superglobalmegacorp.com

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