Matlab2048.zip
The game 2048 is a popular cell phone game in iOS and Andriods. Now One simple version is realized in Matlab just for fun.
Nan in matrix is taken as blank position.
main.m -- user can run this script to start the game. It will call other 3 functions during the game.
add2mat.m -- add one 2 element into matrix
move_element.m -- move one element by one step.
move_mat.m -- move the whole matrix according to player's command in one step.
One 4*4 matrix is created and initialized with two 2 element in random position.
All operations are in Matlab Command Window, the move operation that are touch and slide in cell phone are replaced by inputting command of orientation.
The matrix will be updated and displayed in Each step after user's operation.
I will upload an Chinese version to iLoveMatlab.cn later. If having some questions and good advice, please contact hyowinner in iLoveMatlab.cn.
Cite As
Zhongxiao Sun (2024). Matlab2048.zip (https://www.mathworks.com/matlabcentral/fileexchange/47289-matlab2048-zip), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.