glinscott / leela-chess

**MOVED TO https://github.com/LeelaChessZero/leela-chess ** A chess adaption of GCP's Leela Zero
http://lczero.org
GNU General Public License v3.0
759 stars 298 forks source link

Moves are not flipped for black #236

Closed mooskagh closed 6 years ago

mooskagh commented 6 years ago

I'm pretty sure it's not supposed to be so, but if fact we do generate separate probabilities for "white promotion" move from "black promotion".

So the problem is that different response is expected from the network depending on colour plane. For example in the starting position, it responds highest probability for move e2e4 (element 332 in policy head) for white, while it should be e7e5 (element 1498 in policy head) for black.

Example:

position startpos moves e2e4
go

## Probability / move / code
P: 0.0648852 a7a6 1391
P: 0.0192473 b7b6 1417
P: 0.0776802 c7c6 1445
P: 0.0764345 d7d6 1474
P: 0.0765887 e7e6 1503
P: 0.0103229 f7f6 1532
P: 0.0555585 g7g6 1561
P: 0.0379902 h7h6 1587
P: 0.0552506 a7a5 1388
P: 0.0217171 b7b5 1413
P: 0.0440853 c7c5 1440
P: 0.031886 d7d5 1469
P: 0.242999 e7e5 1498  <- for example,  not e2e4 332.
P: 0.0144731 f7f5 1527
P: 0.0174095 g7g5 1557
P: 0.0335818 h7h5 1584
P: 0.0192064 b8a6 1630
P: 0.035696 b8c6 1632
P: 0.0391559 g8f6 1755
P: 0.0216504 g8h6 1757
mooskagh commented 6 years ago

Here are moves we generate for move_to_id table: https://gist.github.com/mooskagh/907436d7430b4dc96ae35adc780849f5 Note there are promotion moves for black (like a2a1q)

mooskagh commented 6 years ago

What we can do is completely drop the color plane (always fill with zeros), and fix the move flipping. That way no retraining is needed at all, network will always think as white.

Akababa commented 6 years ago

What's the current problem with the position flipping? Is https://github.com/glinscott/leela-chess/blob/0cb27d5de925c65bfd29df5c906b22cf94e319c2/src/Position.cpp#L988 unsuitable for this purpose?

I implemented this into alpha-chess-zero and would love to see it here too!

sf-x commented 6 years ago

What's the current problem with the position flipping?

The problem is with move flipping which has to go together with position flipping.

mooskagh commented 6 years ago

Indeed, that function is suitable for flipping moves, the problem is just that it's not called.

killerducky commented 6 years ago

Fixed in #231.