1: #include "old.h"
2:
3: /*
4: * mobility
5: * 1 for each potential move
6: */
7:
8: wheur1()
9: {
10: int *p1, *p2, *p3, i;
11: int pto;
12:
13: if(amp[-2]) {
14: i = amp[-3];
15: pto = board[i];
16: board[i] = 0;
17: }
18: p1 = lmp;
19: wgen();
20: p2 = lmp;
21: lmp = p1;
22: bgen();
23: p3 = lmp;
24: lmp = p1;
25: i = p2-p3;
26: i >>= 1;
27: if(amp[-2])
28: board[amp[-3]] = pto;
29: return(i);
30: }
31:
32: /*
33: * opening 'goodies'
34: */
35:
36: wheur2()
37: {
38: int i;
39:
40: i = 0;
41: if(game > 2) return(i);
42: /*
43: * minor pieces out
44: * knights before bishops
45: */
46: i += 9*((board[57] != -2)+
47: (board[62] != -2));
48: i += 8*((board[58] != -3)+
49: (board[61] != -3));
50: /*
51: * blocked central pawns
52: */
53: if(board[51] == -1 && board[51-8]!=0) i -= 10;
54: if(board[52] == -1 && board[52-8]!=0) i -= 10;
55: return(i);
56: }
57:
58: /*
59: * castle
60: */
61:
62: wheur3()
63: {
64: int i;
65:
66: i = 0;
67: /*
68: * queenside ability
69: */
70: if(flag&02 && board[48]== -1 && board[49]== -1 && board[50]== -1)
71: i += 20;
72: /*
73: * kingside ability
74: */
75: if(flag&01 && board[53]== -1 && board[54]== -1 && board[55]== -1)
76: i += 20;
77: /*
78: * if both
79: */
80: if(i == 40)
81: i = 22;
82: /*
83: * if castled,
84: * keep pawns in
85: */
86: if(wkpos==58)
87: if(board[50]== -1 && (board[48]== -1 || board[48-8]== -1) &&
88: (board[49]== -1 || board[49-8]== -1))
89: i += 40;
90: if(wkpos==62)
91: if(board[53]== -1 && (board[54]== -1 || board[54-8]== -1) &&
92: (board[55]== -1 || board[55-8]== -1))
93: i += 40;
94: return(i);
95: }
96:
97: /*
98: * prance
99: * a percentage if the
100: * piece on the move
101: * can be driven back
102: * by a smaller piece
103: */
104:
105: wheur4()
106: {
107: int *p1, *p2, ploc, i;
108:
109: if(amp[-1] != 1) return(0);
110: ploc = amp[-3];
111: if(board[ploc] == -1) return(0);
112: if(xheur(ploc)) return(0);
113: p1 = lmp;
114: p2 = p1;
115: bagen();
116: i = 0;
117: while(p2 != lmp) {
118: p2++;
119: bmove(*p2++);
120: i = xheur(ploc);
121: bremove();
122: if(i)
123: break;
124: }
125: lmp = p1;
126: return(i);
127: }
128:
129: /*
130: * control
131: * center control
132: * opening
133: * beginning
134: * king control
135: * middle
136: * end
137: */
138:
139: wheur5()
140: {
141: int i, j, k;
142: int s, n, d, pto;
143:
144: if(amp[-2]) {
145: i = amp[-3];
146: pto = board[i];
147: board[i] = 0;
148: }
149: i = 64;
150: while(i--)
151: control[i] = 0;
152: if(game < 2) {
153: i = 64;
154: while(i--)
155: control[i] += center[i];
156: }
157: if(mantom) {
158: if((flag&03)==0)
159: srnd(wkpos);
160: } else {
161: if((flag&030)==0)
162: srnd(bkpos);
163: }
164: i = 64;
165: s = 0;
166: while(i--) {
167: n = control[i]*100;
168: attack(i);
169: j = 0;
170: while(k = attacv[j++]) {
171: d = (pval+6)[k];
172: if(d < 0)
173: s -= n/(-d); else
174: s += n/d;
175: }
176: }
177: if(amp[-2])
178: board[amp[-3]] = pto;
179: return(-s);
180: }
181:
182: /*
183: * mate threat
184: * minus for captures
185: */
186: wheur6()
187: {
188: int i;
189:
190: i = 0;
191: *amp++ = -1;
192: if(wattack(bkpos))
193: if(mate(2, 0))
194: i += 15;
195: amp--;
196: return(i);
197: }
Defined functions
wheur1
defined in line
8; used 3 times