// promotions by pieces with Lion power stepping in & out the zone in same turn\r
// promotion on capture\r
\r
-#define VERSION "0.20"\r
+#define VERSION "0.21"\r
\r
//define PATH level==0 || path[0] == 0x590cb && (level==1 || path[1] == 0x4c0c9 && (level == 2 || path[2] == 0x8598ca && (level == 3 /*|| path[3] == 0x3e865 && (level == 4 || path[4] == 0x4b865 && (level == 5))*/)))\r
#define PATH 0\r
void pmap(int *m, int col);\r
void pboard(int *b);\r
void pbytes(unsigned char *b);\r
+int myRandom();\r
\r
typedef struct {\r
int lock[5];\r
#define R 37 /* jump capture */\r
#define N -1 /* Knight */\r
#define J -2 /* jump */\r
-#define D -3 /* linear double move */\r
-#define T -4 /* linear triple move */\r
-#define L -5 /* true Lion move */\r
-#define F -6 /* Lion + 3-step */\r
-#define S -7 /* Lion + range */\r
+#define I -3 /* jump + step */\r
+#define D -4 /* linear double move */\r
+#define T -5 /* linear triple move */\r
+#define L -6 /* true Lion move */\r
+#define F -7 /* Lion + 3-step */\r
+#define S -8 /* Lion + range */\r
#define H -9 /* hook move */\r
#define C -10 /* capture only */\r
#define M -11 /* non-capture only */\r
{ NULL } // sentinel\r
};\r
\r
+PieceDesc waPieces[] = {\r
+ {"TE", "", 720, { X,X,1,X,X,X,1,X }, 4 }, // Tenacious Falcon\r
+ {"GS", "", 500, { X,0,X,0,X,0,X,0 }, 4 }, // Gliding Swallow (R)\r
+ {"DE", "", 430, { X,3,1,1,X,1,1,3 }, 3 }, // Cloud Eagle\r
+ {"K", "", 410, { 1,1,1,1,1,1,1,1 }, 2 }, // Crane King (K)\r
+ {"BT", "", 390, { I,I,0,I,I,I,0,I }, 4 }, // Treacherous Fox\r
+ {"FL", "TE", 380, { 1,X,0,X,0,X,0,X }, 4 }, // Flying Falcon\r
+ {"FS", "", 290, { X,1,1,0,X,0,1,1 }, 3 }, // Raiding Falcon\r
+ {"S", "GS", 260, { 1,0,X,0,1,0,X,0 }, 6 }, // Swallow's Wing (SM)\r
+ {"PO", "", 260, { 1,1,1,1,1,1,1,1 }, 2 }, // Plodding Ox (K)\r
+ {"R", "BT", 260, { X,1,0,1,1,1,0,1 }, 2 }, // Running Rabit\r
+ {"B", "", 240, { 1,1,1,1,0,1,1,1 }, 2 }, // Roaming Boar\r
+ {"HH", "", 220, { N,0,0,N,N,0,0,N }, 1 }, // Heavenly Horse\r
+ {"EW", "PO", 220, { 1,1,1,0,1,0,1,1 }, 2 }, // Violent Wolf (G)\r
+ {"VM", "B", 200, { 1,1,0,1,0,1,0,1 }, 2 }, // Violent Stag (S)\r
+ {"G", "S", 190, { 1,1,0,0,1,0,0,1 }, 2 }, // Flying Goose (C)\r
+ {"SM", "VM", 175, { 1,1,0,0,1,0,0,1 }, 2 }, // Climbing Monkey (C)\r
+ {"DH", "HH", 170, { X,0,0,0,2,0,0,0 }, 1 }, // Liberated Horse\r
+ {"DK", "EW", 150, { 0,1,1,0,1,0,1,1 }, 2 }, // Blind Dog\r
+ {"PH", "PO", 150, { X,0,0,0,0,0,0,0 }, 1 }, // Oxcart (L)\r
+ {"L", "FS", 130, { 0,1,1,0,0,0,1,1 }, 2 }, // Flying Cock\r
+ {"KN", "DE", 115, { 1,0,0,1,0,1,0,0 }, 2 }, // Swooping Owl\r
+ {"C", "FL", 105, { 1,0,0,1,0,1,0,0 }, 2 }, // Strutting Crow\r
+ {"P", "EW", 80, { 1,0,0,0,0,0,0,0 }, 2 }, // Sparrow Pawn (P)\r
+ { NULL } // sentinel\r
+};\r
+\r
PieceDesc ddPieces[] = {\r
{"LO", "", 10, { 1,H,1,H,1,H,1,H } }, // Long-Nosed Goblin\r
{"OK", "LO", 10, { 2,1,2,0,2,0,2,1 } }, // Old Kite\r
"....d......d..../pppppppppppppppp/:sm:vmr:hf:se:bg:rg:vg:gg:rg:bg:se:hfr:vm:sm/"\r
":ss:vsb:dh:dk:wb:fi:fe:lh:fi:wb:dk:dhb:vs:ss/:rv.:cs:cs.:bt:ph:fk:ln:kn:bt.:cs:cs.:rv/ln:flicsg:dekgsci:flnl";\r
char shoArray[] = "LNSGKGSNL/.B..:DE..R./PPPPPPPPP/........./........./........./ppppppppp/.r..:de..b./lnsgkgsnl";\r
+char waArray[] = ":PH:DKCG:EWK:VML:KN:SM:DH/.:FL...S...:DE./PPP:BTPPPRPPP/...P...P..."\r
+ "/.........../.........../..........."\r
+ "/...p...p.../ppprppp:btppp/.:de...s...:fl./:dh:sm:knl:vmk:ewgc:dk:ph";\r
char chessArray[] = "RNB:FKKBNR/PPPPPPPP/......../......../......../......../pppppppp/rnb:fkkbnr";\r
char lionArray[] = "R:LNB:FKKBNR/PPPPPPPP/......../......../......../......../pppppppp/r:lnb:fkkbnr";\r
char shatArray[]= "RNBK:FKBNR/PPPPPPPP/......../......../......../......../pppppppp/rnbk:fkbnr";\r
char *array; // initial position\r
} VariantDesc;\r
\r
-typedef enum { V_CHESS, V_SHO, V_CHU, V_DAI, V_DADA, V_MAKA, V_TAI, V_KYOKU, V_TENJIKU, V_SHATRANJ, V_MAKRUK, V_LION } Variant;\r
+typedef enum { V_CHESS, V_SHO, V_CHU, V_DAI, V_DADA, V_MAKA, V_TAI, V_KYOKU, V_TENJIKU, V_SHATRANJ, V_MAKRUK, V_LION, V_WA } Variant;\r
\r
#define SAME (-1)\r
\r
{ 16, 8, 8, 1, V_SHATRANJ,"shatranj",shatArray}, // Shatranj\r
{ 16, 8, 8, 3, V_MAKRUK, "makruk", thaiArray}, // Makruk\r
{ 16, 8, 8, 1, V_LION, "lion", lionArray}, // Mighty Lion\r
+ { 22, 11, 11, 3, V_WA, "washogi", waArray}, // Wa\r
\r
{ 0, 0, 0, 0, 0 }, // sentinel\r
{ 34, 17, 17, 0, V_DADA, "dada", chuArray }, // Dai Dai\r
int attackMaps[200*BSIZE], *attacks = attackMaps;\r
char distance[2*BSIZE]; // distance table\r
char promoBoard[BSIZE]; // flags to indicate promotion zones\r
-char rawFire[BSIZE+2*BWMAX]; // flags to indicate squares controlled by Fire Demons\r
+unsigned char rawFire[BSIZE+2*BWMAX]; // flags to indicate squares controlled by Fire Demons\r
signed char PST[7*BSIZE];\r
\r
#define board (rawBoard + 6*BHMAX + 3)\r
return ListLookUp(name, makrukPieces);\r
case V_LION: // Mighty Lion\r
return ListLookUp(name, lionPieces);\r
+ case V_WA: // Wa\r
+ return ListLookUp(name, waPieces);\r
}\r
return NULL;\r
}\r
int\r
EasyProm (signed char *r)\r
{\r
- int i;\r
if(r[0] == X) return 30 + PROMO*((unsigned int)(r[1] | r[2] | r[3] | r[5] | r[6] | r[7]) <= 1);\r
if(r[1] == X || r[7] == X) return 30 + PROMO/2;\r
return 0;\r
void\r
Compactify (int stm)\r
{ // remove pieces that are permanently gone (captured or promoted) from one side's piece list\r
- int i, j, k;\r
+ int i, k;\r
for(i=stm+2; i<=last[stm]; i+=2) { // first pass: unpromoted pieces\r
if((k = p[i].promo) >= 0 && p[i].pos == ABSENT) { // unpromoted piece no longer there\r
p[k].promo = -2; // orphan promoted version\r
}\r
if(royal[stm] >= i) royal[stm] += 2;\r
if(kylin[stm] >= i) kylin[stm] += 2;\r
- if(p[i].value == (currentVariant == V_SHO ? 410 : 280) ) royal[stm] = i, p[i].pst = 0;\r
+ if(p[i].value == (currentVariant == V_SHO || currentVariant == V_WA ? 410 : 280) ) royal[stm] = i, p[i].pst = 0;\r
p[i].qval = (currentVariant == V_TENJIKU ? list->ranking : 0); // jump-capture hierarchy\r
return i;\r
}\r
\r
void\r
-SetUp(char *array, int var)\r
+SetUp (char *array, int var)\r
{\r
- int i, j, n, m, nr, color;\r
- char c, *q, name[3], prince = 0;\r
+ int i, j, n, m, color;\r
+ char c, name[3], prince = 0;\r
PieceDesc *p1, *p2;\r
last[WHITE] = 1; last[BLACK] = 0;\r
royal[WHITE] = royal[BLACK] = 0;\r
char rowMask[] = { 0100, 0140, 0160, 070, 034, 016, 07, 03, 01 };\r
char rows[9];\r
\r
-int\r
+void\r
AreaStep (int from, int x, int flags, int n, int d)\r
{\r
int i;\r
}\r
}\r
\r
-int\r
+void\r
AreaMoves (int from, int piece, int range)\r
{\r
int i;\r
} else\r
if(r >= S) { // in any case, do a jump of 2\r
int occup = NewNonCapture(x, x + 2*v, pFlag);\r
- if(r < J) { // Lion power, also single step\r
+ if(r < I) { // Lion power, also single step\r
if(!NewNonCapture(x, x + v, pFlag)) nullMove = x; else occup = 1;\r
if(r <= L) { // true Lion, also Knight jump\r
if(!occup & r < L) for(y=x+2*v; !NewNonCapture(x, y+=v, pFlag) && r == S; ); // BS and FF moves\r
v = nStep[j];\r
NewNonCapture(x, x + v, pFlag);\r
}\r
- }\r
+ } else if(r == I) NewNonCapture(x, x + v, pFlag); // also do step\r
} else\r
if(r == M) { // FIDE Pawn; check double-move\r
if(!NewNonCapture(x, x+v, pFlag) && chessFlag && promoBoard[x-v] & LAST_RANK)\r
int\r
MapOneColor (int start, int last, int *map)\r
{\r
- int i, j, k, totMob = 0;\r
+ int i, j, totMob = 0;\r
for(i=start+2; i<=last; i+=2) {\r
int mob = 0;\r
if(p[i].pos == ABSENT) continue;\r
if(r < J) { // Lion power, also single step\r
if(board[x + v] != EMPTY && board[x + v] != EDGE)\r
map[2*(x + v) + start] += one[j];\r
+ if(r < I) {\r
if(r == T) { // Lion Dog, also jump of 3\r
if(board[x + 3*v] != EMPTY && board[x + 3*v] != EDGE)\r
map[2*(x + 3*v) + start] += one[j];\r
if(board[x + v] != EMPTY && board[x + v] != EDGE)\r
map[2*(x + v) + start] += one[8];\r
}\r
+ }\r
}\r
} else\r
if(r == C) { // FIDE Pawn diagonal\r
int i;\r
for(i=0; i<2*bsize; i++) map[i] = 0;\r
mobilityScore = MapOneColor(1, last[WHITE], map);\r
+\r
mobilityScore -= MapOneColor(0, last[BLACK], map);\r
}\r
\r
}\r
\r
void\r
-GenCapts(int sqr, int victimValue)\r
+GenCapts (int sqr, int victimValue)\r
{ // generate all moves that capture the piece on the given square\r
- int i, range, att = attacks[2*sqr + stm];\r
+ int i, att = attacks[2*sqr + stm];\r
//printf("GenCapts(%c%d,%d) %08x\n",sqr%BW+'a',sqr/BW,victimValue,att);\r
if(!att) return; // no attackers at all!\r
for(i=0; i<8; i++) { // try all rays\r
- int x, v, jumper, jcapt=0;\r
+ int x, v, jcapt=0;\r
if(att & attackMask[i]) { // attacked by move in this direction\r
v = -kStep[i]; x = sqr;\r
while( board[x+=v] == EMPTY ); // scan towards source until we encounter a 'stop'\r
break;\r
case J: // plain jump (as in KY, PH)\r
if(d != 2) break;\r
+ case I: // jump + step (as in Wa TF)\r
+ if(d > 2) break;\r
NewCapture(x, sqr + victimValue - SORTKEY(attacker), p[attacker].promoFlag);\r
att -= one[i];\r
break;\r
for(i=BH-1; i>=0; i--) {\r
for(j=0; j<BH; j++) printf("%3x", b[BW*i+j]);\r
printf("\n");\r
+\r
}\r
}\r
\r
sup2 = sup1; sup1 = sup0;\r
}\r
\r
-char fenNames[] = "RV....DKDEFL..DHGB......SMLNKN..FK....BT..VM..PH..LN"; // pairs of char\r
+char fenNames[] = "RV....DKDEFL..DHGB......SMLNKN..FK....BT..VMSWPH..LN"; // pairs of char\r
char fenPromo[] = "WLDHSMSECPB R HFDE....WHFB..LNG ..DKVMFS..FO..FK...."; // pairs of char\r
\r
char *\r
int\r
ReadSquare (char *p, int *sqr)\r
{\r
- int i=0, f, r;\r
+ int f, r;\r
f = p[0] - 'a';\r
r = atoi(p + 1) - ONE;\r
*sqr = r*BW + f;\r
int\r
SearchBestMove (MOVE *move, MOVE *ponderMove)\r
{\r
- int score, i;\r
+ int score;\r
printf("# SearchBestMove\n");\r
startTime = GetTickCount();\r
nodes = 0;\r
}\r
}\r
\r
+ int\r
main()\r
{\r
int engineSide=NONE; // side played by engine\r
}\r
if(currentVariant == V_SHO)\r
printf("setup (PNBRLSE..G.+++++++Kpnbrlse..g.+++++++k) 9x9+0_shogi lnsgkgsnl/1r2e2b1/ppppppppp/9/9/9/PPPPPPPPP/1B2E2R1/LNSGKGSNL w 0 1\n");\r
+ if(currentVariant == V_WA)\r
+ printf("setup (P.C.EVLO.WGHDF.TRSXOM.+.+..+++.+++++..+++++Kp.c.evlo.wghdf.trsxom.+.+..+++.+++++..+++++k) 11x11+0_chu "\r
+ "hmolvkwgcdx/1e3s3f1/ppprppptppp/3p3p3/11/11/11/3P3P3/PPPTPPPRPPP/1F3S3E1/XDCGWKVLOMH w 0 1\n");\r
repStack[199] = hashKeyH, checkStack[199] = 0;\r
continue;\r
}\r
if(!strcmp(command, "remove")) { stm = TakeBack(2); continue; }\r
printf("Error: unknown command\n");\r
}\r
+ return 0;\r
}\r
\r