Write a function that validates a sequence of moves

Assignment Help Other Subject
Reference no: EM131970501

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

Reference no: EM131970501

Questions Cloud

Prepare the adjusting journal entry to reflect the warranty : Prepare the adjusting journal entry to reflect the associated warranty liability/expense, assuming 1,000 mowers were sold this year.
Is melba required to recognize income : An employer provides all of his employees with life insurance protection equal to twice the employee's annual salary. Melba, age 42, has an annual salary.
What were the companys preferred dividends : What were the company's preferred dividends if net income was $700,000 during a year when beginning common stockholders' equity was $4,750,000.
What is renees domestic production activities deduction : What is Renee's domestic production activities deduction for the gadget in each of the following alternative scenarios?
Write a function that validates a sequence of moves : 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
Would you purchase the machine : You are an engineer for a company that manufactures check valves. One stage of the fabrication process requires that two people per shift assemble the valves.
How much quicker will she pay off the hd television : She decides to pay twice the minimum monthly payment ($20 per month), Instead. How much quicker will she pay off the HD Television?
What sources have you used that you feel are credible : What sources have you used that you feel are credible? Explain why. What sources have you used where you doubt the credibility? Explain why.
Provide your opinion of life and health insurance : Life insurance, like all other insurance, is the ability to combine a homogeneous group of people to spread the risk.

Reviews

Write a Review

Other Subject Questions & Answers

  Cross-cultural opportunities and conflicts in canada

Short Paper on Cross-cultural Opportunities and Conflicts in Canada.

  Sociology theory questions

Sociology are very fundamental in nature. Role strain and role constraint speak about the duties and responsibilities of the roles of people in society or in a group. A short theory about Darwin and Moths is also answered.

  A book review on unfaithful angels

This review will help the reader understand the social work profession through different concepts giving the glimpse of why the social work profession might have drifted away from its original purpose of serving the poor.

  Disorder paper: schizophrenia

Schizophrenia does not really have just one single cause. It is a possibility that this disorder could be inherited but not all doctors are sure.

  Individual assignment: two models handout and rubric

Individual Assignment : Two Models Handout and Rubric,    This paper will allow you to understand and evaluate two vastly different organizational models and to effectively communicate their differences.

  Developing strategic intent for toyota

The following report includes the description about the organization, its strategies, industry analysis in which it operates and its position in the industry.

  Gasoline powered passenger vehicles

In this study, we examine how gasoline price volatility and income of the consumers impacts consumer's demand for gasoline.

  An aspect of poverty in canada

Economics thesis undergrad 4th year paper to write. it should be about 22 pages in length, literature review, economic analysis and then data or cost benefit analysis.

  Ngn customer satisfaction qos indicator for 3g services

The paper aims to highlight the global trends in countries and regions where 3G has already been introduced and propose an implementation plan to the telecom operators of developing countries.

  Prepare a power point presentation

Prepare the power point presentation for the case: Santa Fe Independent School District

  Information literacy is important in this environment

Information literacy is critically important in this contemporary environment

  Associative property of multiplication

Write a definition for associative property of multiplication.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd