exp: absolute position and own-side rank as attributes
The CPPN sees only r_ij, so the representation is translation-invariant and a chess board has edges: a knight has 2.96 destinations on the rim against 6.85 in the middle, and 43% of them sit on the rim. Relative geometry to other pieces cannot recover that on a near-empty board, and the shape control is handed the square while the organism was not. own_rank is rank from the piece's own back rank, so a pawn's push, its double-push rank, its promotion and castling are one law rather than two mirrored ones.
This commit is contained in:
2 files changed
+28
-2
No files matched your search
+13
-2
@@ -38,7 +38,14 @@ from ailed import Affect, Organism
|
||||
from chess_domain import flat_diff
|
||||
from chess_reach import GRID, OFFSET
|
||||
|
||||
ATTR_DIM = 9 # type (6), colour (1), this piece still has a castling right (1), ep flag (1)
|
||||
# type (6), colour (1), castling right (1), ep flag (1), file, rank, rank-from-my-own-side (3)
|
||||
ATTR_DIM = 12
|
||||
# The last three exist because the CPPN sees only r_ij, which makes the representation
|
||||
# translation-invariant -- and a chess board has EDGES. A knight on the rim has 2.96
|
||||
# destinations on average and one in the middle has 6.85, and 43% of knights sit on the rim
|
||||
# (measured). Relative geometry to other pieces cannot recover that on a near-empty board.
|
||||
# `own_rank` is rank from the piece's own back rank: a pawn's push, its double-push rank, its
|
||||
# promotion rank and castling are all one law in that frame and two mirrored laws without it.
|
||||
HOME = ((chess.WHITE, chess.E1, chess.H1, chess.A1), (chess.BLACK, chess.E8, chess.H8, chess.A8))
|
||||
|
||||
|
||||
@@ -148,7 +155,11 @@ def build(b: chess.Board) -> Position:
|
||||
ep = b.ep_square if (b.ep_square is not None and p.piece_type == chess.PAWN
|
||||
and b.ep_square in _rule_only(p, sq, False, None)) else None
|
||||
attrs[k, 8] = float(ep is not None)
|
||||
coords[k] = (chess.square_file(sq) / 7.0, chess.square_rank(sq) / 7.0)
|
||||
f, r = chess.square_file(sq), chess.square_rank(sq)
|
||||
coords[k] = (f / 7.0, r / 7.0)
|
||||
attrs[k, 9] = f / 7.0
|
||||
attrs[k, 10] = r / 7.0
|
||||
attrs[k, 11] = (r if p.color == chess.WHITE else 7 - r) / 7.0
|
||||
for t in dests.get(sq, ()):
|
||||
y[k, OFFSET[sq][t]] = 1.0
|
||||
for t in _rule_only(p, sq, right, ep):
|
||||
|
||||
Reference in new issue
Block a user