Question: Question 1 1 0 0 Marks there are no other pieces on the board ) . A move is valid if the plece can move

Question 1
100 Marks there are no other pieces on the board). A move is valid if the plece can move folls within the fol squares of the board, labeled from 'a' to 'h' horizontally and '1' to '8' vertically. A move from 'a8' to 'h1' means that the piece intends to move from the upper left corner of the board to the lower right corner.
For the purposes of testing, the order of the horizontal/vertical board positions may be transposed ('8a' and 'a8' are equal), and you must perform error checking on the input to ensure it is within the range of the board.
You should handle the following pieces in your implementation, with each piece's implementation being worth 15 marks: King, Queen, Bishop, Rook (Castle), Knight (Horse)
Before you begin, think about valuable functions to build. Small parts of the more extensive program that you can extract that you will need for all the pieces. You should have one helper function for each piece (named as you choose, with parameters of your choosing), and other functions as you see fit.
The final 25 marks will be allocated to:
checking for proper positions
controlling for alternate inputs ('a8' vs '8a')
controlling for other incorrect inputs('a10','10aaa', 'hhhh')
incorrect input should return False
def is_move_valid(piece:str, current_location:str, destination:str) bool:
# YOUR IMPLEMENTATION
Examples of the function running should appear as follows:
> is_move_valid('Queen','a7','a1')
True
is_move_valid('queen','(:7A',?'A1'}
True
is_move_valid('king','A7','C8')
False
is_move_valid('knight','A7','C8')
True
is_move_valid('knight','AA','C8') # AA is an invalid position
False
is_move_valid('knight','A7','C9') # c9 is an invalid square
False
is_move_valid('hammer','A7','A1') # a hammer is not a piece
False
3
3
 Question 1 100 Marks there are no other pieces on the

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 Databases Questions!