copied over chess.js sources