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