spectral: enable mate
authorMichal Terepeta <michal.terepeta@gmail.com>
Mon, 13 Mar 2017 22:34:12 +0000 (18:34 -0400)
committerBen Gamari <ben@smart-cactus.org>
Mon, 13 Mar 2017 23:44:06 +0000 (19:44 -0400)
Summary:
This also adds the `mate.stdout` file with the expected result.

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
Test Plan: compile & run nofib

Reviewers: bgamari

Reviewed By: bgamari

Differential Revision: https://phabricator.haskell.org/D3161

spectral/Makefile
spectral/mate/Makefile
spectral/mate/README
spectral/mate/mate.stdout [new file with mode: 0644]

index 6187c33..c056f4c 100644 (file)
@@ -4,12 +4,12 @@ include $(TOP)/mk/boilerplate.mk
 SUBDIRS = ansi atom awards banner boyer boyer2 calendar cichelli circsim \
           clausify constraints cryptarithm1 cryptarithm2 cse eliza expert \
           fft2 fibheaps fish gcd hartel integer knights lambda last-piece lcss life \
-         mandel mandel2 minimax multiplier para power pretty primetest puzzle \
-          rewrite scc simple sorting sphere treejoin
+         mandel mandel2 mate minimax multiplier para power pretty primetest \
+         puzzle rewrite scc simple sorting sphere treejoin
 
 # compreals    no suitable test data
 # salishan     no Haskell code!
-OTHER_SUBDIRS = compreals lambda last-piece mate salishan secretary triangle
+OTHER_SUBDIRS = compreals lambda last-piece salishan secretary triangle
 
 include $(TOP)/mk/target.mk
 
index 4775ac0..d2812b9 100644 (file)
@@ -1,7 +1,10 @@
 TOP = ../..
 include $(TOP)/mk/boilerplate.mk
 
-# Arguments for the test program
+# It's necessary to specify those manually so that the current make-based system
+# compiles them in the right order.
+# TODO(michalt): This should go away once we move to the Shake-based system.
+HS_SRCS = Board.hs Move.hs Problem.hs Solution.hs Main.hs
 PROG_ARGS = holzhausen.prob
 
 #      Other problems
index 79911b7..c378cec 100644 (file)
@@ -1,15 +1,26 @@
-Mate solves chess end-game problems of the form "White to move\r
-and mate in N".  For example problems (standard input) and\r
-solutions (standard output) see *.in and *.out.\r
-\r
-The program works by brute-force search in an AND-OR game-tree\r
-of depth 2N-1 in which nodes represent board positions and\r
-succession is by legal move.\r
-\r
-Here are approximate timings for some of the problems, when\r
-Mate is compiled to byte-code by nhc98 and run on a 700MHz PC\r
-(all times in seconds):\r
-\r
-ellerman      3    \r
-shinkman     70\r
-fridlizius  140   \r
+UPDATE(2017.02)
+---------------
+
+Currently `make` will run the `holzhausen.prob` (specified in the `Makefile`),
+the output is simply copied to `mate.stdout`
+(`cp holzhausen.soln mate.stdout`).
+If you want to change the benchmark, you need to update both of these.
+
+ORIGINAL README
+---------------
+
+Mate solves chess end-game problems of the form "White to move
+and mate in N".  For example problems (standard input) and
+solutions (standard output) see *.in and *.out.
+
+The program works by brute-force search in an AND-OR game-tree
+of depth 2N-1 in which nodes represent board positions and
+succession is by legal move.
+
+Here are approximate timings for some of the problems, when
+Mate is compiled to byte-code by nhc98 and run on a 700MHz PC
+(all times in seconds):
+
+ellerman      3
+shinkman     70
+fridlizius  140
diff --git a/spectral/mate/mate.stdout b/spectral/mate/mate.stdout
new file mode 100644 (file)
index 0000000..1188334
--- /dev/null
@@ -0,0 +1,64 @@
+
+File: holzhausen.prob
+ - - - - R - - K
+ - - - - - - - b
+ - b - - N - q -
+ - - - - - - - -
+ - - - - - - P -
+ - r - - - - p -
+ - - p - - - - k
+ - - - - - - - -
+
+White to move and mate in 4
+
+1. B/QN6-QB7,
+       if R/K1-KB1; 2. B/QB7-K5,
+               if N/K3-KN2; 3. B/K5xN/KN7++
+               if R/KB1-KB3; 3. B/K5xR/KB6, N/K3-KN2; 4. B/KB6xN/KN7++
+       if R/K1-K2; 2. B/QB7-K5,
+               if R/K2-KN2; 3. B/K5-KB6, ...; 4. B/KB6xR/KN7++
+               if N/K3-KN2; 3. R/QN3-QN8, R/K2-K1; 4. R/QN8xR/K8++
+       if R/K1-KN1; 2. B/QB7-K5,
+               if R/KN1-KN2; 3. B/K5-KB6, ...; 4. B/KB6xR/KN7++
+               if N/K3-KN2; 3. B/K5-QR1, ...; 4. B/QR1xN/KN7++
+       if R/K1-QN1; 2. B/QB7-KB4,
+               if R/QN1-KB1; 3. B/KB4-K5,
+                       if N/K3-KN2; 4. B/K5xN/KN7++
+                       if R/KB1-KB3; 4. Q/KN6-KN8++
+               if R/QN1-QN4; 3. B/KB4-K5,
+                       if N/K3-KN2; 4. B/K5xN/KN7++
+                       if R/QN4xB/K4; 4. Q/KN6-KN8++
+               if N/K3-Q1; 3. B/KB4xR/QN8,
+                       if N/Q1-QN2; 4. B/QN8-K5++
+                       if others; 4. Q/KN6-KN8++
+               if N/K3-QB4; 3. B/KB4xR/QN8,
+                       if N/QB4-QR5, -QR3, xR/QN6, -QN2; 4. B/QN8-K5++
+                       if others; 4. Q/KN6-KN8++
+               if N/K3-KN2; 3. B/KB4xR/QN8, ...; 4. Q/KN6-KN8++
+               if R/QN1-KN1; 3. B/KR7xR/KN8,
+                       if N/K3xB/KB5, -KN2; 4. Q/KN6-KR7++
+                       if others; 4. B/KB4-K5++
+               if R/QN1-QN2; 3. Q/KN6-KN8++
+               if N/K3xB/KB5; 3. R/QN3xR/QN8++
+               if N/K3-QB2, -Q5, -KB1, -KN4; 3. B/KB4-K5++
+               if others; 3. B/KB4-K5, N/K3-KN2; 4. B/K5xN/KN7++
+       if N/K3xB/QB2; 2. R/QN3-QN8,
+               if R/K1xR/QN1; 3. B/KR7-KN8,
+                       if R/QN1xB/KN1; 4. Q/KN6-KR6++
+                       if others; 4. Q/KN6-KR7++
+               if N/QB2-K3; 3. R/QN8xR/K8, N/K3-KB1; 4. R/K8xN/KB8++
+               if R/K1-KB1; 3. R/QN8xR/KB8++
+               if R/K1-KN1; 3. R/QN8xR/KN8++
+               if R/K1-Q1; 3. R/QN8xR/Q8, N/QB2-K1; 4. R/Q8xN/K8++
+               if R/K1-QB1; 3. R/QN8xR/QB8, N/QB2-K1; 4. R/QB8xN/K8++
+               if others; 3. R/QN8xR/K8++
+       if N/K3-KN2; 2. R/QN3-QN8,
+               if R/K1xR/QN1; 3. B/QB7xR/QN8, ...; 4. Q/KN6-KN8++
+               if N/KN2-K3; 3. R/QN8xR/K8, N/K3-KB1; 4. R/K8xN/KB8++
+               if R/K1-KB1; 3. R/QN8xR/KB8++
+               if R/K1-KN1; 3. R/QN8xR/KN8++
+               if R/K1-Q1; 3. R/QN8xR/Q8, N/KN2-K1; 4. R/Q8xN/K8++
+               if R/K1-QB1; 3. R/QN8xR/QB8, N/KN2-K1; 4. R/QB8xN/K8++
+               if others; 3. R/QN8xR/K8++
+       if R/K1-QR1, -QB1, -Q1; 2. B/QB7-K5, N/K3-KN2; 3. B/K5xN/KN7++
+       if others; 2. B/QB7-K5, R/K1xB/K4; 3. Q/KN6-KN8++