Question: USING MATLAB - PLEASE READ ALL INSTRUCTIONS - USE FOR LOOPS AND IF STATEMENTS AS MAIN COMMANDS For the game 2048, develop code (MATLAB) to
USING MATLAB - PLEASE READ ALL INSTRUCTIONS - USE FOR LOOPS AND IF STATEMENTS AS MAIN COMMANDS
For the game 2048, develop code (MATLAB) 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 (MATLAB):
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
To develop the MATLAB code for moving tiles in the 2048 game we will break down the task into two main parts creating the MoveLeftRight function and the MoveUpDown function Both functions will use loo... View full answer
Get step-by-step solutions from verified subject matter experts
