hello, world\n (that's seebs, Richard and Dann for now :-) - The following is a random sequence of gibberish, so beware. - If you use gcc on a POSIX.1 system and have getrusage() everything's ready to go make # build the chess executable cd test; make # run the test suite; takes several minutes otherwise frob this directory's Makefile and config.h. - Have a look at the first cut of a man page in doc/chess.1 How to use chess: (a polished version should make it into the man page) ***************** The standard input is a sequence of lines, one problem per line of the following format: bm *; # ; Example (english notation): 6R1/p4p2/1p2q2p/8/6Pk/8/PP2r1PK/3Q4 w - - bm ?; # 2; The describes the following board, obviously, and is modelled after some de facto standard found in rec.games.chess and several archives. Fed to 'chess -1' this will answer: +-A--B--C--D--E--F--G--H-+ 8 | ::: ::: ::: R :::| 8 7 |:p: ::: ::: p ::: | 7 6 | :p: ::: q ::: :p:| 6 5 |::: ::: ::: ::: | 5 4 | ::: ::: ::: P :k:| 4 3 |::: ::: ::: ::: | 3 2 | P :P: ::: r ::: P :K:| 2 1 |::: ::: Q ::: ::: | 1 +-A--B--C--D--E--F--G--H-+ To move: white Mate in: 2 Solution: 0.06 1/35 1. Qd1-e1+ Re2xe1 2. Pg2-g3# Re2-f2 2. Qe1xf2# max moves side to move = 35 max moves side to answer = 2 max number allocations = 5 (Which means a solution, Qd1-e1+, was found in 0.06 seconds and Qd1-e1 was the first of 35 possible first moves of the attacker.) - The default language is english, where is either b or w, is - or one or more of kKqQ. is - or one of abcdefgh and indicates that the opponent's pawn in that row may be captured en passant because the opponent's last move was to move that pawn 2 squares from the home row. bm ?; is needed for compatibility with some archive's best move field. # 3; says 'mate in three moves'. To switch to german, use the '= deutsch;' field. An 'id "whatever";' field is also accepted, e.g. 7L/4b2L/8/5B2/8/8/b5T1/1kl1K2T w K - bm O-O; id "656"; = deutsch; # 2; fed to chess without options will produce +-A--B--C--D--E--F--G--H-+ 8 | ::: ::: ::: :L:| 8 7 |::: ::: :b: ::: L | 7 6 | ::: ::: ::: :::| 6 5 |::: ::: ::: B ::: | 5 4 | ::: ::: ::: :::| 4 3 |::: ::: ::: ::: | 3 2 | b ::: ::: ::: T :::| 2 1 |::: k :l: :K: ::: T | 1 +-A--B--C--D--E--F--G--H-+ Am Zug: weiß Matt in: 2 Rochade: O-O noch erlaubt Lösung: 0.22 36/36 1. O-O Ba2-a1S 2. Tg2-b2# Ba2-a1L 2. Bf5-f6# Ba2-a1T 2. Tg2-b2# Ba2-a1D 2. Bf5-f6# Be7-e5 2. Bf5xe6ep# Be7-e6 2. Bf5xe6# max moves side to move = 39 max moves side to answer = 16 max number allocations = 13 Which means that testing all 36 possible moves for the attacker needed 0.22 seconds. The only solution found was O-O. - Q: Why is the statistics still in English? - Don't "make lclint" yet, it's too noisy :-( Target lint is good for Sunpro's lint available for Solaris 2. - For options see the man page or run chess -h - Comments welcome. /* * You're not supposed to understand the source. If you do, * I'd like to hear from you to explain to me what I've done. * * Regards, * * Jens */ - There are more than a thousand problems in the "1001 Brilliant Ways to Checkmate" archive, test/bwtc.epd. 44 of them don't have a solution in a reasonable number (5 to 10) of moves, and I'm very confident that the bug is not in my program. The suspected kooks are: 5 31 57 74 87 103 108 121 134 256 259 265 317 363 398 399 502 503 513 544 548 557 563 570 573 591 624 632 639 640 644 647 658 671 684 702 758 773 785 840 878 905 911 930 If you know a solution for any of these *please* let me know so I can verify whether my program is buggy or just needs more time to find the solution.