Design a chess engine. How would the game be represented in code? What would the gameplay flow look like? For each piece, how do you check if the player is making a valid move? How do you check if a player's king is in the check position? How do you check if a player's king is in the checkmate position?