From: Fabian Fichter Date: Sat, 30 Nov 2019 17:35:51 +0000 (+0100) Subject: Support Tsume mode X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=d745e5cce8c4bf41eff7ad9ca1c3a2f5a3ec311b;p=fairystockfish.git Support Tsume mode Allows to solve Tsume puzzles. Example: ``` setoption name TsumeMode value true setoption name UCI_Variant value shogi position fen 1kp6/2l6/2l6/2l6/2n6/2n6/1gn6/9/L8[SPPPPPPrrbbgggsssnlppp] w 0 1 d go mate 20 ``` --- diff --git a/Readme.md b/Readme.md index c65baf5..f6b481b 100644 --- a/Readme.md +++ b/Readme.md @@ -46,7 +46,7 @@ The games currently supported besides chess are listed below. Fairy-Stockfish ca - [Clobber](https://en.wikipedia.org/wiki/Clobber) ## Installation -You can download [binary releases](https://github.com/ianfab/Fairy-Stockfish/releases) for Windows and Linux or [compile the program from source](https://github.com/ianfab/Fairy-Stockfish#compiling-stockfish-yourself-from-the-sources). You probably want to use it together with a GUI, see https://github.com/ianfab/Fairy-Stockfish/wiki/Usage for recommendations. Or play against it right away online at https://pychess-variants.herokuapp.com/. +You can download [binary releases](https://github.com/ianfab/Fairy-Stockfish/releases) for Windows and Linux or [compile the program from source](https://github.com/ianfab/Fairy-Stockfish#compiling-stockfish-yourself-from-the-sources). The program comes without a graphical user interface, so you probably want to use it together with a [compatible GUI](https://github.com/ianfab/Fairy-Stockfish/wiki/Usage). Or play against it right away online at [pychess-variants](https://pychess-variants.herokuapp.com/). ## UCI parameters @@ -55,7 +55,7 @@ The following UCI options are added or changed compared to official Stockfish: * #### UCI_Variant The most important option, since it allows to set the variant that is going to be played. Most GUIs for chess variants set this option automatically if you select a variant in the GUI, - but in case of usage via CLI or via Shogi GUIs the option needs to be set manually. + but in case of usage via the CLI the option needs to be set manually. * #### UCI_Chess960 Used as a universal flag to switch between Chess960-style shuffling variants (such as Crazyhouse960, @@ -64,13 +64,18 @@ The following UCI options are added or changed compared to official Stockfish: * #### Protocol Can be used to switch between the supported protocols, namely UCI, UCCI (Xiangqi), USI (Shogi) and XBoard/CECP. - This option is automatically set to the respective protocol if a GUI starts communication + This option is automatically set to the respective protocol if communication is started with one of the `uci`/`ucci`/`usi`/`xboard` commands (as required by the protocols). * #### VariantPath The path to the configuration file for user-defined variants. Alternatively, the [`load`](https://github.com/ianfab/Fairy-Stockfish/wiki/Variant-configuration#loading-variant-configuration) command can be used. + * #### TsumeMode + When enabled assumes that the side without a king has to strive for a forced mate, and otherwise loses. + This option should be enabled when solving Tsume puzzles, otherwise it might wrongly go for a brinkmate. + Although it mainly targets Shogi, the option can be used for any variant where checkmate is the goal. + ## Help See the [Fairy-Stockfish Wiki](https://github.com/ianfab/Fairy-Stockfish/wiki) for more info, or if the required information is not available, open an [issue](https://github.com/ianfab/Fairy-Stockfish/issues). diff --git a/src/position.cpp b/src/position.cpp index e921d83..a673efb 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1915,6 +1915,12 @@ bool Position::is_immediate_game_end(Value& result, int ply) const { } } } + // Tsume mode: Assume that side with king wins when not in check + if (Options["TsumeMode"] && count(sideToMove) && !checkers()) + { + result = mate_in(ply); + return true; + } return false; } diff --git a/src/ucioption.cpp b/src/ucioption.cpp index 8a385bf..c101a6e 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -118,6 +118,7 @@ void init(OptionsMap& o) { o["SyzygyProbeDepth"] << Option(1, 1, 100); o["Syzygy50MoveRule"] << Option(true); o["SyzygyProbeLimit"] << Option(7, 0, 7); + o["TsumeMode"] << Option(false); o["VariantPath"] << Option("", on_variant_path); }