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); });