[SCM] Packaging for fairymax branch, master, updated. debian/4.8m-1-6-g6549cc2

Vincent Legout vincent at legout.info
Sat Jan 23 05:22:52 UTC 2010


The following commit has been merged in the master branch:
commit ba47a865c521d7704f9de6cb2dfa6eee0d72257a
Author: Vincent Legout <vincent at legout.info>
Date:   Sat Jan 23 12:38:28 2010 +0800

    Imported Upstream version 4.8o

diff --git a/Makefile b/Makefile
index b389dc9..08d5a2c 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ CC=gcc
 CFLAGS += -O2
 
 
-ALL= fairymax shamax maxqi
+ALL= fairymax shamax maxqi fairymax.6.gz
 
 all: ${ALL}
 
@@ -18,25 +18,45 @@ maxqi: maxqi.c
 	$(CC) $(CFLAGS) -DINI_FILE=\"/usr/share/games/fairymax/qmax.ini\" maxqi.c -o maxqi
 
 install: ${ALL} ${srcdir}/data/*
-	cp -u ${srcdir}/fairymax /usr/games
-	cp -u ${srcdir}/shamax /usr/games
-	cp -u ${srcdir}/maxqi /usr/games
-	install -d -m0755 /usr/share/games/fairymax
-	cp -u ${srcdir}/data/* /usr/share/games/fairymax
-	install -d -m0755 /usr/share/man/man6
-	cp -u ${srcdir}/fairymax.6.gz /usr/share/man/man6
+	cp -u ${srcdir}/fairymax $(DESTDIR)/usr/games
+	cp -u ${srcdir}/shamax $(DESTDIR)/usr/games
+	cp -u ${srcdir}/maxqi $(DESTDIR)/usr/games
+	install -d -m0755 $(DESTDIR)/usr/share/games/fairymax
+	cp -u ${srcdir}/data/* $(DESTDIR)/usr/share/games/fairymax
+	install -d -m0755 $(DESTDIR)/usr/share/man/man6
+	cp -u ${srcdir}/fairymax.6.gz $(DESTDIR)/usr/share/man/man6
+
+fairymax.6.gz: fairymax.pod
+	pod2man -s 6 fairymax.pod > fmax.man
+	cp fmax.man fairymax.6
+	rm -f fairymax.6.gz
+	gzip fairymax.6
 
 clean:
 	rm -f ${ALL}
 
 dist-clean:
-	rm -f ${ALL} *~ data/*~
+	rm -f ${ALL} *~ data/*~ *.man md5sums
+
+dist:
+	install -d -m0755 Fairy-Max
+	install -d -m0755 Fairy-Max/data
+	rm -f fairymax.tar fairymax.tar.gz
+	cp fairymax.c maxqi.c fairymax.pod Makefile README changelog copyright md5sums Fairy-Max
+	cp data/* Fairy-Max/data
+	md5 Fairy-Max/* Fairy-Max/data/* > Fairy-Max/md5sums
+	tar -cvvf fairymax.tar Fairy-Max
+	gzip fairymax.tar
+	rm Fairy-Max/data/*
+	rmdir Fairy-Max/data
+	rm Fairy-Max/*
+	rmdir Fairy-Max
 
 uninstall:
-	rm -f /usr/share/games/fairymax/*
-	rmdir /usr/share/games/fairymax
-	rm -f /usr/share/man/man6/fairymax.6.gz
-	rm -f /usr/games/fairymax
-	rm -f /usr/games/shamax
-	rm -f /usr/games/maxqi
+	rm -f $(DESTDIR)/usr/share/games/fairymax/*
+	rmdir $(DESTDIR)/usr/share/games/fairymax
+	rm -f $(DESTDIR)/usr/share/man/man6/fairymax.6.gz
+	rm -f $(DESTDIR)/usr/games/fairymax
+	rm -f $(DESTDIR)/usr/games/shamax
+	rm -f $(DESTDIR)/usr/games/maxqi
 
diff --git a/README b/README
index db5e7c9..6dadac8 100644
--- a/README
+++ b/README
@@ -1,5 +1,5 @@
 This package contains the sources of the XBoard-compatible Chess and
-Chess-variant engine Fairy-Max, and its dedicaed derivatives ShaMax 
+Chess-variant engine Fairy-Max, and its dedicated derivatives ShaMax 
 (for Shatranj) and MaxQi (for XiangQi = Chinese Chess). A Makefile
 is provided to compile and install them. Normally this would require only
 the command (given from the main directory of the package):
diff --git a/changelog b/changelog
new file mode 100644
index 0000000..e4e6f6a
--- /dev/null
+++ b/changelog
@@ -0,0 +1,79 @@
+/***************************************************************************/
+/* micro-Max version 4.8 (~1950 characters) features:                      */
+/* - recursive negamax search                                              */
+/* - all-capture quiescence search with MVV/LVA priority                   */
+/* - (internal) iterative deepening                                        */
+/* - best-move-first 'sorting'                                             */
+/* - a hash table storing score and best move                              */
+/* - futility pruning                                                      */
+/* - king safety through magnetic frozen king                              */
+/* - null-move pruning                                                     */
+/* - Late-move reductions                                                  */
+/* - full FIDE rules (expt minor promotion) and move-legality checking     */
+/* - keep hash + rep-draw detect                                           */
+/* - end-game Pawn-push bonus, new piece values, gradual promotion         */
+/***************************************************************************/
+/* The Fairy-Max version reads the piece description from a file fmax.ini  */
+/* The format supports many fairy pieces, including hoppers.               */
+/* f) now supports 15 piece types, by requisitioning WHITE bit             */
+/* g) supports larger board width.                                         */
+/* h) castling bug ('in-check by non-captures') corrected                  */
+/* i) rep-draw bug ('side-to-move') corrected                              */
+/* k) allow user underpromotions, recognize & ignore 'variant' command     */
+/* l) edit bug corrected (i & j file clear)                                */
+/* m) piece values no longer quantized, game-stage counting bug corrected  */
+/* n) edit-menu K-side castling bug corrected.                             */
+/* o) retrieve the requested variant from the .ini file                    */
+/* p) clear hash table on variant switch                                   */
+/* q) reduced piece-material count for better Pawn push                    */
+/* r) hash-table bug corrected (X still ORed with flags)                   */
+/* s) Bug that prevented initialization center points corrected            */
+/* t) castling bug after edit fixed                                        */
+/* u) converted to protocol 2; ping implemented                            */
+/* v) white e.p. rights hash bug fixed;                                    */
+/* w) piece indicators programable, multi-path support                     */
+/* x) e.p. changed to support Berolina Pawns                               */
+/* y) capture value of 6-7th-rank Pawn reduced in Shatranj                 */
+/* z) bug in promotion input corrected                                     */
+/* A) stalemate-detection bug in printResult fixed                         */
+/* B) Invalidate hash on game-level promotion (might be under-promotion!)  */
+/* C) King move evaluation based on negative piece value in stead of nr    */
+/* D) WB memory command added, undo fixed                                  */
+/* E) 15th piece read in                                                   */
+/* F) accepts ini fileargument                                             */
+/* G) bug in calculation ASCII promotion character fixed                   */
+/* H) unified normal and shatranj source                                   */
+/* J) rewrite under-promotion code, fixes persistent bug there             */
+/* K) o[] and oo[] made int to make fairymax work on big-endian machines   */
+/* L) added Resign option feature (using new WB protocol)                  */
+/* M) char -> signed char for better portability                           */
+/* N) add PV printing and multi-PV support                                 */
+/* O) non-Rook castling, 6th-rank promotion, independent B/W piece naming  */
+/***************************************************************************/
+
+4/6/2009 Unified source of ShaMax and Fairy-Max into single fmax.c file, and
+         created this ChangeLog from the until then self-documenting source.
+
+6/2/2009 Promotion code rewitten to not refer to default piece characters.
+
+9/3/2009 Fixed big-endian bug in reading inifile (char with int format),
+         and added some option features to make Fairy-Max useful as test
+         engine for GUIs that want to implement the WB protocol extensions.
+
+9/16/2009 Made signedness of char in AI explicit
+
+27/12/2009 Added PV updating through the triangular-array method. Also added
+           a multi-PV option to print lines within a certain sccore margin.
+
+15/1/2010 Improved Makefile, updated docs
+          Implement independent naming of white and black pieces. (So mirror-
+          image pieces can use same letter.) 
+          Change castling code to allow castling with any corner piece type.
+          Implement 6th-rank promotion based on 'Queen' value.
+          Makruk added as new variant to the fmax.ini file.
+
+16/1/2010 Fixed bug in Shatranj result claims.
+          Flip eval sign when side-to-move changes through WB color command.
+          
+17/1/2010 Removed Shatranj stalemate claim again, as it was never triggered.
+
diff --git a/changelog.gz b/changelog.gz
deleted file mode 100644
index b5f4fb3..0000000
Binary files a/changelog.gz and /dev/null differ
diff --git a/data/fmax.ini b/data/fmax.ini
index 64bd2ac..d6f70e1 100644
--- a/data/fmax.ini
+++ b/data/fmax.ini
@@ -133,11 +133,24 @@ After that follow upto 18 lines with the description.
 Line 1:     Board size (files x ranks). Ranks must currently still be 8.
 Line 2:     initial setup of white pieces on back rank
 Line 3:     initial setup of black pieces on back rank
-Line 4-10:  Description of pieces present in the opening position
-Line 11-18: Description 8 additional piece types
+Line 4-18:  Description of piece types that can occur in the variant
 
-The rest of the lines is ignored, but some pre-cooked descriptions are
-provided for easy copying into the first positions.
+There can be upto 15 piece types per variant, numbered 1 to 15.
+Numbers 1 and 2 are considered Pawns for white and black, respectively,
+and the 2nd and 7th rank of the opening setup will be filled with them.
+These pieces will automatically promote to piece number 7 when they 
+reach last rank. So in normal Chess, piece 7 should be programmed as Queen.
+
+Castling can be done only with the original corner piece as specified
+by line 2 and 3. Any royal piece can in principle castle. (Subject to 
+the normal restrictions on castling, i.e. not passing through check etc.)
+If you don't want that, remove the castling moves from the King description. 
+If the castling initiator does not start in a central file, the results are 
+currently undefined.
+
+Most variant definitions can be seen at the end of this file.
+Other lines in this file (i.e. those not recognized as belonging to a
+variant description) are ignored. They can be used for comments.
 
 
 
@@ -153,6 +166,17 @@ The piece-description lines have the following syntax:
    c) the move-mode descriptor, most easily given in hexadecimal, as the
       individual bits specify the various options
 
+The piece indicator character is used to set up positions, and for the
+promotion choice as 5th character of an input move. (Fairy-Max itself
+always promotes to "Queen", i.e. the 7th piece of the list.)
+If more pieces use the same letter, the first one is used for white,
+and the last one for black. If more than two have the same name, the 
+others cannot be indicated at all, but they could still occur in the
+initial setup (where you specify them by number, not letter).
+
+NOTE: piece value 181 for piece 7 is reserved for Makruk, and enables
+promotion on the 6th rank. Do not use it in other variants.
+
 The individual bits in the move-mode descriptor have the following meaning:
 In the last hexadecimal digit:
     1 capture allowed (of enemy piece; own pieces always block a move)
@@ -208,10 +232,6 @@ black Pawn, respectively, or promotions will have undefined effects. Also
 note that uMax does do primitive evaluation of Pawn structure, which might
 become counter-productive if the Pawn move is changed.
 
-Castling is done with the Rook replacement (the piece that starts in the
-corner, whatever its type). If you don't want that, remove the castling
-moves from the King desription. If the castling initiator does not start
-in a central file, the results are currently undefined.
 
 
 For the truly lazy, a few complete game descriptions can be found below:
@@ -245,6 +265,24 @@ q:180 15,7 17,7 -15,7 -17,7
 e:110 30,7 34,7 -30,7 -34,7
 f:180 15,7 17,7 -15,7 -17,7
 
+// Thai Chess. Note: value m = 181 controls promotion at 6th!
+Game: makruk
+8x8
+6 4 5 7 3 5 4 6
+6 4 8 3 7 8 4 6
+p:100 -16,6 -15,5 -17,5 
+p:100 16,6 15,5 17,5
+k:-1  1,7 16,7 15,7 17,7 -1,7 -16,7 -15,7 -17,7
+n:450 14,7 31,7 33,7 18,7 -14,7 -31,7 -33,7 -18,7
+s:300 15,7 17,7 -15,7 -17,7 -16,7
+R:630 1,3 16,3 -1,3 -16,3
+m:181 15,7 17,7 -15,7 -17,7
+s:300 15,7 17,7 -15,7 -17,7 16,7
+f:181 15,7 17,7 -15,7 -17,7
+q:181 15,7 17,7 -15,7 -17,7
+b:300 15,7 17,7 -15,7 -17,7 -16,7
+b:300 15,7 17,7 -15,7 -17,7 16,7
+
 // Medieval intermediate between Shatranj and FIDE Chess
 Game: courier
 12x8
@@ -268,7 +306,7 @@ Game: knightmate
 6 4 5 7 3 5 4 6
 p:74 -16,24 -16,6 -15,5 -17,5 
 p:74  16,24 16,6 15,5 17,5
-u:-1  1,34 -1,34 14,7 31,7 33,7 18,7 -14,7 -31,7 -33,7 -18,7
+k:-1  1,34 -1,34 14,7 31,7 33,7 18,7 -14,7 -31,7 -33,7 -18,7
 m:222 1,7 16,7 15,7 17,7 -1,7 -16,7 -15,7 -17,7
 b:296 15,3 17,3 -15,3 -17,3
 R:444 1,3 16,3 -1,3 -16,3
@@ -319,7 +357,7 @@ b:450 15,103 17,103 -15,103 -17,103
 R:525 1,103 16,3 -1,103 -16,3
 Q:1150 1,103 16,3 15,103 17,103 -1,103 -16,3 -15,103 -17,103
 
-// Berolina Chess. In WinBoard 4.3.15 you can play this with legality testing switched off
+// Berolina Chess. In WinBoard 4.3.15 you can play this with legality testing switched off
 Game: berolina
 8x8
 6 4 5 7 3 5 4 6
@@ -353,27 +391,27 @@ g:640 1,7 16,7 15,7 17,7 -1,7 -16,7 -15,7 -17,7 2,7 30,7 32,7 34,7 -2,7 -30,7 -3
 m:-1  1,34 -1,34 1,7 16,7 15,7 17,7 -1,7 -16,7 -15,7 -17,7 16,70 -16,70
 d:625 1,7 16,7 -1,7 -16,7 15,3 17,3 -15,3 -17,3
 
+// Set for Chess with Different Armies, FIDE vs Color-bound Cloberers (legality-testing off!)
 Game: fairy
 8x8
-10 9 8 7 3 5 4 6
-10 9 8 7 3 5 4 6
+6 4 5 7 3 5 4 6
+11 9 10 12 8 10 9 11
 p:100 -16,24 -16,6 -15,5 -17,5 
 p:100 16,24 16,6 15,5 17,5
-k:-1  1,34 -1,34 1,7 16,7 15,7 17,7 -1,7 -16,7 -15,7 -17,7
+k:-1  1,34 -1,34 1,7 -1,7 16,7 15,7 17,7 -16,7 -15,7 -17,7
 n:325 14,7 31,7 33,7 18,7 -14,7 -31,7 -33,7 -18,7
 b:350 15,3 17,3 -15,3 -17,3
-R:500 1,3 16,3 -1,3 -16,3
+R:500 16,3 -16,3 -1,3 1,3
 Q:950 1,3 16,3 15,3 17,3 -1,3 -16,3 -15,3 -17,3
-e:60 30,7 34,7 -30,7 -34,7
-H:560 14,3 31,3 33,3 18,3 -14,3 -31,3 -33,3 -18,3
-O:320 1,BA 16,BA -1,BA -16,BA
+k:-1  1,34 -1,1034 1,7 -1,7 16,7 15,7 17,7 -16,7 -15,7 -17,7
+e:320 30,7 34,7 -30,7 -34,7 16,7 -16,7 1,7 -1,7
+c:480 15,7 17,7 -15,7 -17,7 32,7 -32,7 2,7 -2,7 30,7 34,7 -30,7 -34,7
+l:530 15,3 17,3 -15,3 -17,3 32,7 -32,7 2,7 -2,7
 A:875 15,3 17,3 -15,3 -17,3 14,7 31,7 33,7 18,7 -14,7 -31,7 -33,7 -18,7
-C:900 1,3 16,3 -1,3 -16,3 14,7 31,7 33,7 18,7 -14,7 -31,7 -33,7 -18,7
-v:850 1,7 16,7 15,7 17,7 -1,7 -16,7 -15,7 -17,7 14,7 31,7 33,7 18,7 -14,7 -31,7 -33,7 -18,7
-Z:1260 1,3 16,3 -1,3 -16,3 15,3 17,3 -15,3 -17,3 14,7 31,7 33,7 18,7 -14,7 -31,7 -33,7 -18,7
 m:275 1,7 16,7 15,7 17,7 -1,7 -16,7 -15,7 -17,7
+H:560 14,3 31,3 33,3 18,3 -14,3 -31,3 -33,3 -18,3
 
-// Great Shatranj: modern variant with range-two leapers replacing sliders, on 10x8 board
+// Great Shatranj: modern variant with range-two leapers replacing sliders, on 10x8 board.
 // Must be played with legality testing off in XBoard 4.4.0.
 Game: great
 10x8
diff --git a/fairymax.6.gz b/fairymax.6.gz
deleted file mode 100644
index 5ce4c9c..0000000
Binary files a/fairymax.6.gz and /dev/null differ
diff --git a/fairymax.c b/fairymax.c
old mode 100755
new mode 100644
index 8b7b45a..b939cfc
--- a/fairymax.c
+++ b/fairymax.c
@@ -18,7 +18,7 @@
      /*****************************************************************/
 
 #define MULTIPATH
-#define VERSION "4.8M"
+#define VERSION "4.8O"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -92,7 +92,8 @@ int GameNr;
 int Resign;
 int Threshold = 800;
 int Score;
-char piecename[32], piecetype[32];
+int makruk;
+char piecename[32], piecetype[32], blacktype[32];
 char *inifile = INI_FILE;
 
 int Ticks, tlim, Setup, SetupQ;
@@ -122,6 +123,9 @@ T[4104],                                       /* hash translation table   */
 centr[32],
 n[]=".*XKNBRQEWFMACHG?x+knbrqewfmachg";        /* piece symbols on printout*/
 
+int pv[10000],*sp=pv; // triangular array
+int margin;
+
 pboard()
 {int i;
  i=-1;W(++i<128)printf(" %c",(i&15)==BW&&(i+=15-BW)?10:n[b[i]&31]);
@@ -131,9 +135,10 @@ pboard()
 D(k,q,l,e,E,z,n)        /* recursive minimax search, k=moving side, n=depth*/
 int k,q,l,e,E,z,n;      /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/
 {                       /* e=score, z=prev.dest; J,Z=hashkeys; return score*/
- int j,r,m,v,d,h,i,F,G,P,V,f=J,g=Z,C,s,flag,FF;
+ int j,r,m,v,d,h,i,F,G,P,V,f=J,g=Z,C,s,flag,FF,*ps=sp;
  signed char t,p,u,x,y,X,Y,H,B;
  struct _*a=A+(J+(k+S)*E&U-1);                 /* lookup pos. in hash table*/
+ *sp++=0;
  q-=q<e;l-=l<=e;                               /* adj. window: delay bonus */
  d=a->D;m=a->V;X=a->F;Y=a->Y;                  /* resume at stored depth   */
  if(a->K-Z|z&S  |                              /* miss: other pos. or empty*/
@@ -179,8 +184,8 @@ int k,q,l,e,E,z,n;      /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/
        v=d-1?e:i-p;                            /*** MVV/LVA scoring if d=1**/
        if(d-!t>1)                              /*** all captures if d=2  ***/
        {v=centr[p]?b[x+257]-b[y+257]:0;        /* center positional pts.   */
+        if(!(G&S))b[FF]=b[G],v+=50;            /* castling: put R & score  */
         b[G]=b[H]=b[x]=0;b[y]=u|32;            /* do move, set non-virgin  */
-        if(!(G&S))b[FF]=k+6,v+=50;             /* castling: put R & score  */
         v-=w[p]>0|R<EG?0:20;                   /*** freeze K in mid-game ***/
         if(p<3)                                /* pawns:                   */
         {v-=9*((x-2&M||b[x-2]-u)+              /* structure, undefended    */
@@ -188,18 +193,25 @@ int k,q,l,e,E,z,n;      /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/
               +(w[b[x^16]&15]<0))              /*** cling to magnetic K ***/
               +(R-76>>2);                      /* end-game Pawn-push bonus */
          b[y]+=V=y+r+1&S?647-p:2*(u&y+16&32);  /* upgrade P or convert to Q*/
+         if(V&makruk)b[y]=u|7,V=480;           /* Makruk promotion on 6th  */
          V>>=sh;                               /* for Shatranj promo to F  */
          i+=V;                                 /* promotion / passer bonus */
         } if(z&S && GamePtr<6) v+=(rand()>>10&31)-16;
         J+=J(0);Z+=J(4)+G-S;
         SHAMAX( pl[k]-=!!t; )                  /* count pieces per side    */
         v+=e+i;V=m>q?m:q;                      /*** new eval & alpha    ****/
+        if(z&S)V=m-margin>q?m-margin:q;        /* multiPV                  */
         C=d-1-(d>5&p>2&!t&!h);                 /* nw depth, reduce non-cpt.*/
         C=R<EG|P-I|d<3||t&&p-3?C:d;            /* extend 1 ply if in-check */
         do
          s=C>2|v>V?-D(16-k,-l,-V,-v,/*** futility, recursive eval. of reply */
                                      F,y&255,C):v;
         W(s>q&++C<d); v=s;                     /* no fail:re-srch unreduced*/
+        if(v>V&v<l){int *p=sp;
+         sp=ps+1;
+         W(*sp++=*p++);
+         *ps=256*x+y;
+        }
         if(z&S&&K-I)                           /* move pending: check legal*/
         {if(v+I&&x==K&y==L)                    /*   if move found          */
          {Q=-e-i;O=F;LL=L;
@@ -208,27 +220,36 @@ int k,q,l,e,E,z,n;      /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/
           a->D=99;a->V=0;                      /* lock game in hash as draw*/
           R-=i/FAC;                            /*** total captd material ***/
           Fifty = t|p<3?0:Fifty+1;
+          sp=ps;
                      return l;}                /*   & not in check, signal */
          v=m;                                  /* (prevent fail-lows on    */
         }                                      /*   K-capt. replies)       */
         J=f;Z=g;
         SHAMAX( pl[k]+=!!t; )
-        b[G]=k+6;b[FF]=b[y]=0;b[x]=u;b[H]=t;   /* undo move,G can be dummy */
+        b[G]=b[FF];b[FF]=b[y]=0;b[x]=u;b[H]=t; /* undo move,G can be dummy */
        }                                       /*          if non-castling */
+       if(z&S&&Post&K==I&d>2&v>V&v<l){int *p=ps;char X,Y;
+        printf("%2d ",d-2);
+        printf("%6d ",v);
+        printf("%8d %10d",(GetTickCount()-Ticks)/10,N);
+        while(*p){X=*p>>8;Y=*p++;
+        printf(" %c%c%c%c",'a'+(X&15),'8'-(X>>4),'a'+(Y&15),'8'-(Y>>4&7));}
+        printf("\n");fflush(stdout);
+       }
        if(v>m)                                 /* new best, update max,best*/
         m=v,X=x,Y=y|S&F;                       /* mark non-double with S   */
        if(h){h=0;goto A;}                      /* redo after doing old best*/
       }
-      s=t;
+      s=t;v=r^flag>>12;                        /* calc. alternated vector  */
       if(flag&15^4|u&32||                      /* no double or moved before*/
          p>2&&                                 /* no P & no lateral K move,*/
-         (b[G=r<0?x&~15:BW-1|x&112]-k-6        /* no virgin R in corner G, */
-         ||b[G^1]|b[G^2]|b[FF=r<0?G+3:G-2])    /* no 2 empty sq. next to R */
+         ((b[G=r<0?x&~15:BW-1|x&112]^32)<33    /* no virgin R in corner G, */
+         ||b[G^1]|b[G^2]|b[FF=y+v-r])          /* no 2 empty sq. next to R */
         )t+=flag&4;                            /* fake capt. for nonsliding*/
       else F=y;                                /* enable e.p.              */
       if(s&&flag&8)t=0,flag^=flag>>4&15;       /* hoppers go to next phase */
       if(!(flag&S))                            /* zig-zag piece?           */
-       r^=flag>>12,flag^=flag>>4&15;           /* alternate vector & mode  */
+       r=v,flag^=flag>>4&15;                   /* alternate vector & mode  */
      }W(!t);                                   /* if not capt. continue ray*/
    }}
    if((++x&15)>=BW)x=x+16&112;                 /* next sqr. of board, wrap */
@@ -237,13 +258,9 @@ C:FMAX( m=m+I|P==I?m:(X=Y=0); )                /* if stalemate, draw-score */
   if(a->D<99)                                  /* protect game history     */
    a->K=Z,a->V=m,a->D=d,a->X=X,                /* always store in hash tab */
    a->F=8*(m>q)|S*(m<l),a->Y=Y;                /* move, type (bound/exact),*/
-  if(z&S&&Post){
-    printf("%2d ",d-2);
-    printf("%6d ",m);
-    printf("%8d %10d %c%c%c%c\n",(GetTickCount()-Ticks)/10,N,
-       'a'+(X&15),'8'-(X>>4),'a'+(Y&15),'8'-(Y>>4&7)),fflush(stdout);
- }}                                            /*    encoded in X S,8 bits */
+  }                                            /*    encoded in X S,8 bits */
 if(z&4*S)K=X,L=Y&~S;
+ sp=ps;
  return m+=m<e;                                /* delayed-loss bonus       */
 }
 
@@ -302,10 +319,24 @@ int PrintResult(int s)
         }
         K=I;
         cnt = D(s,-I,I,Q,O,LL|4*S,3);
+#ifdef SHATRANJ
+        if(pl[s]==1 && pl[16-s]==1) {
+                printf("1/2-1/2 {Insufficient mating material}\n");
+                return 4;
+        }
+        if(pl[s]<=1 && pl[16-s]>1) {
+                if (s == BLACK)
+                        printf("0-1 {Bare King}\n");
+                else
+                        printf("1-0 {Bare King}\n");
+                return 5;
+        }
+#else
         if(cnt>-I+1 && K==0 && L==0) {
                 printf("1/2-1/2 {Stalemate}\n");
                 return 2;
         }
+#endif
         if(cnt==-I+1) {
                 if (s == WHITE)
                         printf("0-1 {Black mates}\n");
@@ -317,19 +348,6 @@ int PrintResult(int s)
                 printf("1/2-1/2 {Draw by fifty move rule}\n");
                 return 4;
         }
-#ifdef SHATRANJ
-        if(pl[s]==1 && pl[16-s]==1) {
-                printf("1/2-1/2 {Insufficient mating material}\n");
-                return 4;
-        }
-        if(pl[s]<=1 && pl[16-s]>1) {
-                if (s == BLACK)
-                        printf("0-1 {Bare King}\n");
-                else
-                        printf("1-0 {Bare King}\n");
-                return 5;
-        }
-#endif
         return 0;
 }
 
@@ -393,6 +411,7 @@ void PrintOptions()
 	printf("feature option=\"Resign -check %d\"\n", Resign);
 	printf("feature option=\"Resign Threshold -spin %d 200 1200\"\n", Threshold);
 	printf("feature option=\"Ini File -file %s\"\n", inifile);
+	printf("feature option=\"Multi-PV Margin -spin %d 0 1000\"\n", margin);
 	printf("feature option=\"Playing Style ;-) -combo Brilliant /// *Brave /// Beautiful\"\n");
 	printf("feature option=\"Dummy Slider Example -slider 20 0 100\"\n");
 	printf("feature option=\"Dummy String Example -file happy birthday!\"\n");
@@ -437,14 +456,15 @@ int LoadGame(char *name)
         for(i=0; i<BW; i++) fscanf(f, "%d", oo+i+16);
         for(i= 0; i<=U; i++)
             A[i].K = A[i].D = A[i].X = A[i].Y = A[i].F = 0; /* clear hash */
-        for(i=0; i<32; i++) piecetype[i] = 0;
+        for(i=0; i<32; i++) piecetype[i] = blacktype[i] = 0;
 
         i=0; j=-1; c=0;
         while(fscanf(f, "%d,%x", o+j, of+j)==2 ||
                                       fscanf(f,"%c:%d",&c, w+i+1)==2)
         {   if(c)
             { od[++i]=j; centr[i] = c>='a';
-              piecetype[c&31]=i; piecename[i]=c&31;
+              blacktype[c&31]=i; piecename[i]=c&31;
+              if(piecetype[c&31]==0) piecetype[c&31]=i; // only first
             }
             j++; o[j]=0;
             /* printf("# c='%c' i=%d od[i]=%d j=%d (%3d,%8x)\n",c?c:' ',i,od[i],j,o[j-1],of[j-1]); /**/
@@ -453,6 +473,7 @@ int LoadGame(char *name)
 
         fclose(f);
 	sh = w[7] < 250 ? 3 : 0;
+	makruk = w[7]==181 ? 64 : 0; // w[7] is used as kludge to enable makruk promotions
 }
 
 int main(int argc, char **argv)
@@ -595,12 +616,14 @@ int main(int argc, char **argv)
 		}
 		if (!strcmp(command, "white")) {
                         /* set white to move in current position */
+                        if(Side == BLACK) Q = -Q;
                         Side     = WHITE;
                         Computer = BLACK;
 			continue;
 		}
 		if (!strcmp(command, "black")) {
                         /* set blck to move in current position */
+                        if(Side == WHITE) Q = -Q;
                         Side     = BLACK;
                         Computer = WHITE;
 			continue;
@@ -667,6 +690,7 @@ int main(int argc, char **argv)
 				inifile = filename; continue;
 			}
 			if(sscanf(line+7, "Clear Hash") == 1) for(i=0; i<U; i++) A->K = 0;
+			if(sscanf(line+7, "MultiVariation Margin=%d", &margin) == 1) continue;
 			continue;
 		}
 		if (!strcmp(command, "go")) {
@@ -749,7 +773,7 @@ int main(int argc, char **argv)
                                     && line[1] >= 'a' && line[1] <= 'a'+BW-1
                                     && line[2] >= '1' && line[2] <= '0'+BH) {
                                         m = line[1]-16*line[2]+799;
-                                        switch(p = piecetype[line[0]&31])
+                                        switch(p = (color == WHITE ? piecetype : blacktype)[line[0]&31])
                                         {
                                         case 1:
                                         case 2:
@@ -759,23 +783,16 @@ int main(int argc, char **argv)
                                             else b[m]=(m&0x70)==0x10?18:50,
                                                  Q+=w[2];
                                             break;
-                                        case 3: // can castle, normally King
-                                            b[m]=3+color+32;
-                                            if(m==BW>>1        && color==BLACK ||
-                                               m==0x70+(BW>>1) && color==WHITE)
-                                                b[m] -= 32;
-                                            break;
-                                        case 6: // can castle, normally Rook
-                                            b[m]=6+color+32;
-                                            if((m==0x00 || m==BW-1   ) && color==BLACK ||
-                                               (m==0x70 || m==0x6F+BW) && color==WHITE)
-                                                b[m] -= 32;
-                                            Q+=w[6]; R+=w[6]/FAC;
-                                            break;
                                         default:
-                                            b[m]=p+color;
-                                            Q+=w[p]; R+=w[p]/FAC;
-						    case 0: // undefined piece, ignore
+                                            b[m]=p+color+32; // assume non-virgin
+                                            if(w[p]<0) { // Royal piece on original square: virgin
+					        if(color==BLACK && m<0x10 && p==oo[m+16] ||
+                                                   color==WHITE && m>0x6F && p==oo[m-0x70]) b[m] -= 32;
+					    } else { Q+=w[p]; R+=w[p]/FAC; }
+                                            if((m==0x00 || m==BW-1   ) && color==BLACK && p==oo[m+16] ||
+                                               (m==0x70 || m==0x6F+BW) && color==WHITE && p==oo[m-0x70])
+                                                b[m] &= ~32; // corner piece as in original setup: virgin
+					case 0: // undefined piece, ignore
                                             break;
                                         }
                                         pl[BLACK+WHITE-color]++;
@@ -794,7 +811,7 @@ int main(int argc, char **argv)
                 m = line[0]<'a' | line[0]>='a'+BW | line[1]<'1' | line[1]>='1'+BH |
                     line[2]<'a' | line[2]>='a'+BW | line[3]<'1' | line[3]>='1'+BH;
                 if(line[4] == '\n') line[4] = piecename[7];
-                PromPiece = 7 - piecetype[line[4]&31];
+                PromPiece = 7 - (Side == WHITE ? piecetype : blacktype)[line[4]&31];
 		    if(PromPiece == 7) PromPiece = 0;
                 {char *c=line; K=c[0]-16*c[1]+799;L=c[2]-16*c[3]+799; }
                 if (m)
diff --git a/fairymax.pod b/fairymax.pod
new file mode 100644
index 0000000..e495219
--- /dev/null
+++ b/fairymax.pod
@@ -0,0 +1,126 @@
+=head1 NAME
+
+fairymax - xboard-compatible chess and chess-variant engine 'Fairy-Max'
+
+
+=head1 SYNOPSIS
+
+B<fairymax> [hashSize] [iniFile]
+
+B<shamax> [hashSize] [iniFile]
+
+B<maxqi> [hashSize] [iniFile]
+
+
+=head1 DESCRIPTION
+
+B<fairymax> is a program that plays chess and chess variants. 
+It uses the xboard/winboard chess-engine protocol to communicate.
+Apart from 'regular' chess (also known as the Mad-Queen variant),
+it can play Capablanca chess, gothic chess, knightmate, cylinder chess, 
+berolina chess, superchess, makruk (Thai chess) and courier chess.
+Fairy-Max can be easily configured by the user to play other variants as well,
+by modifying the ini file.
+This ini file describes the rules of movement
+of the participating pieces and the initial board setup.
+
+Fairy-Max can also play shatranj, 
+but in this case is not aware of the shatranj rule that a bare king loses.
+So it might play sub-optimally in the late end-game.
+A version of Fairy-Max adapted to implement the baring rule is
+available under the name B<shamax>.
+
+Similarly, a version of Fairy-Max adapted to play Xiang Qi (Chinese Chess)
+is included in the fmax package as well.
+
+B<fairymax> is a derivative of the world's (once) smallest chess program 
+(source-code wise), micro-Max.
+The latter measures less that 2000 characters, (about 100 code lines),
+and has a computer rating of around 2050 on the CCRL rating list.
+Although this is about 1000 rating points behind the world champion,
+micro-Max still makes a quite tough opponent even for club players,
+although it is not unbeatable.
+
+The main difference between micro-Max and Fairy-Max is that the latter loads
+its move-generator tables, which specify how the various pieces move,
+from an external file, so it can be easily adapted to incorporate un-orthodox pieces.
+For ease of use of the artificial-intelligence, Fairy-Max is equipped with
+I/O routines that allow it to run with the xboard graphical user interface.
+
+See xboard(6) for instructions about how to use B<fairymax> through xboard. To
+start up quickly, you just need the command: B<xboard -fcp fairymax>.
+However, XBoard might not support symbols for every unorthodox piece in board sizes
+different from B<bulky>, B<middling> and B<petite>.
+It might thius be adviasable to specify a board size as well, e.g.
+B<xboard -fcp shamax -boardSize middling -variant shatranj> 
+to get correct display of the elephant and general pieces in shatranj.
+Note that to be able to play the chess variants,
+you will need xboard 4.3.14 or later.
+
+Fairymax supports multi-PV mode: by specifying a non-zero multi-PV margin in the
+Options -> Engine-Settings dialog of XBoard, Fairy-Max will not only print the
+principal variation for the best move, but also for every move that approaches
+the score of this best move to within the set margin.
+(If it does not find the best move on the first try, this might lead to printing
+of a few extra lines below the threshold.)
+
+The fmax.ini file from which Fairy-Max by default takes the piece and game definitions
+is a self-documenting text file,
+which contains instructions for how to define new pieces and chess variants.
+In addition it contains an extensive list of pre-defined pieces,
+incuding many not occurring in any of the pre-defined variants,
+which the user can draw on to define his own variants.
+
+Amongst the move types supported by Fairy-Max are normal leaper and slider moves,
+(e.g. knight and rook),
+divergent moves (i.e. capture and non-capture moves can be different)
+hoppers (which jump over other pieces, such as the Chinese cannon or the grasshopper),
+lame leapers (the move of which can be blocked on squares they cannot move to,
+such as the Chinese horse and elephant),
+and any combination thereof,
+in every possible direction.
+The board width is configurable upto a width of 14 squares,
+and cylindrical boards (where left and right edge connect) are supported as well.
+
+=head1 OPTIONS
+
+=over 8
+
+=item B<hashSize>
+
+If the first argument to fairymax is numeric,
+it is taken as an indicator for the amount of memory Fairy-Max is allowed to use
+for its internal hash table.
+The default value for this argument, 22, would result in a memory usage of 48MB.
+Each next-higher number doubles the memory usage, each next-lower halves it.
+Running with less than 6MB (i.e. argument 19) is not recommended.
+When fairymax is running under xboard 4.3.15 the hash-table size can be set 
+through the xboard menus,
+making this argument superfluous.
+
+=item B<iniFile>
+
+A second or non-numeric first argument is taken as a filename.
+Fairy-max will use the mentioned file in stead of its default fmax.ini file
+to define the movement of pieces and initial setup of the variants.
+This makes it easier to define your own variants.
+
+=back
+
+
+=head1 SEE ALSO
+
+xboard(6)
+
+http://www.chessvariants.org/index/msdisplay.php?itemid=MSfairy-max
+
+http://home.hccnet.nl/h.g.muller/max-src2.html
+
+http://www.open-aurec.com/wbforum/viewtopic.php?t=49439
+
+
+=head1 AUTHOR
+
+B<Fairy-Max> was written by H.G.Muller <h.g.muller at hccnet.nl>.
+
+This manual page was generated with pod2man(1).
diff --git a/md5sums b/md5sums
index 1baacc4..f599e5f 100644
--- a/md5sums
+++ b/md5sums
@@ -1,10 +1,11 @@
-c754004f67e8f6f59ad7084f53c44a2d  fairymax/README
-d907f5af0c1cf96c53e6271485beb0b1  fairymax/copyright
-cfe941bb7d308b91f5d7348f16d0e399  fairymax/changelog.gz
-45493909b7a5fefdb78b46e03f53853c  fairymax/fairymax.c
-81c983b6325e9b9c94979685b1777a9b  fairymax/maxqi.c
-b851b7bc80c6db22089b81af1f8d1dbc  fairymax/Makefile
-31d11c7183a805f64896808854603fff  fairymax/fairymax.6.gz
-4acd0ed6e5b58545f6151994ba7b9d71  fairymax/data/fmax.ini
-674172f47a1ddc15fcfa165088fb7122  fairymax/data/qmax.ini
-
+58af54e80d68b2b6212f9155e866fb7d	Fairy-Max/Makefile
+860020905dcdb168a1b84ff6425ce26c	Fairy-Max/README
+3aae714ddb153bee8f345b8113a2d489	Fairy-Max/changelog
+d907f5af0c1cf96c53e6271485beb0b1	Fairy-Max/copyright
+d41d8cd98f00b204e9800998ecf8427e	Fairy-Max/data
+003dc6cf98fe4449ed03a6b6ec0f1869	Fairy-Max/fairymax.c
+b7983b54c6bcc6c9fa34d9bd3f5b6592	Fairy-Max/fairymax.pod
+81c983b6325e9b9c94979685b1777a9b	Fairy-Max/maxqi.c
+d41d8cd98f00b204e9800998ecf8427e	Fairy-Max/md5sums
+9a548807b36e48ba568518051c769a3d	Fairy-Max/data/fmax.ini
+674172f47a1ddc15fcfa165088fb7122	Fairy-Max/data/qmax.ini

-- 
Packaging for fairymax



More information about the Pkg-games-commits mailing list