1: #include "old.h" 2: 3: int * 4: statl() 5: { 6: int *p1, *p2, *p3; 7: 8: p1 = p2 = lmp; 9: stage(); 10: mantom? bagen(): wagen(); 11: if(lmp == p1+1) 12: return(p1); 13: while(p2 != lmp) { 14: p3 = p2++; 15: if(mantom) { 16: bmove(*p2++); 17: *p3 = bstatic(0); 18: bremove(); 19: } else { 20: wmove(*p2++); 21: *p3 = wstatic(0); 22: wremove(); 23: } 24: } 25: qsort(p1, lmp); 26: return(p1); 27: } 28: 29: wstatic(f) 30: { 31: int i, j, h, (*p)(); 32: 33: h = i = 0; 34: while(p = wheur[h++]) { 35: j = (*p)(); 36: if(f) 37: printf("%4d ", j); 38: i += j; 39: } 40: if(f) 41: printf("=%4d ", i); 42: return(-i); 43: } 44: 45: bstatic(f) 46: { 47: int i, j, h, (*p)(); 48: 49: h = i = 0; 50: while(p = bheur[h++]) { 51: j = (*p)(); 52: if(f) 53: printf("%4d ", j); 54: i += j; 55: } 56: if(f) 57: printf("=%4d ", i); 58: return(-i); 59: } 60: 61: xheur(ploc) 62: int ploc; 63: { 64: int *p1, *p2, from, to, pie; 65: 66: pie = board[ploc]; 67: p1 = lmp; 68: p2 = p1; 69: mantom? wgen(): bgen(); 70: while(p2 != lmp) { 71: p2++; 72: to = *p2++ & 0377; 73: if(to == ploc) { 74: from = p2[-1] >> 8; 75: if(abs(board[from]) < abs(pie)) { 76: lmp = p1; 77: return((pval+6)[pie]/60); 78: } 79: } 80: } 81: lmp = p1; 82: return(0); 83: } 84: 85: srnd(p) 86: int p; 87: { 88: 89: srnd1(p, uleft, -9); 90: srnd1(p, uright, -7); 91: srnd1(p, dleft, 7); 92: srnd1(p, dright, 9); 93: srnd1(p, up, -8); 94: srnd1(p, left, -1); 95: srnd1(p, right, 1); 96: srnd1(p, down, 8); 97: srnd1(p, 0, 0); 98: } 99: 100: srnd1(p, m, o) 101: int p, m, o; 102: { 103: 104: if((dir[p]&m) == 0) 105: control[p+o] += 10; 106: }