Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function move() that takes the following arguments, in this order: 1. bo

ID: 3595737 • Letter: W

Question

Write a function move() that takes the following arguments, in this order:

1. board: A game board.

2. movement: A string that represents what kind of movement that Starman needs to perform. Four             movement commands are listed below:

• ’U’: go up one row

• ’D’: go down one row

• ’L’: go left one column

• ’R’: go right one column

Note: You may assume that the movement is always one of the four valid ones in this part.

This function should call the four functions you wrote for Parts II through V.

Your move() function should check the value of movement and then perform the corresponding movement by calling the appropriate function you write in Part II through V. move() must also return the value that is returned from the function that it calls. As an example, if the value of movement is ’U’, then move() will

return whatever value is returned by move up().

Hint: Don’t over-think this problem – it is literally four conditional statements based on movement’s value. Under each conditional statement you call one of the move X() functions and return the result from the function call.

Examples:

board1 = [[’.’, ’W’, ’W’, ’.’, ’W’],

                 [’F’, ’F’, ’.’, ’.’, ’F’],

                 [’.’, ’O’, ’.’, ’W’, ’*’],

                 [’.’, ’.’, ’.’, ’W’, ’.’],

                 [’O’, ’.’, ’O’, ’.’, ’.’]]

board2 = [[’.’, ’F’, ’.’, ’F’, ’.’],

                 [’.’, ’.’, ’O’, ’.’, ’.’],

                 [’.’, ’.’, ’O’, ’*’, ’.’],

                 [’W’, ’W’, ’.’, ’O’, ’.’],

                 [’.’, ’.’, ’.’, ’W’, ’.’]]

board3 = [[’F’, ’W’, ’F’, ’.’, ’W’],

                 [’.’, ’.’, ’.’, ’.’, ’.’],

                [’W’, ’*’, ’O’, ’F’, ’.’],

                 [’W’, ’.’, ’.’, ’.’, ’.’],

                 [’.’, ’W’, ’O’, ’.’, ’.’]]

board4 = [[’.’, ’O’, ’.’, ’.’, ’.’],

                 [’.’, ’F’, ’F’, ’.’, ’.’],

                [’W’, ’*’, ’F’, ’F’, ’.’],

                [’F’, ’O’, ’.’, ’.’, ’.’],

                [’.’, ’.’, ’.’, ’.’, ’F’]]

Function Call           Return Value

move(board1, ’U’) [2, 5]

move(board2, ’D’) [4, 4]

move(board3, ’L’) [-1, -1]

move(board4, ’R’) [3, 3]

Updated boards:

board1 = [[’.’, ’W’, ’W’, ’.’, ’W’],

                 [’F’, ’F’, ’.’, ’.’, ’*’],

                 [’.’, ’O’, ’.’, ’W’, ’.’],

   [’.’, ’.’, ’.’, ’W’, ’.’],

   [’O’, ’.’, ’O’, ’.’, ’.’]]

board2 = [[’.’, ’F’, ’.’, ’F’, ’.’],

   [’.’, ’.’, ’O’, ’.’, ’.’],

   [’.’, ’.’, ’O’, ’.’, ’.’],

   [’W’, ’W’, ’.’, ’X’, ’.’],

   [’.’, ’.’, ’.’, ’W’, ’.’]]

board3 = [[’F’, ’W’, ’F’, ’.’, ’W’],

   [’.’, ’.’, ’.’, ’.’, ’.’],

   [’W’, ’*’, ’O’, ’F’, ’.’],

   [’W’, ’.’, ’.’, ’.’, ’.’],

   [’.’, ’W’, ’O’, ’.’, ’.’]]

board4 = [[’.’, ’O’, ’.’, ’.’, ’.’],

   [’.’, ’F’, ’F’, ’.’, ’.’],

   [’W’, ’.’, ’*’, ’F’, ’.’],

   [’F’, ’O’, ’.’, ’.’, ’.’],

   [’.’, ’.’, ’.’, ’.’, ’F’]]

Explanation / Answer


def move(board, moevement):
if moment == 'U':
return move_up(board)
elif moment == 'D':
return move_down(board)
elif moment == 'L':
return move_left(board)
elif moment == 'R':
return move_right(board)

# copy pastable code: https://paste.ee/p/L2s9c

It is assumed that you ahve code for move_up, move_down, move_left, move_right as specification of those are not provided in this question.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote