Question: Create a class called ChessVar to implement an abstract board game based on a chess variant known as Fog of War chess. The game starts

Create a class called ChessVar to implement an abstract board game based on a chess variant known as Fog of War chess.
The game starts with the standard chess setup. You'll need to track which player's turn it is, with white always moving first. Pieces move and capture the same way as in standard chess, but there are no checks, checkmates, castling, en passant, or pawn promotion. Like in standard chess, pawns can move two spaces forward on their first move, but only one space on subsequent moves. The game ends when a player's king is captured, and that player loses.
Special rules for this variant of chess: Each player sees a different version of the board, where they can only view their own pieces and the squares their pieces can legally move to. If an opponents piece occupies one of these squares, it will be visible, as it can be captured. Hidden squares are clearly indicated to avoid confusion with visible empty squares. The objective is not to checkmate the king but to capture it. Players are not informed if their king is in check, and both staying in check or moving into check are legal moves, though they may result in the king being captured and losing the game.
Your ChessVar class must include the following:
-An init method that initializes any data members
-A method called get_game_state that just returns 'UNFINISHED', 'WHITE_WON', 'BLACK_WON'.
-A method called get_board that takes one parameter a string indicating the perspective from which to display the board and return the board. If the argument is 'white', it returns the board oriented for the white player. If 'black', it returns the board from the black players viewpoint. Passing 'audience' returns the complete board without hiding any information.
-A method called make_move that takes two parameters - strings that represent the square moved from and the square moved to. For example, make_move('b2','b4'). If the square being moved from does not contain a piece belonging to the player whose turn it is, or if the indicated move is not legal, or if the game has already been won, then it should just return False. Otherwise it should make the indicated move, remove any captured piece, update the game state if necessary, update whose turn it is, and return True.
Feel free to add whatever other classes, methods, or data members you want. All data members of a class must be private. Every class should have an init method that initializes all of the data members for that class.
Here's a very simple example of how the class could be used:
game = ChessVar() print(game.make_move('d2','d4'))
print(game.make_move('g7','g5'))
print(game.make_move('c1','g5'))
print(game.make_move('e7','e6'))
print(game.make_move('g5','d8'))
print(game.get_board("audience"))
print(game.get_board("white"))
print(game.get_board("black"))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!