Question
Python 3 Follow up to http://www.chegg.com/homework-help/questions-and-answers/python-program-players-decide-random-moves-first-turn-player-must-make-one-two-types-move--q28825646 and http://www.chegg.com/homework-help/questions-and-answers/python-3-comments-please-thanks-write-function-makemovecapture-boardstring-start-end-takes-q28778650 Write a function make_move_sequence(board_string,move_sequence) that validates a sequence of moves constituting part of a game. This sequence
Python 3
Follow up to
http://www.chegg.com/homework-help/questions-and-answers/python-program-players-decide-random-moves-first-turn-player-must-make-one-two-types-move--q28825646 and http://www.chegg.com/homework-help/questions-and-answers/python-3-comments-please-thanks-write-function-makemovecapture-boardstring-start-end-takes-q28778650
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........oooo', [((1, 0), (1, 1)), ((2, 3), (1, 2))]))
'x.xx.x...o..oo.o'
>>> print(make_move_sequence('x.xx.x...o..oo.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_normal(board_string, start, end) function from Question 1 and make_move_capture(board_string, start,end) function from Question 2 that you can use here. You can use our reference implemenation of the function make_move_normal(board, start, end) or make_move_capture(board, start, end) by adding this code at the beginning of your code:
from reference import make_move_capture, make_move_normal
Default code :
from reference import get_board_state, get_board_string
def make_move_sequence(board_string, move_sequence): # TODO implement this function. return None
if __name__ == '__main__': # Run the examples from the question. print(make_move_sequence('xxxx........oooo', [((1, 0), (1, 1)), ((2, 3), (1, 2))])) print(make_move_sequence('x.xx.x...o..oo.o', [((1, 2), (2, 1)), ((1, 1), (1, 3))]))
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started