Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Chess input representation v3.0 #134

Merged
merged 9 commits into from
Jun 9, 2021
Merged

Chess input representation v3.0 #134

merged 9 commits into from
Jun 9, 2021

Conversation

QueensGambit
Copy link
Owner

@QueensGambit QueensGambit commented Jun 9, 2021

Revision of chess input representation v2.8 (#125) and integration of WDLP value head (#123).
This PR benefits from (#133) because the input representation is more complex now.

Feature Planes Description
P1 piece 6 (pieces are ordered: PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING)
P2 piece 6 (pieces are ordered: PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING)
Repetitions 2 two planes (full zeros/ones) indicating how often the board positions has occurred
En-passant square 1 (Binary map indicating the square where en-passant capture is possible)
P1 castling 2 (One if castling is possible, else zero)
P2 castling 2 (One if castling is possible, else zero)
No-progress count 1 (Setting the no progress counter as integer values, (described by uci halfmoves format)
Last Moves 16 Last moves played
is960 1 indicate if 960 is active
P1 pieces 1 A grouped mask of all P1 pieces
P2 pieces 1 A grouped mask of all P2 pieces
Checkerboard 1 A chess board pattern
P1 Material Diff 5 (pieces are ordered: PAWN, KNIGHT, BISHOP, ROOK, QUEEN), normalized with 8, + means positive, - means negative
Opposite Color Bishops 1 Indicates if they are only two bishops and the bishops are opposite color
Checkers 1 Indicates all pieces giving check
P1 Material Count 5 (pieces are ordered: PAWN, KNIGHT, BISHOP, ROOK, QUEEN), normalized with 8

Total Planes: 52

Changes are highlighted in bold. Removed check moves and mobility feature as it was too costly.

Constants

NORMALIZE_PIECE_NUMBER = 8
NORMALIZE_50_MOVE_RULE = 50
# These constant describe the starting channel for the corresponding info
CHANNEL_PIECES = 0
CHANNEL_REPETITION = 12
CHANNEL_EN_PASSANT = 14
CHANNEL_CASTLING = 15
CHANNEL_NO_PROGRESS = 19
CHANNEL_LAST_MOVES = 20
CHANNEL_IS_960 = 36
CHANNEL_PIECE_MASK = 37
CHANNEL_CHECKERBOARD = 39
CHANNEL_MATERIAL_DIFF = 40
CHANNEL_OPP_BISHOPS = 45
CHANNEL_CHECKERS = 46
CHANNEL_MATERIAL_COUNT = 47

Supervised Training

  • Both better policy and value loss compared to Rise 3.3 (Rise v3.3 #104) under same training configuration.

  • Input 1.0, default AlphaZero Value Head: last_8_moves/rise33

2021-05-05 13:35:20 root[4963] INFO Step 513K/538K - 273ms/step
2021-05-05 13:35:20 root[4963] INFO -------------------------
2021-05-05 13:35:20 root[4963] DEBUG Iteration 513000/538160
2021-05-05 13:35:20 root[4963] DEBUG lr: 0.0000100 - momentum: 0.9500000
 - train_value_loss: 0.4613 - train_policy_loss: 1.1982 - train_value_acc_sign: 0.7238 - train_policy_acc: 0.5872 - train_loss: 1.1908 - val_value_loss: 0.4298 - val_policy_loss: 1.2086 - val_value_acc_sign: 0.7101 - val_policy_acc: 0.5841 - val_loss: 1.2008
2021-05-05 13:35:27 root[4963] INFO Saved checkpoint to "/data/SL/results/risev3.3/weights/model-1.20081-0.584-0513.params"
 - 280s
  • Input 3.0 only, default AlphaZero Value Head: 8_default_heads_7_epochs
2021-06-08 10:45:43 root[12519] INFO Step 513K/538K - 290ms/step
2021-06-08 10:45:43 root[12519] INFO -------------------------
2021-06-08 10:45:43 root[12519] DEBUG Iteration 513000/538160
2021-06-08 10:45:43 root[12519] DEBUG lr: 0.0000100 - momentum: 0.9500000
 - train_value_loss: 0.4587 - train_policy_loss: 1.1965 - train_value_acc_sign: 0.7258 - train_policy_acc: 0.5856 - train_loss: 1.1892 - val_value_loss: 0.4306 - val_policy_loss: 1.2044 - val_value_acc_sign: 0.7086 - val_policy_acc: 0.5848 - val_loss: 1.1966
2021-06-08 10:45:51 root[12519] INFO Saved checkpoint to "/data/SL/results_input_3.0/8_default_heads_7_epochs/weights/model-1.19661-0.585-0513.params"
 - 298s
  • Input 3.0, with WDLP Value Head: 7_wdlp_head_7_epochs
2021-06-08 11:19:55 root[12141] INFO Step 513K/538K - 285ms/step
2021-06-08 11:19:55 root[12141] INFO -------------------------
2021-06-08 11:19:55 root[12141] DEBUG Iteration 513000/538160
2021-06-08 11:19:55 root[12141] DEBUG lr: 0.0000100 - momentum: 0.9500000
 - train_value_loss: 0.4533 - train_policy_loss: 1.1950 - train_value_acc_sign: 0.7293 - train_policy_acc: 0.5870 - train_wdl_loss: 0.8887 - train_wdl_acc: 0.5630 - train_plys_to_end_loss: 0.0728 - train_loss: 1.1876 - val_value_loss: 0.4260 - val_policy_loss: 1.2019 - val_value_acc_sign: 0.7102 - val_policy_acc: 0.5854 - val_wdl_loss: 0.9041 - val_wdl_acc: 0.5512 - val_plys_to_end_loss: 0.0734 - val_loss: 1.1941
2021-06-08 11:20:02 root[12141] INFO Saved checkpoint to "/data/SL/results_input_3.0/7_wdlp_head_7_epochs/weights/model-1.19414-0.585-0513.params"
 - 292s

Performance

  • About +45 Elo for standard chess compared to RISE3.3 with input 1.0 and AlphaZero value head.
./cutechess-cli -variant standard -openings file="/data/SL/opening_suites/UHO_V3_6mvs_+090_+099.pgn" format=pgn plies=100 -pgnout "/data/SL/pgn_out/wdlp_input_3.0_vs_rise3.3_default.pgn" -resign movecount=5 score=600 -draw movenumber=30 movecount=4 score=20 -concurrency 1 -engine name=ClassicAra-0.9.5_e17e608_wdlp_input_3.0 option.Model_Directory=/data/SL/model/input_3.0/7_wdlp_head_7_epochs cmd=/data/SL/@JC_ClassicAra_input_3.0 -engine name=ClassicAra-0.9.5_51bb64f option.Model_Directory=/data/SL/model/input_1.0/rise33 cmd=/data/SL/@JC_ClassicAra_51bb64f -each dir=/data/SL/ option.Threads=3 proto=uci tc=0/1:0+0.25 option.First_Device_ID=15 option.Last_Device_ID=15 -games 2 -rounds 300 -repeat&
tc=0/1:0+0.25 
Score of ClassicAra-0.9.5_e17e608_wdlp_input_3.0 vs ClassicAra-0.9.5_51bb64f: 50 - 30 - 72  [0.566] 152
wdlp_input_3.0_vs_rise3.3_default.pgn

Name                        :  Games                 Elo    Pts   Pts%   Win  Loss  Draw  Tf  Sc
ClassicAra-0.9.5_51bb64f    :    152   -45.98 +/-  40.23   66.0   43.4    30    50    72   0   0
ClassicAra-0.9.5_e17e608_wd :    152    45.98 +/-  40.23   86.0   56.6    50    30    72   0   0

Name                        :  W_win  B_win   Draw
ClassicAra-0.9.5_51bb64f    :     26      4     72
ClassicAra-0.9.5_e17e608_wd :     41      9     72


Name                        :   Wapc     Sd
ClassicAra-0.9.5_51bb64f    :    121     38
ClassicAra-0.9.5_e17e608_wd :    135     42

Finished games   : 152
White wins       : 67 (44.1%)
Black wins       : 13 (8.6%)
Draws            : 144 (94.7%)
Unfinished games : 0 (0.0%)

Tf = time forfeit
Sc = stalled connection
Wapc = win average ply count, lower is better
Sd = standard deviation

increased version to 0.9.4
added is_terminal() for MCTS_TB_SUPPORT=false
added input_representation.py for version 3
added missing 50-move rule normalization for input 3.0
added implementation for input 3.0 in C++
added unit-tests
added VERSION=3 to CMakeLists.txt
@QueensGambit QueensGambit changed the title Input 3.0 Chess input representation v3.0 Jun 9, 2021
@QueensGambit QueensGambit merged commit 7000731 into master Jun 9, 2021
@QueensGambit QueensGambit deleted the input_3.0 branch June 30, 2021 11:44
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant