summaryrefslogtreecommitdiff
path: root/games/exchess/patches/patch-ai
blob: bffa3fc944050dea16c0dadcb2bd3df86452a52d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
$NetBSD: patch-ai,v 1.2 2011/11/25 21:52:33 joerg Exp $

--- exmove.cpp.orig	2000-04-01 07:46:42.000000000 +0000
+++ exmove.cpp
@@ -8,7 +8,7 @@
 #include "const.h"
 #include "funct.h"
 #include "hash.h"
-#include "iostream.h"
+#include <iostream>
 
 /* Hash code variables */
 extern hash_rec *hash_table;    // pointer to hash_table
@@ -52,8 +52,8 @@ int exec_move(position *p, move emove, i
                 { return 0; }
               p->sq[5] = p->sq[7];
               p->sq[7] = empty;
-              or(p->hcode, hval[WROOK][5]);
-              or(p->hcode, hval[WROOK][7]);
+              hash_or(p->hcode, hval[WROOK][5]);
+              hash_or(p->hcode, hval[WROOK][7]);
               p->has_castled[1] = 1;
               /* update piece list */ 
               for(pi=1;pi<=p->plist[p->wtm][ROOK][0];pi++)
@@ -69,8 +69,8 @@ int exec_move(position *p, move emove, i
                 { return 0; }
               p->sq[3] = p->sq[0];
               p->sq[0] = empty;
-              or(p->hcode, hval[WROOK][3]);
-              or(p->hcode, hval[WROOK][0]);
+              hash_or(p->hcode, hval[WROOK][3]);
+              hash_or(p->hcode, hval[WROOK][0]);
               p->has_castled[1] = 1;
               /* update piece list */
               for(pi=1;pi<=p->plist[p->wtm][ROOK][0];pi++)
@@ -86,8 +86,8 @@ int exec_move(position *p, move emove, i
                 { return 0; }
               p->sq[61] = p->sq[63];
               p->sq[63] = empty;
-              or(p->hcode, hval[BROOK][61]);
-              or(p->hcode, hval[BROOK][63]);
+              hash_or(p->hcode, hval[BROOK][61]);
+              hash_or(p->hcode, hval[BROOK][63]);
               p->has_castled[0] = 1;
               /* update piece list */
               for(pi=1;pi<=p->plist[p->wtm][ROOK][0];pi++)
@@ -103,8 +103,8 @@ int exec_move(position *p, move emove, i
                 { return 0; }
               p->sq[59] = p->sq[56];
               p->sq[56] = empty;
-              or(p->hcode, hval[BROOK][59]);
-              or(p->hcode, hval[BROOK][56]);
+              hash_or(p->hcode, hval[BROOK][59]);
+              hash_or(p->hcode, hval[BROOK][56]);
               p->has_castled[0] = 1;
               /* update piece list */
               for(pi=1;pi<=p->plist[p->wtm][ROOK][0];pi++)
@@ -125,7 +125,7 @@ int exec_move(position *p, move emove, i
 
   if(p->sq[emove.b.to].type) {
    // Remove hashcode for the target square 
-   or(p->hcode, hval[ID(p->sq[emove.b.to])][emove.b.to]);   
+   hash_or(p->hcode, hval[ID(p->sq[emove.b.to])][emove.b.to]);   
    // Remove piece from piece list
    for(pi=1;pi<=p->plist[p->wtm^1][p->sq[emove.b.to].type][0];pi++)
     if(p->plist[p->wtm^1][p->sq[emove.b.to].type][pi] == emove.b.to) {
@@ -143,8 +143,8 @@ int exec_move(position *p, move emove, i
   // Move the new piece to the target square
   p->sq[emove.b.to] = p->sq[emove.b.from];
   // Update the hash code to reflect the move
-  or(p->hcode, hval[ID(p->sq[emove.b.from])][emove.b.from]);
-  or(p->hcode, hval[ID(p->sq[emove.b.from])][emove.b.to]);
+  hash_or(p->hcode, hval[ID(p->sq[emove.b.from])][emove.b.from]);
+  hash_or(p->hcode, hval[ID(p->sq[emove.b.from])][emove.b.to]);
   // Original square is now empty
   p->sq[emove.b.from] = empty;
 
@@ -152,7 +152,7 @@ int exec_move(position *p, move emove, i
   if(emove.b.type&EP) {
     if(p->wtm) {
       p->sq[emove.b.to-8] = empty;
-      or(p->hcode, hval[BPAWN][emove.b.to-8]);
+      hash_or(p->hcode, hval[BPAWN][emove.b.to-8]);
       // Update piece lists 
       for(pi=1;pi<=p->plist[p->wtm^1][PAWN][0];pi++)
         if(p->plist[BLACK][PAWN][pi] == emove.b.to-8) {
@@ -163,7 +163,7 @@ int exec_move(position *p, move emove, i
         }
     } else {
       p->sq[emove.b.to+8] = empty;
-      or(p->hcode, hval[WPAWN][emove.b.to+8]);
+      hash_or(p->hcode, hval[WPAWN][emove.b.to+8]);
       // Update piece lists
       for(pi=1;pi<=p->plist[p->wtm^1][PAWN][0];pi++)
        if(p->plist[WHITE][PAWN][pi] == emove.b.to+8) {
@@ -189,7 +189,7 @@ int exec_move(position *p, move emove, i
   // if the move is a promotion, promote it
   if(emove.b.type&PROMOTE) {
     // Remove the pawn from the hash code
-    or(p->hcode, hval[ID(p->sq[emove.b.to])][emove.b.to]);
+    hash_or(p->hcode, hval[ID(p->sq[emove.b.to])][emove.b.to]);
     // Change the piece type to the promoted piece
     p->sq[emove.b.to].type = emove.b.promote;
     // Add the new piece to the piece lists
@@ -206,7 +206,7 @@ int exec_move(position *p, move emove, i
     // adjust material score
     p->material += value[emove.b.promote] - value[PAWN];
     // add piece to hash code 
-    or(p->hcode, hval[ID(p->sq[emove.b.to])][emove.b.to]);
+    hash_or(p->hcode, hval[ID(p->sq[emove.b.to])][emove.b.to]);
     // adjust total piece count
     p->pieces[p->wtm]++;
   }
@@ -214,11 +214,11 @@ int exec_move(position *p, move emove, i
   // update position characteristics
   p->wtm = p->wtm^1;
   p->material = -p->material;
-  or(p->hcode, btm); or(p->hcode, wtm);
+  hash_or(p->hcode, btm); hash_or(p->hcode, wtm);
 
   // undo hash code for en-passant and castling status
-  or(p->hcode, ep_code[p->ep]);
-  or(p->hcode, castle_code[p->castle]);
+  hash_or(p->hcode, ep_code[p->ep]);
+  hash_or(p->hcode, castle_code[p->castle]);
 
   // if move is a pawn push 2 spaces, set en passant flag
   if((emove.b.type&PAWN_PUSH2) && 
@@ -235,8 +235,8 @@ int exec_move(position *p, move emove, i
   p->last = emove;
 
   // update hash code for en-passant and castling status
-  or(p->hcode, ep_code[p->ep]);
-  or(p->hcode, castle_code[p->castle]);
+  hash_or(p->hcode, ep_code[p->ep]);
+  hash_or(p->hcode, castle_code[p->castle]);
 
   // check whether other side is placed in check
   int ptype = p->sq[emove.b.to].type;