#ifndef PARSER_H_INCLUDED
#define PARSER_H_INCLUDED
+#include <iostream>
+
#include "variant.h"
+class Config : public std::map<std::string, std::string> {
+public:
+ Config::iterator find (const std::string& s) {
+ constexpr bool PrintOptions = false; // print config options?
+ if (PrintOptions)
+ std::cout << s << std::endl;
+ return std::map<std::string, std::string>::find(s);
+ }
+};
+
class VariantParser {
public:
- VariantParser(const std::map<std::string, std::string>& c) : config (c) {};
+ VariantParser(const Config& c) : config (c) {};
Variant* parse();
Variant* parse(Variant* v);
private:
- std::map<std::string, std::string> config;
+ Config config;
template <class T> void parse_attribute(const std::string& key, T& target);
};
# This is a configuration file to add user-defined variants to Fairy-Stockfish.
-# Usage:
+################################################
+### Usage:
# Add "load" and the file path to the SF call (e.g., "./stockfish load variants.ini")
# or set the UCI option "VariantPath" to the path of this file in order to load it.
-# Variant configuration:
+################################################
+### Variant configuration:
# The variant name needs to be specified as a section in square brackets,
# followed by its rule configurations as key-value pairs.
# See variants.h for the available options and their default values.
# If you encounter problems configuring variants, please report them at:
# https://github.com/ianfab/Fairy-Stockfish/issues
-# Example for minishogi configuration that would be equivalent to the built-in variant:
+### Piece types
+# Firstly, the piece types for a variant need to be defined.
+# For that, specify the letter used for each piece type, e.g.:
+# pawn = p
+#
+# See the list below for all available piece types:
+# pawn
+# knight
+# bishop
+# rook
+# queen
+# fers
+# alfil
+# fers_alfil (=fers+alfil)
+# silver
+# aiwok (=rook+knight+fers)
+# bers (=rook+fers)
+# archbishop (=bishop+knight)
+# chancellor(=rook+bishop)
+# amazon (=queen+knight)
+# knibis
+# biskni
+# shogi_pawn
+# lance
+# shogi_knight
+# euroshogi_knight
+# gold
+# horse
+# clobber
+# breakthrough
+# immobile (piece without moves)
+# cannon
+# wazir
+# commoner (non-royal king)
+# king
+
+### Rule options
+# variantTemplate
+# pocketSize
+# maxRank: maximum rank (e.g., 8)
+# maxFile: maximum file (e.g., 8 or h)
+# chess960: allow chess960 castling (true/false)
+# startFen: FEN of starting position
+# promotionRank: relative rank required to reach for promotion (e.g., 8)
+# promotionPieceTypes: pieces letters of promotion options (e.g., nbrq)
+# sittuyinPromotion: (true/false)
+# promotionLimit
+# promotedPieceType
+# piecePromotionOnCapture: (true/false)
+# mandatoryPawnPromotion: (true/false)
+# mandatoryPiecePromotion: (true/false)
+# pieceDemotion: (true/false)
+# endgameEval: (true/false)
+# doubleStep: (true/false)
+# doubleStepRank
+# firstRankDoubleSteps: (true/false)
+# castling: (true/false)
+# castlingDroppedPiece: (true/false)
+# castlingKingsideFile: e.g., g
+# castlingQueensideFile: e.g., c
+# castlingRank: relative rank of castling, e.g., 1
+# checking: (true/false)
+# mustCapture: (true/false)
+# mustDrop: (true/false)
+# pieceDrops: (true/false)
+# dropLoop: (true/false)
+# capturesToHand: (true/false)
+# firstRankDrops: (true/false)
+# dropOnTop: (true/false)
+# whiteDropRegion
+# blackDropRegion
+# sittuyinRookDrop: (true/false)
+# dropOppositeColoredBishop: (true/false)
+# dropPromoted: (true/false)
+# shogiDoubledPawn: (true/false)
+# immobilityIllegal: (true/false)
+# gating: (true/false)
+# nMoveRule: e.g., 50
+# nFoldRule: e.g., 3
+# nFoldValue: (win/draw/loss)
+# nFoldValueAbsolute: (true/false)
+# perpetualCheckIllegal: (true/false)
+# stalemateValue: (win/draw/loss)
+# checkmateValue: (win/draw/loss)
+# shogiPawnDropMateIllegal: (true/false)
+# shatarMateRule: (true/false)
+# bareKingValue: (win/draw/loss)
+# extinctionValue: (win/draw/loss)
+# bareKingMove: (true/false)
+# extinctionPieceTypes
+# flagPiece
+# whiteFlag
+# blackFlag
+# flagMove: (true/false)
+# checkCounting: (true/false)
+# connectN: number of aligned pieces for win (e.g., 4)
+# countingRule: (makruk/asean)
+
+################################################
+### Example for minishogi configuration that would be equivalent to the built-in variant:
# [minishogi]
# variantTemplate = shogi