File Exchange

image thumbnail

2048 MATLAB Edition

version 1.1.0.1 (54.1 KB) by jiro
This is a MATLAB implementation of the 2048 game

20 Downloads

Updated 01 Sep 2016

View Version History

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

2048 is a game originally created by Gabriele Cirulli. This is a MATLAB implementation of the game.
For users of R2012b or newer, install the app. For older versions of MATLAB, you can run "play2048" inside the "NonAppVersion" folder. You must be using MATLAB R2009b or newer.
There's also a simulator where you can test out your own game solving algorithm. The algorithm must be a MATLAB function with the signature:
function direction = myfcn(board)

where "board" is a 4x4 matrix of numbers representing the game board (NaN for empty spots), and "direction" is a character array representing the direction to move the blocks, i.e. 'up', 'down', 'right', or 'left'.

Read "readme.txt" for more information.

Cite As

jiro (2021). 2048 MATLAB Edition (https://www.mathworks.com/matlabcentral/fileexchange/46124-2048-matlab-edition), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (17)

Mariano

I am using R2018b. The non-app version works fine.
But after installing the app, I get the following error:
Undefined function or variable 'x2048MATLABApp'.
Error in appinstall.internal.runapp>execute (line 116)
out = evalin('caller', [script ';']);
Error in appinstall.internal.runapp>runapp13a (line 95)
outobj = execute(fullfile(appinstalldir, [wrapperfile 'App.m']));
Error in appinstall.internal.runapp>preamble18b (line 60)
appobj = runapp13a(appinstalldir);
Error in appinstall.internal.runapp (line 13)
out = preamble18b(appinstalldir);
Error in matlab.apputil.run (line 45)
appinstall.internal.runapp(appName, appLocation);

matzewolf

Bill McClurg

Found it I was looking in the wrong folder .. thanks

Tyler Marr

For those that are having issues with it crashing after the first time you play, you can comment out lines 266 and 267 or 'Game2048.m' and it will continue to work

nguyen thaithien

zhangye1994

I can't open the app twice, please improve it for us.

danf

Ran into same problem as Sebastian
Decided to explore further
Going deeper and deeper into the unknown code
Please tell my mother if I am not out in 33 days.

Eysteinn Finnsson

Exactly what I was looking for

Sebastian

Nice work! But after I played once, I couldn't open the app again. It seems that the plotting of the previous scores does not work. I got this error "Error using cellfun
matlab.graphics.primitive.Line output type is not supported. Set 'UniformOutput' to false." I fixed it by writing: "hp = cellfun(@(x) line(1:length(x),x,'Parent',obj.hHistoryAxes), fliplr({obj.Game.AllScores.Scores}), 'Uniform', 0); hp = [hp{:}];". I tested under R2015a.

iftah

bnu bnu

Ashan Peiris

Oliver Woodford

panpan

Abhijit Kamble

John Thompson

Davide Ferraro

MATLAB Release Compatibility
Created with R2014a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!