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.
jiro (2021). 2048 MATLAB Edition (https://www.mathworks.com/matlabcentral/fileexchange/46124-2048-matlab-edition), MATLAB Central File Exchange. Retrieved .
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Create scripts with code, output, and formatted text in a single executable document.
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);
Found it I was looking in the wrong folder .. thanks
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
I can't open the app twice, please improve it for us.
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.
Exactly what I was looking for
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.