1: #include "old.h"
2:
3: rline()
4: {
5: char *p1;
6: int c;
7:
8: loop0:
9: p1 = sbuf;
10: loop:
11: c = getchar();
12: if(c <= 0)
13: exit(0);
14: if(c == '#')
15: goto loop0;
16: if(c != '*') {
17: *p1++ = c;
18: goto loop;
19: }
20: switch(getchar()) {
21:
22: case '#':
23: goto loop0;
24:
25: case '*':
26: if(p1 != sbuf+4) {
27: printf("bad input\n");
28: goto loop0;
29: }
30: sbuf[0] += 'a'-'1';
31: sbuf[2] += 'a'-'1';
32: *p1++ = '\0';
33: return;
34:
35: case '0':
36: exit(0);
37:
38: case '1':
39: spread("");
40: return;
41:
42: case '2':
43: spread("first");
44: return;
45:
46: case '3':
47: spread("clock");
48: return;
49:
50: case '4':
51: spread("score");
52: return;
53:
54: case '5':
55: spread("remove");
56: return;
57:
58: case '6':
59: spread("repeat");
60: return;
61:
62: case '7':
63: spread("save");
64: return;
65:
66: case '8':
67: spread("restore");
68: return;
69: }
70: printf("bad option\n");
71: goto loop;
72: }
73:
74: spread(s)
75: char *s;
76: {
77: char *p;
78:
79: p = sbuf;
80: while(*p++ = *s++) ;
81: }
82:
83: pboard()
84: {
85: int i, x, y, c, p;
86:
87: i = 0;
88: x = 8;
89: while(x--) {
90: y = 8;
91: while(y--) {
92: p = board[i++];
93: if(p == 0) {
94: printf("space\n");
95: continue;
96: }
97: if(p < 0)
98: printf("white "); else
99: printf("black ");
100: putpiece("kqrbnp pnbrqk"[p+6]);
101: }
102: pause();
103: printf("end\n");
104: pause();
105: }
106: }
107:
108: putpiece(p)
109: {
110: char *s;
111:
112: s = "god only knows";
113: switch(p) {
114:
115: case 'p':
116: s = "pawn";
117: break;
118:
119: case 'n':
120: s = "knight";
121: break;
122:
123: case 'b':
124: s = "bishop";
125: break;
126:
127: case 'r':
128: s = "rook";
129: break;
130:
131: case 'q':
132: s = "queen";
133: break;
134:
135: case 'k':
136: s = "king";
137: break;
138: }
139: printf("%s\n", s);
140: }
141:
142: out1(m)
143: {
144: putnumb(moveno);
145: pause();
146: out(m);
147: pause();
148: }
149:
150: out(m)
151: int m;
152: {
153: int from, to, epf, pmf;
154:
155: from = m>>8;
156: to = m&0377;
157: mantom? bmove(m): wmove(m);
158: epf = pmf = 0;
159: switch(amp[-1]) {
160:
161: case 0:
162: case 1:
163: stdp(board[to]);
164: ed:
165: printf("at\n");
166: stdb(from);
167: if(amp[-2]) {
168: printf("takes\n");
169: stdp(amp[-2]);
170: printf("at\n");
171: } else
172: printf("to\n");
173: stdb(to);
174: break;
175:
176: case 3:
177: printf("castle queen side\n");
178: break;
179:
180: case 2:
181: printf("castle king side\n");
182: break;
183:
184: case 4:
185: epf = 1;
186: putpiece('p');
187: goto ed;
188:
189: case 5:
190: pmf = 1;
191: putpiece('p');
192: goto ed;
193: }
194: if(pmf) {
195: printf("becomes\n");
196: putpiece('q');
197: }
198: if(epf) {
199: printf("en passent\n");
200: }
201: if(check())
202: printf("check\n");
203: mantom? bremove(): wremove();
204: }
205:
206: stdp(p)
207: int p;
208: {
209:
210: if(p < 0)
211: p = -p;
212: p = "ppnbrqk"[p];
213: putpiece(p);
214: }
215:
216: stdb(b)
217: int b;
218: {
219: int r, f;
220:
221: r = b/8;
222: if((f = b%8) < 4)
223: putpiece('q'); else {
224: putpiece('k');
225: f = 7-f;
226: }
227: f = "rnb\0"[f];
228: if(f)
229: putpiece(f);
230: putnumb(mantom? r+1: 8-r);
231: }
232:
233: prtime(a, b)
234: {
235:
236: printf("compute time is\n");
237: putnumb(a);
238: printf("real time is\n");
239: putnumb(b);
240: pause();
241: }
242:
243: putnumb(n)
244: {
245:
246: if(n <= 12) {
247: putdig(n);
248: putchar('\n');
249: return;
250: }
251: if(n <= 19) {
252: putdig(n+1);
253: printf("teen\n");
254: return;
255: }
256: if(n >= 100) {
257: putnumb(n/100);
258: printf("hundred\n");
259: n %= 100;
260: if(n)
261: putnumb(n);
262: return;
263: }
264: putdig(n/10+11);
265: printf("tee\n");
266: n %= 10;
267: if(n)
268: putnumb(n);
269: }
270:
271: putdig(n)
272: {
273: char *s;
274:
275: s = "god only knows";
276: switch(n) {
277:
278: case 0:
279: s = "zero";
280: break;
281:
282: case 1:
283: s = "one";
284: break;
285:
286: case 2:
287: s = "two";
288: break;
289:
290: case 3:
291: s = "three";
292: break;
293:
294: case 4:
295: case 15:
296: s = "four";
297: break;
298:
299: case 5:
300: s = "five";
301: break;
302:
303: case 6:
304: case 17:
305: s = "six";
306: break;
307:
308: case 7:
309: case 18:
310: s = "seven";
311: break;
312:
313: case 8:
314: case 19:
315: s = "eight";
316: break;
317:
318: case 9:
319: case 20:
320: s = "nine";
321: break;
322:
323: case 10:
324: s = "ten";
325: break;
326:
327: case 11:
328: s = "eleven";
329: break;
330:
331: case 12:
332: s = "twelve";
333: break;
334:
335: case 13:
336: s = "twen";
337: break;
338:
339: case 14:
340: s = "thir";
341: break;
342:
343: case 16:
344: s = "fif";
345: break;
346: }
347: printf(s);
348: }
349:
350: pause()
351: {
352:
353: printf("...\n");
354: }
355:
356: score1(m)
357: {
358: if(!mantom) {
359: putnumb(moveno);
360: pause();
361: }
362: out(m);
363: pause();
364: }
365:
366: score()
367: {
368: int *p;
369:
370: p = amp;
371: while(amp[-1] != -1) {
372: mantom? wremove(): bremove();
373: decrem();
374: }
375: posit(score1, p);
376: printf("the end\n");
377: }
Defined functions
out
defined in line
150; used 5 times
out1
defined in line
142; used 1 times
rline
defined in line
3; used 1 times
stdb
defined in line
216; used 2 times
stdp
defined in line
206; used 2 times