fairy-stockfish / variant-nnue-pytorch

chess variant NNUE training code for Fairy-Stockfish
https://github.com/fairy-stockfish/variant-nnue-pytorch/wiki/Introduction
28 stars 18 forks source link

Sample variant.py for xiangqi #10

Closed macteki closed 2 years ago

macteki commented 2 years ago

The variant.py in the master branch is for chess only. Could you provide a sample for xiangqi training ? My guess is something like: (please correct any mistakes)

RANKS = 10 FILES = 9 SQUARES = RANKS FILES KING_SQUARES = RANKS FILES PIECE_TYPES = 7 PIECES = 2 PIECE_TYPES USE_POCKETS = False POCKETS = 2 FILES if USE_POCKETS else 0

PIECE_VALUES = { 1 : 200, # copied from types.h in fairy stockfish, SoldierValueMg 2 : 420, # FersValueMg 3 : 300, # ElephantValueMg 4 : 520, # HorseValueMg 5 : 800, # CannonPieceValueMg 6 : 1276 # RookValueMg }

ianfab commented 2 years ago

As mentioned in the wiki, the training data generator prints the required code changes when switching to a variant. E.g.,:

input: setoption name UCI_Variant value xiangqi output:

lib/nnue_training_data_formats.h:
#define FILES 9
#define RANKS 10
#define PIECE_TYPES 7
#define PIECE_COUNT 32
#define POCKETS false
#define KING_SQUARES 9

variant.py:
RANKS = 10
FILES = 9
SQUARES = RANKS * FILES
KING_SQUARES = 9
PIECE_TYPES = 7
PIECES = 2 * PIECE_TYPES
USE_POCKETS = False
POCKETS = 2 * FILES if USE_POCKETS else 0

PIECE_VALUES = {
  1: 1276,
  2: 420,
  3: 800,
  4: 200,
  5: 520,
  6: 300,
}
ianfab commented 2 years ago

I also updated branch https://github.com/ianfab/variant-nnue-pytorch/tree/xiangqi where the changes for xiangqi are already done, so you can simply use that branch from now on for xiangqi and don't need to do manual changes.