To do this, we will need you to create different types of chess pieces to populate the board. All Chess_Pieces will have some of the same properties: a unique ID (represented by a string), a position on a board represented by an (x, y) coordinate, a color (represented by a string), a direction (“UP” or “DOWN”), and a board size (expressed as a tuple of (width, height)). The default size of the chess board should be 8×8. However, this should be configurable by parameter. Regardless of the size of the board, (0,0) should be considered to be in the lower, left hand corner. Keep in mind that the orientation of the board does matter, but assume the coordinate system’s origin is the lower left hand corner from where you are viewing the chess board (See image below of standard 8x8 chess board). If a piece is not on the chess board yet, its position should be (None, None).
All Chess_Pieces will also have some universally similar behaviors: If a Chess_Piece is not already on the board, it should be able to be placed on any valid position on the chess board. The Chess_Piece should be able to move to a position that is a valid movement position for the piece (although the list of valid moves is not specified within the Chess_Piece class itself, since each Chess_Piece has its own rules for movement). Any Chess_Piece should be able to be removed from the board at any point. Finally, a Chess_Piece can try to take another piece. This is done (generally; note the exception for Pawns, below) by checking to see if the other Chess_Piece is on a position that this Chess_Piece can move onto.
With the general behavior of all Chess_Pieces defined, we need to define the behaviors of individual pieces. A Pawn is a Chess_Piece that can only move one or two spaces in the direction that it is facing.
A Knight is a Chess_Piece that moves by leaping in an “L-shape,” meaning that it moves one space ahead
and two spaces to a side OR two spaces ahead and one space to a side. These spaces are the only spaces that
the Knight can land on to move or take another piece and any Chess_Pieces in any intermediate space are
safe.
A King is a Chess_Piece that can only move one space in any of the 8 directions (straight line or diagonal).
Finally, there are three pieces that have a strong similarity in behavior. A Bishop is a Chess_Piece that can
move diagonally for 1 or more positions. A Rook is a Chess_Piece that can move laterally (horizontally or
vertically) for 1 or more positions. Finally, a Queen is a Rook that can move diagonally OR laterally (horizontally
or vertically) for 1 or more positions. None of these three types of Chess_Pieces need to check for
obstructions when determining valid moves and can take a Chess_Piece if the target Chess_Piece in a
position that is in the list of valid moves.
Lab Requirements
For this lab, create 7 different classes using object-oriented principles and design to implement the above
behaviors. These objects are to be called Chess_Piece, Pawn, Knight, King, Bishop, Rook, and Queen.
Any Chess_Piece will have its ID, initial position, color, and direction declared at instantiation. Each
Chess_Piece can also have the size of the chess board it is on declared at instantiation but, if it is not, then
the board size should default to the standard 8×8 board. Every other object is a Chess_Piece; however, we
are going to consider the Queen to also be a more specific type of Rook. The Chess_Piece class should be
in its own code file named chess_piece.py. All other classes should be included into a single file called
pieces.py.
All objects will have pure accessor methods for ALL state variables. Additionally, all objects will have an
accessor method that checks if piece is on the chess board. If it is, it should return True and False
otherwise. Finally, the method get_valid_moves should return a list of tuples representing all of the valid
moves for the given piece.
Hi
I have read your description before an hour I think.
I can do your task. I have 3+ years of experience in Python and OOP.
It will be done not just before friday but tomorrow.
Feel free to send a message please.
$30 USD in 1 Tag
5,0 (25 Bewertungen)
4,5
4,5
2 Freelancer bieten im Durchschnitt $30 USD für diesen Auftrag