Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions

Question

Which table does the DEPARTMENT table relate to?

Answered: 1 week ago