You should aim to make your test cases as complete as


Testing your implementation

In addition to implementing your solution, you are also required to submit a suite of test cases that can be used to test your Question 2 make_move_capture function.

You should aim to make your test cases as complete as possible. That is, it should be sufficient to pick up invalid moves. Your suite of test cases may assume that the input passed to your function will be of the correct type and will be well-formed, in that the first argument will be a string of the correct length, containing valid characters ( ' x ' , ' o' , and ' . ' ), and the second and third arguments will be tuples containing the coordinates of start and end coordinates. However, you should not assume that the moves described by these inputs are necessarily valid.

Your test cases suite will be evaluated by running it on several known incorrect implementations, in which it should detect incorrect behaviour; ie, failure to reject invalid input or failure to accept valid input. One of your marks will be allocated on the basis of this evaluation.

Further, we will run a tournament in which each test you submit is used to test every other Question 2 submission, to generate a "leaderboard" of whose test case suites best managed to detect incorrect behaviour in other submissions. Note that this will be run anonymously, you will not know whose submissions were incorrect, simply how many incorrect submissions your test case suite was able to detect. There is a possible bonus mark for accurately detecting incorrect Question 2 submissions!

You should specify your test cases as a series of calls to the function test_make_move_capture( ( board_string, start, end ) , expected_return_value), where board_string and expected_return_value are board string representations of the initial and final boards, and start and end are 2-tuples of positions, as in Question 2. That is, you specify both the arguments and return value for make_move_capture as arguments to test_make_move_capture.

Write a function make_move_sequence(board_string, move_sequence) that validates a sequence of moves constituting part of a game. This sequence may contain both normal and capture moves. This function should take as arguments a string representation of the initial board state, and a list of tuples containing the start and end coordinates corresponding to a sequence of successive moves.

The return value of this function is a string representation of the final board state (ie, after executing all moves in the sequence) if the sequence of moves are valid, or None if an invalid move is made at any point in the sequence.

Assumptions: It can be either black or white's turn for any initial given board state.
>>> print(make_move_sequence('xxxx 0000', [((1, 0), (1, 1)), ((2, 3), (1, 2))]))
'x.xx.x...o..00.o'
>>> print(make_move_sequence('x.xx.x...o 00.o', [((1, 2), (2, 1)), ((1, 1), (1, 3))]))
'x.xx..o ..... ox.o'

We have provided to you a reference implementation of the make_move_normat ( boa rd_st ri ng, start, end) function from Question 1 and make_move_capture (boa rd_stri ng, start, end) function from Question 2 that you can use here. You can use our reference irnplemenation of the function make_move_normal (boa rd , start, end) or make_move_captu re (boa rd , start, end) by adding this code at the beginning of your code:
from reference import make_move_capture, make_move_normal

VVriteafunctimmake_move_capture(board_string, start, end) that takes as input a string representation of the current board state, a tuple representing the initial position of the piece to be moved (start), and a tuple representing the end position (end) the piece is to be moved to. This function will validate if the move is valid and if so, execute the move.

The function should return a string representation of the board reflecting the position of the pieces after the move if the move is valid, or None if the move is invalid.

Note: This is the hardest question in Project 2! If you get stuck, you may want to go on to Questions 3 and 4 first. Remember that you can get marks for your approach, even if you don't get the green diamond!

Attachment:- assignment.zip

Solution Preview :

Prepared by a verified Expert
Dissertation: You should aim to make your test cases as complete as
Reference No:- TGS02764970

Now Priced at $50 (50% Discount)

Recommended (98%)

Rated (4.3/5)