Rating:
# Solution
The flag format starts with `flag{` and the hint that the first 40 last 8 half-moves being all theory lets us deduce that each move somehow encodes a bit. `fl` encoded is `01100110 01101100`. Hopefully it isn't too much of a stretch to realize that a same-colored piece moving to the same-colored square is a 1 whereas moving to a different-colored square is a 0.
From there using the Python chess library can quickly solve for the solution. It is intended to be very painful to solve manually. I purposely chose a pgn that did not include castling.
```import chess.pgn, chess
def square_color(move):
# returns True if square color is white
square = move.to_square
if(((square // 8) % 2 == 0) ^ ((square % 8) % 2 == 0)):
return chess.WHITE
return chess.BLACK
pgn = open("dist/chessbros.pgn")
game = chess.pgn.read_game(pgn)
bitstream = ""
for num, move in enumerate(game.mainline_moves()):
if square_color(move) ^ (num % 2 == 0):
bitstream += "0"
else:
bitstream += "1"
# print(bitstream)
assert(len(bitstream) % 8 == 0)
def binary_to_ascii(binary_string):
binary_chunks = [binary_string[i:i+8] for i in range(0, len(binary_string), 8)]
integer_values = [int(binary, 2) for binary in binary_chunks]
ascii_string = ''.join([chr(i) for i in integer_values])
return ascii_string
print(binary_to_ascii(bitstream))
```