# Question SOLVED: USING MATLAB For the game 2048, develop code to mo...

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);

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);

You'll get a 34.5KB .DOC file.