Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
[email protected] webmail now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!

Paste

Pasted as Python by N78_Training ( 4 years ago )
import chess.pgn
from chess import Board

pgn = open("somegames.pgn")
game = chess.pgn.read_game(pgn)

board = Board()

for node in game.mainline():
	move = node.move
	comment = node.comment
	print(board.fullmove_number)
	print(move)
	if comment:
		print(comment)
	else:
		print('(move has no comment)')
	board.push(move) # last so that the move numbers are correct, yeah, we could also just count up instead of pushing moves to the board.
	print()

 

Revise this Paste

Your Name: Code Language: