Last active
January 16, 2022 07:22
-
-
Save FermiDirak/d8dd49f34b877dc2652f45e586e24f59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum PlayerSide { /* ... */ } | |
type Move = { /* ... */ } | |
type Board = { /* ... */ } | |
type Chess = { board: Board; turn: PlayerSide } | |
namespace ChessService { | |
// functions for interacting with the game chess | |
function applyMove(chess: Chess, move: Move): Chess { /* ... */ } | |
function starting_state(): Chess { /* ... */ } | |
function listValidMoves(board: Chess, playerTurn: PlayerSide): Move[] { /* ... */ } | |
// ... | |
} | |
// usage | |
const moves: Move[] = readInput("input.json"); | |
let chess: Chess = ChessService.starting_state(); | |
display(chess.board); | |
moves.forEach(move => { | |
chess = ChessService.applyMove(chess, move); | |
display(chess.board); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment