Question: USING MATLAB For the game 2048, develop code to move the tiles in either the up, down, left, or right direction. Given the location of

USING MATLAB

For the game 2048, develop code to move the tiles in either the up, down, left, or right direction.

Given the location of the tiles, calculate how the tiles and score will change for each move.

Create the following two functions:

MoveLeftRight

Summary: Given the board as a 4x4 matrix, determine the new board after moving left or right

Inputs: board (4x4 matrix), current score (numeric value), left (boolean value)

Outputs: new board (4x4 matrix), new score (numeric value)

Example to move left: [newBoard,newScore] = MoveLeftRight(board,score,true);

Example to move right: [newBoard,newScore] = MoveLeftRight(board,score,false);

MoveUpDown

Summary: Given the board as a 4x4 matrix, determine how the new board after moving up or down

Inputs: board (4x4 matrix), current score (numeric value), up (boolean value)

Outputs: new board (4x4 matrix), new score (numeric value)

Example to move up: [newBoard,newScore] = MoveUpDown(board,score,true);

Example to move down: [newBoard,newScore] = MoveUpDown(board,score,false);

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!