Annotation of 42BSD/games/backgammon/one.c, revision 1.1

1.1     ! root        1: static char sccsid[] = "       one.c   4.1     82/05/11        ";
        !             2: 
        !             3: #include "back.h"
        !             4: 
        !             5: makmove (i)
        !             6: register int   i;
        !             7:  
        !             8: {
        !             9:        register int    n, d;
        !            10:        int             max;
        !            11: 
        !            12:        d = d0;
        !            13:        n = abs(g[i]-p[i]);
        !            14:        max = (*offptr < 0? 7: last());
        !            15:        if (board[p[i]]*cturn <= 0)
        !            16:                return (checkd(d)+2);
        !            17:        if (g[i] != home && board[g[i]]*cturn < -1)
        !            18:                return (checkd(d)+3);
        !            19:        if (i || D0 == D1)  {
        !            20:                if (n == max? D1 < n: D1 != n)
        !            21:                        return (checkd(d)+1);
        !            22:        } else  {
        !            23:                if (n == max? D0 < n && D1 < n: D0 != n && D1 != n)
        !            24:                        return (checkd(d)+1);
        !            25:                if (n == max? D0 < n: D0 != n)  {
        !            26:                        if (d0)
        !            27:                                return (checkd(d)+1);
        !            28:                        swap;
        !            29:                }
        !            30:        }
        !            31:        if (g[i] == home && *offptr < 0)
        !            32:                return (checkd(d)+4);
        !            33:        h[i] = 0;
        !            34:        board[p[i]] -= cturn;
        !            35:        if (g[i] != home)  {
        !            36:                if (board[g[i]] == -cturn)  {
        !            37:                        board[home] -= cturn;
        !            38:                        board[g[i]] = 0;
        !            39:                        h[i] = 1;
        !            40:                        if (abs(bar-g[i]) < 7)  {
        !            41:                                (*inopp)--;
        !            42:                                if (*offopp >= 0)
        !            43:                                        *offopp -= 15;
        !            44:                        }
        !            45:                }
        !            46:                board[g[i]] += cturn;
        !            47:                if (abs(home-g[i]) < 7 && abs(home-p[i]) > 6)  {
        !            48:                        (*inptr)++;
        !            49:                        if (*inptr+*offptr == 0)
        !            50:                                *offptr += 15;
        !            51:                }
        !            52:        } else {
        !            53:                (*offptr)++;
        !            54:                (*inptr)--;
        !            55:        }
        !            56:        return (0);
        !            57: }
        !            58: 
        !            59: moverr (i)
        !            60: register int   i;
        !            61: 
        !            62: {
        !            63:        register int    j;
        !            64: 
        !            65:        if (tflag)
        !            66:                curmove (20,0);
        !            67:        else
        !            68:                writec ('\n');
        !            69:        writel ("Error:  ");
        !            70:        for (j = 0; j <= i; j++)  {
        !            71:                wrint (p[j]);
        !            72:                writec ('-');
        !            73:                wrint (g[j]);
        !            74:                if (j < i)
        !            75:                        writec (',');
        !            76:        }
        !            77:        writel ("... ");
        !            78:        movback (i);
        !            79: }
        !            80: 
        !            81: 
        !            82: checkd (d)
        !            83: register int   d;
        !            84: 
        !            85: {
        !            86:        if (d0 != d)
        !            87:                swap;
        !            88:        return (0);
        !            89: }
        !            90: 
        !            91: last ()  {
        !            92:        register int    i;
        !            93: 
        !            94:        for (i = home-6*cturn; i != home; i += cturn)
        !            95:                if (board[i]*cturn > 0)
        !            96:                        return (abs(home-i));
        !            97: }
        !            98: 
        !            99: movback (i)
        !           100: register int   i;
        !           101: 
        !           102: {
        !           103:        register int    j;
        !           104: 
        !           105:        for (j = i-1; j >= 0; j--)
        !           106:                backone(j);
        !           107: }
        !           108: 
        !           109: backone (i)
        !           110: register int   i;
        !           111: 
        !           112: {
        !           113:        board[p[i]] += cturn;
        !           114:        if (g[i] != home)  {
        !           115:                board[g[i]] -= cturn;
        !           116:                if (abs(g[i]-home) < 7 && abs(p[i]-home) > 6)  {
        !           117:                        (*inptr)--;
        !           118:                        if (*inptr+*offptr < 15 && *offptr >= 0)
        !           119:                                *offptr -= 15;
        !           120:                }
        !           121:        } else  {
        !           122:                (*offptr)--;
        !           123:                (*inptr)++;
        !           124:        }
        !           125:        if (h[i])  {
        !           126:                board[home] += cturn;
        !           127:                board[g[i]] = -cturn;
        !           128:                if (abs(bar-g[i]) < 7)  {
        !           129:                        (*inopp)++;
        !           130:                        if (*inopp+*offopp == 0)
        !           131:                                *offopp += 15;
        !           132:                }
        !           133:        }
        !           134: }

unix.superglobalmegacorp.com

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