HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>2048 game</title>
<link href="../css/style.css" rel="stylesheet">
<style>body,html{margin:0;padding:0;background:#faf8ef;color:#776e65;font-family:Raleway,"Helvetica Neue",Arial,sans-serif;/*font-size:18px;*/overscroll-behavior:contain}body{margin:30px 0}.heading:after{content:"";display:block;clear:both}h1.title{font-size:80px;font-weight:700;margin:0;display:block;float:left}h1.title strong:first-child{color:#ea4335}h1.title strong:nth-child(2){color:#34a853}h1.title strong:nth-child(3){color:#fbbc05}h1.title strong:nth-child(4){color:#4285f4}.above-game:after{content:"";display:block;clear:both}.control-buttons{margin-top:10px}.control-buttons::after{display:block;content:"";clear:both}.control-button{box-sizing:border-box;background:#ea4335;border-radius:3px;padding:0 10px;text-decoration:none;color:#fff;height:40px;line-height:42px;display:block;text-align:center;width:30%}.bot-button{float:left}.restart-button{float:right}@-webkit-keyframes move-up{0%{top:-15px;opacity:1}100%{top:-50px;opacity:0}}@-moz-keyframes move-up{0%{top:-15px;opacity:1}100%{top:-50px;opacity:0}}@keyframes move-up{0%{top:-15px;opacity:1}100%{top:-50px;opacity:0}}.scores-container{float:right;text-align:right}.best-container,.score-container{position:relative;box-sizing: content-box;display:inline-block;background:#34a853;padding:15px 25px;font-size:25px;height:25px;line-height:47px;font-weight:700;border-radius:3px;color:#fff;margin-top:8px;text-align:center}.best-container{background-color:#fbbc05}.best-container:after,.score-container:after{position:absolute;width:100%;top:10px;left:0;text-transform:uppercase;font-size:13px;line-height:13px;text-align:center;color:#fff}.best-container .score-addition,.score-container .score-addition{position:absolute;right:30px;color:#ea4335;font-size:25px;line-height:25px;font-weight:700;z-index:100;-webkit-animation:move-up .6s ease-in;-moz-animation:move-up .6s ease-in;animation:move-up .6s ease-in;-webkit-animation-fill-mode:both;-moz-animation-fill-mode:both;animation-fill-mode:both}.score-container:after{content:"Score"}.best-container:after{content:"Best"}p{margin-top:0;margin-bottom:10px;line-height:1.65}a{color:#776e65;font-weight:700;text-decoration:none;cursor:pointer}strong.important{text-transform:uppercase}hr{border:none;border-bottom:1px solid #d8d4d0}#adRect{max-width:468px;min-height:90px;margin:0 auto}.thumbnails-468 .trc_spotlight_item{background-color:#fff!important}.text_nav a{font-size:16px}.text_nav_link{width: unset;}.container{width:500px;margin:0 auto}@-webkit-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-moz-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade-in{0%{opacity:0}100%{opacity:1}}.game-container{position:relative;padding:15px;cursor:default;-webkit-touch-callout:none;-ms-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-ms-touch-action:none;touch-action:none;background:#bbada0;border-radius:6px;width:500px;height:500px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.game-container .game-message{display:none;position:absolute;top:0;right:0;bottom:0;left:0;background:rgba(238,228,218,.5);z-index:100;text-align:center;-webkit-animation:fade-in .8s ease 1.2s;-moz-animation:fade-in .8s ease 1.2s;animation:fade-in .8s ease 1.2s;-webkit-animation-fill-mode:both;-moz-animation-fill-mode:both;animation-fill-mode:both}.game-container .game-message p{font-size:60px;font-weight:700;height:60px;line-height:60px;margin-top:222px}.game-container .game-message .lower{display:block;margin-top:59px}.game-container .game-message a{display:inline-block;background:#ea4335;border-radius:3px;padding:0 20px;text-decoration:none;color:#f9f6f2;height:40px;line-height:42px;margin-left:9px}.game-container .game-message a.keep-playing-button{display:none}.game-container .game-message.game-won{background:rgba(237,194,46,.5);color:#f9f6f2}.game-container .game-message.game-won a.keep-playing-button{display:inline-block}.game-container .game-message.game-over,.game-container .game-message.game-won{display:block}.grid-container{position:absolute;z-index:1}.grid-row{margin-bottom:15px}.grid-row:last-child{margin-bottom:0}.grid-row:after{content:"";display:block;clear:both}.grid-cell{width:106.25px;height:106.25px;margin-right:15px;float:left;border-radius:3px;background:rgba(238,228,218,.35)}.grid-cell:last-child{margin-right:0}.tile-container{position:absolute;z-index:2}.tile,.tile .tile-inner{width:107px;height:107px;line-height:107px}.tile-inner strong:first-child{color:#ea4335}.tile-inner strong:nth-child(2){color:#34a853}.tile-inner strong:nth-child(3){color:#fbbc05}.tile-inner strong:nth-child(4){color:#4285f4}.tile.tile-position-1-1{-webkit-transform:translate(0,0);-moz-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0)}.tile.tile-position-1-2{-webkit-transform:translate(0,121px);-moz-transform:translate(0,121px);-ms-transform:translate(0,121px);transform:translate(0,121px)}.tile.tile-position-1-3{-webkit-transform:translate(0,242px);-moz-transform:translate(0,242px);-ms-transform:translate(0,242px);transform:translate(0,242px)}.tile.tile-position-1-4{-webkit-transform:translate(0,363px);-moz-transform:translate(0,363px);-ms-transform:translate(0,363px);transform:translate(0,363px)}.tile.tile-position-2-1{-webkit-transform:translate(121px,0);-moz-transform:translate(121px,0);-ms-transform:translate(121px,0);transform:translate(121px,0)}.tile.tile-position-2-2{-webkit-transform:translate(121px,121px);-moz-transform:translate(121px,121px);-ms-transform:translate(121px,121px);transform:translate(121px,121px)}.tile.tile-position-2-3{-webkit-transform:translate(121px,242px);-moz-transform:translate(121px,242px);-ms-transform:translate(121px,242px);transform:translate(121px,242px)}.tile.tile-position-2-4{-webkit-transform:translate(121px,363px);-moz-transform:translate(121px,363px);-ms-transform:translate(121px,363px);transform:translate(121px,363px)}.tile.tile-position-3-1{-webkit-transform:translate(242px,0);-moz-transform:translate(242px,0);-ms-transform:translate(242px,0);transform:translate(242px,0)}.tile.tile-position-3-2{-webkit-transform:translate(242px,121px);-moz-transform:translate(242px,121px);-ms-transform:translate(242px,121px);transform:translate(242px,121px)}.tile.tile-position-3-3{-webkit-transform:translate(242px,242px);-moz-transform:translate(242px,242px);-ms-transform:translate(242px,242px);transform:translate(242px,242px)}.tile.tile-position-3-4{-webkit-transform:translate(242px,363px);-moz-transform:translate(242px,363px);-ms-transform:translate(242px,363px);transform:translate(242px,363px)}.tile.tile-position-4-1{-webkit-transform:translate(363px,0);-moz-transform:translate(363px,0);-ms-transform:translate(363px,0);transform:translate(363px,0)}.tile.tile-position-4-2{-webkit-transform:translate(363px,121px);-moz-transform:translate(363px,121px);-ms-transform:translate(363px,121px);transform:translate(363px,121px)}.tile.tile-position-4-3{-webkit-transform:translate(363px,242px);-moz-transform:translate(363px,242px);-ms-transform:translate(363px,242px);transform:translate(363px,242px)}.tile.tile-position-4-4{-webkit-transform:translate(363px,363px);-moz-transform:translate(363px,363px);-ms-transform:translate(363px,363px);transform:translate(363px,363px)}.tile{position:absolute;-webkit-transition:.1s ease-in-out;-moz-transition:.1s ease-in-out;transition:.1s ease-in-out;-webkit-transition-property:-webkit-transform;-moz-transition-property:-moz-transform;transition-property:transform}.tile .tile-inner{border-radius:3px;background:#eee4da;text-align:center;font-weight:700;z-index:10;font-size:55px}.tile.tile-2 .tile-inner{color:#f9f6f2;background:#4285f4;box-shadow:0 0 30px 10px rgba(243,215,116,0),inset 0 0 0 1px rgba(255,255,255,0)}.tile.tile-4 .tile-inner{color:#f9f6f2;background:#ea4335;box-shadow:0 0 30px 10px rgba(243,215,116,0),inset 0 0 0 1px rgba(255,255,255,0)}.tile.tile-8 .tile-inner{color:#f9f6f2;background:#fbbc05}.tile.tile-16 .tile-inner{color:#f9f6f2;background:#34a853}.tile.tile-32 .tile-inner{color:#f9f6f2;background:#e84e9b}.tile.tile-64 .tile-inner{color:#f9f6f2;background:#27a28b}.tile.tile-128 .tile-inner{color:#f9f6f2;background:#f67c5f;box-shadow:0 0 30px 10px rgba(246,124,95,.2381),inset 0 0 0 1px rgba(255,255,255,.14286);font-size:45px}.tile.tile-256 .tile-inner{color:#f9f6f2;background:#2b5bad;box-shadow:0 0 30px 10px rgba(243,215,116,.31746),inset 0 0 0 1px rgba(255,255,255,.19048);font-size:45px}.tile.tile-512 .tile-inner{color:#f9f6f2;background:#edc850;box-shadow:0 0 30px 10px rgba(243,215,116,.39683),inset 0 0 0 1px rgba(255,255,255,.2381);font-size:45px}.tile.tile-1024 .tile-inner{color:#f9f6f2;background:#b79473;box-shadow:0 0 30px 10px rgba(183,148,115,.47619),inset 0 0 0 1px rgba(255,255,255,.28571);font-size:35px}.tile.tile-2048 .tile-inner{color:#f9f6f2;background:#976f43;box-shadow:0 0 30px 10px rgba(151,111,67,.55556),inset 0 0 0 1px rgba(255,255,255,.33333);font-size:35px}.tile.tile-super .tile-inner{color:#f9f6f2;background:#3c3a32;font-size:30px}@-webkit-keyframes appear{0%{opacity:0;-webkit-transform:scale(0);-moz-transform:scale(0);-ms-transform:scale(0);transform:scale(0)}100%{opacity:1;-webkit-transform:scale(1);-moz-transform:scale(1);-ms-transform:scale(1);transform:scale(1)}}@-moz-keyframes appear{0%{opacity:0;-webkit-transform:scale(0);-moz-transform:scale(0);-ms-transform:scale(0);transform:scale(0)}100%{opacity:1;-webkit-transform:scale(1);-moz-transform:scale(1);-ms-transform:scale(1);transform:scale(1)}}@keyframes appear{0%{opacity:0;-webkit-transform:scale(0);-moz-transform:scale(0);-ms-transform:scale(0);transform:scale(0)}100%{opacity:1;-webkit-transform:scale(1);-moz-transform:scale(1);-ms-transform:scale(1);transform:scale(1)}}.tile-new .tile-inner{-webkit-animation:appear .2s ease .1s;-moz-animation:appear .2s ease .1s;animation:appear .2s ease .1s;-webkit-animation-fill-mode:backwards;-moz-animation-fill-mode:backwards;animation-fill-mode:backwards}@-webkit-keyframes pop{0%{-webkit-transform:scale(0);-moz-transform:scale(0);-ms-transform:scale(0);transform:scale(0)}50%{-webkit-transform:scale(1.2);-moz-transform:scale(1.2);-ms-transform:scale(1.2);transform:scale(1.2)}100%{-webkit-transform:scale(1);-moz-transform:scale(1);-ms-transform:scale(1);transform:scale(1)}}@-moz-keyframes pop{0%{-webkit-transform:scale(0);-moz-transform:scale(0);-ms-transform:scale(0);transform:scale(0)}50%{-webkit-transform:scale(1.2);-moz-transform:scale(1.2);-ms-transform:scale(1.2);transform:scale(1.2)}100%{-webkit-transform:scale(1);-moz-transform:scale(1);-ms-transform:scale(1);transform:scale(1)}}@keyframes pop{0%{-webkit-transform:scale(0);-moz-transform:scale(0);-ms-transform:scale(0);transform:scale(0)}50%{-webkit-transform:scale(1.2);-moz-transform:scale(1.2);-ms-transform:scale(1.2);transform:scale(1.2)}100%{-webkit-transform:scale(1);-moz-transform:scale(1);-ms-transform:scale(1);transform:scale(1)}}.tile-merged .tile-inner{z-index:20;-webkit-animation:pop .2s ease .1s;-moz-animation:pop .2s ease .1s;animation:pop .2s ease .1s;-webkit-animation-fill-mode:backwards;-moz-animation-fill-mode:backwards;animation-fill-mode:backwards}.game-intro{float:left;line-height:42px;margin-bottom:0}.game-explanation{font-style:italic;font-size:15px}.copyright{border-top: 1px solid #ccc;margin-top: 10px;padding-top: 10px;}.copyright,.copyright a{font-size:13px;font-weight:400;text-align:center}@media screen and (max-width:520px){body,html{font-size:15px}body{margin:20px 0;padding:0 20px}h1.title{font-size:55px}.container{width:360px;margin:0 auto}.best-container,.score-container{margin-top:0;padding:15px 10px;min-width:40px}.heading{margin-bottom:10px}.game-intro{line-height:1.65}.control-button{width:33%}.game-container{margin-top:17px;position:relative;padding:10px;cursor:default;-webkit-touch-callout:none;-ms-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-ms-touch-action:none;touch-action:none;background:#bbada0;border-radius:6px;width:360px;height:360px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.game-container .game-message{display:none;position:absolute;top:0;right:0;bottom:0;left:0;background:rgba(238,228,218,.5);z-index:100;text-align:center;-webkit-animation:fade-in .8s ease 1.2s;-moz-animation:fade-in .8s ease 1.2s;animation:fade-in .8s ease 1.2s;-webkit-animation-fill-mode:both;-moz-animation-fill-mode:both;animation-fill-mode:both}.game-container .game-message p{font-size:60px;font-weight:700;height:60px;line-height:60px;margin-top:222px}.game-container .game-message .lower{display:block;margin-top:59px}.game-container .game-message a{display:inline-block;background:#ea4335;border-radius:3px;padding:0 20px;text-decoration:none;color:#f9f6f2;height:40px;line-height:42px;margin-left:9px}.game-container .game-message a.keep-playing-button{display:none}.game-container .game-message.game-won{background:rgba(237,194,46,.5);color:#f9f6f2}.game-container .game-message.game-won a.keep-playing-button{display:inline-block}.game-container .game-message.game-over,.game-container .game-message.game-won{display:block}.grid-container{position:absolute;z-index:1}.grid-row{margin-bottom:10px}.grid-row:last-child{margin-bottom:0}.grid-row:after{content:"";display:block;clear:both}.grid-cell{width:77.5px;height:77.5px;margin-right:10px;float:left;border-radius:3px;background:rgba(238,228,218,.35)}.grid-cell:last-child{margin-right:0}.tile-container{position:absolute;z-index:2}.tile,.tile .tile-inner{width:78px;height:78px;line-height:78px}.tile.tile-position-1-1{-webkit-transform:translate(0,0);-moz-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0)}.tile.tile-position-1-2{-webkit-transform:translate(0,87px);-moz-transform:translate(0,87px);-ms-transform:translate(0,87px);transform:translate(0,87px)}.tile.tile-position-1-3{-webkit-transform:translate(0,175px);-moz-transform:translate(0,175px);-ms-transform:translate(0,175px);transform:translate(0,175px)}.tile.tile-position-1-4{-webkit-transform:translate(0,262px);-moz-transform:translate(0,262px);-ms-transform:translate(0,262px);transform:translate(0,262px)}.tile.tile-position-2-1{-webkit-transform:translate(87px,0);-moz-transform:translate(87px,0);-ms-transform:translate(87px,0);transform:translate(87px,0)}.tile.tile-position-2-2{-webkit-transform:translate(87px,87px);-moz-transform:translate(87px,87px);-ms-transform:translate(87px,87px);transform:translate(87px,87px)}.tile.tile-position-2-3{-webkit-transform:translate(87px,175px);-moz-transform:translate(87px,175px);-ms-transform:translate(87px,175px);transform:translate(87px,175px)}.tile.tile-position-2-4{-webkit-transform:translate(87px,262px);-moz-transform:translate(87px,262px);-ms-transform:translate(87px,262px);transform:translate(87px,262px)}.tile.tile-position-3-1{-webkit-transform:translate(175px,0);-moz-transform:translate(175px,0);-ms-transform:translate(175px,0);transform:translate(175px,0)}.tile.tile-position-3-2{-webkit-transform:translate(175px,87px);-moz-transform:translate(175px,87px);-ms-transform:translate(175px,87px);transform:translate(175px,87px)}.tile.tile-position-3-3{-webkit-transform:translate(175px,175px);-moz-transform:translate(175px,175px);-ms-transform:translate(175px,175px);transform:translate(175px,175px)}.tile.tile-position-3-4{-webkit-transform:translate(175px,262px);-moz-transform:translate(175px,262px);-ms-transform:translate(175px,262px);transform:translate(175px,262px)}.tile.tile-position-4-1{-webkit-transform:translate(262px,0);-moz-transform:translate(262px,0);-ms-transform:translate(262px,0);transform:translate(262px,0)}.tile.tile-position-4-2{-webkit-transform:translate(262px,87px);-moz-transform:translate(262px,87px);-ms-transform:translate(262px,87px);transform:translate(262px,87px)}.tile.tile-position-4-3{-webkit-transform:translate(262px,175px);-moz-transform:translate(262px,175px);-ms-transform:translate(262px,175px);transform:translate(262px,175px)}.tile.tile-position-4-4{-webkit-transform:translate(262px,262px);-moz-transform:translate(262px,262px);-ms-transform:translate(262px,262px);transform:translate(262px,262px)}.tile[class*=tile-] .tile-inner{font-size:25px}.game-message p{font-size:30px!important;height:30px!important;line-height:30px!important;margin-top:90px!important}.game-message .lower{margin-top:30px!important}}@media screen and (max-width:400px){body{padding:0}}@media screen and (max-width:360px){body{margin:20px 0;padding:0 20px}h1.title{font-size:27px;margin-top:15px}.game-intro{line-height:1;font-size:14px}.container{width:280px;margin:0 auto}.game-container{margin-top:17px;position:relative;padding:10px;cursor:default;-webkit-touch-callout:none;-ms-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-ms-touch-action:none;touch-action:none;background:#bbada0;border-radius:6px;width:280px;height:280px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.control-button{width:42%}.grid-cell{width:57.5px;height:57.5px;margin-right:10px;float:left;border-radius:3px;background:rgba(238,228,218,.35)}.tile,.tile .tile-inner{width:58px;height:58px;line-height:58px}.tile.tile-position-1-1{-webkit-transform:translate(0,0);-moz-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0)}.tile.tile-position-1-2{-webkit-transform:translate(0,67px);-moz-transform:translate(0,67px);-ms-transform:translate(0,67px);transform:translate(0,67px)}.tile.tile-position-1-3{-webkit-transform:translate(0,135px);-moz-transform:translate(0,135px);-ms-transform:translate(0,135px);transform:translate(0,135px)}.tile.tile-position-1-4{-webkit-transform:translate(0,202px);-moz-transform:translate(0,202px);-ms-transform:translate(0,202px);transform:translate(0,202px)}.tile.tile-position-2-1{-webkit-transform:translate(67px,0);-moz-transform:translate(67px,0);-ms-transform:translate(67px,0);transform:translate(67px,0)}.tile.tile-position-2-2{-webkit-transform:translate(67px,67px);-moz-transform:translate(67px,67px);-ms-transform:translate(67px,67px);transform:translate(67px,67px)}.tile.tile-position-2-3{-webkit-transform:translate(67px,135px);-moz-transform:translate(67px,135px);-ms-transform:translate(67px,135px);transform:translate(67px,135px)}.tile.tile-position-2-4{-webkit-transform:translate(67px,202px);-moz-transform:translate(67px,202px);-ms-transform:translate(67px,202px);transform:translate(67px,202px)}.tile.tile-position-3-1{-webkit-transform:translate(135px,0);-moz-transform:translate(135px,0);-ms-transform:translate(135px,0);transform:translate(135px,0)}.tile.tile-position-3-2{-webkit-transform:translate(135px,67px);-moz-transform:translate(135px,67px);-ms-transform:translate(135px,67px);transform:translate(135px,67px)}.tile.tile-position-3-3{-webkit-transform:translate(135px,135px);-moz-transform:translate(135px,135px);-ms-transform:translate(135px,135px);transform:translate(135px,135px)}.tile.tile-position-3-4{-webkit-transform:translate(135px,202px);-moz-transform:translate(135px,202px);-ms-transform:translate(135px,202px);transform:translate(135px,202px)}.tile.tile-position-4-1{-webkit-transform:translate(202px,0);-moz-transform:translate(202px,0);-ms-transform:translate(202px,0);transform:translate(202px,0)}.tile.tile-position-4-2{-webkit-transform:translate(202px,67px);-moz-transform:translate(202px,67px);-ms-transform:translate(202px,67px);transform:translate(202px,67px)}.tile.tile-position-4-3{-webkit-transform:translate(202px,135px);-moz-transform:translate(202px,135px);-ms-transform:translate(202px,135px);transform:translate(202px,135px)}.tile.tile-position-4-4{-webkit-transform:translate(202px,202px);-moz-transform:translate(202px,202px);-ms-transform:translate(202px,202px);transform:translate(202px,202px)}.tile[class*=tile-] .tile-inner{font-size:20px}}@media screen and (max-width:320px){body{padding:0}}.ad-wrapper{display: none;}@media screen and (min-width: 1156px) { #adRect{display: none}.ad-wrapper {box-sizing: border-box;display: block;width: calc(50% - 250px);min-height: 500px;position: fixed;top: 165px;right: 0;padding: 10px;}.thumbnails-1x1{margin: 0 auto;width:100%;max-width: 468px;}}</style>
<link href="https://fonts.googleapis.com/css2?family=Raleway:wght@400;600;700&display=swap" rel="stylesheet"><script type="text/javascript">
window._taboola = window._taboola || [];
_taboola.push({article:'auto'});
!function (e, f, u, i) {
if (!document.getElementById(i)){
e.async = 1;
e.src = u;
e.id = i;
f.parentNode.insertBefore(e, f);
}
}(document.createElement('script'),
document.getElementsByTagName('script')[0],
'//cdn.taboola.com/libtrc/iploc-network/loader.js',
'tb_loader_script');
if(window.performance && typeof window.performance.mark == 'function')
{window.performance.mark('tbl_ic');}
var currPage = window.location.pathname.split("/")[1];
</script>
</head>
<body>
<div class="container">
<div class="heading">
<h1 class="title"><a href="/2048/"><strong>2</strong><strong>0</strong><strong>4</strong><strong>8</strong></a></h1>
<div class="scores-container">
<div class="score-container">0</div>
<div class="best-container">0</div>
</div>
</div>
<div class="above-game">
<p class="game-intro">Join the numbers and get to the <strong>2048</strong> tile!</p>
</div>
<p style="display: none">2048 is a single-player sliding block puzzle game designed by Italian web developer Gabriele Cirulli. The objective of the game is to slide numbered tiles on a grid to combine them to create a tile with the number 2048; however, one can continue to play the game after reaching the goal, creating tiles with larger numbers. Play and enjoy!</p>
<div class="game-container">
<div class="game-message">
<p></p>
<div class="lower">
<a class="keep-playing-button">Keep going</a>
<a class="retry-button">Try again</a>
</div>
</div>
<div class="grid-container">
<div class="grid-row">
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
</div>
<div class="grid-row">
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
</div>
<div class="grid-row">
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
</div>
<div class="grid-row">
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
<div class="grid-cell"></div>
</div>
</div>
<div class="tile-container"></div>
</div>
<div class="control-buttons">
<script>var startBot=false;</script>
<a class="bot-button control-button" onclick="startBot=!startBot;gameControl(startBot);">Activate Bot?</a>
<a class="restart-button control-button">New Game</a>
</div>
<hr>
<p class="game-explanation">
<strong class="important">How to play:</strong> Use <strong>arrow keys</strong> or <strong>swipe</strong> to move the tiles. When two tiles with the same number touch, they <strong>merge into one!</strong>
</p>
<div id="adRect">
<div id="taboola-streamthumbnails" class="thumbnails-468"></div>
<script type="text/javascript">
window._taboola = window._taboola || [];
_taboola.push({
mode: 'thumbnails-1X1stream',
container: 'taboola-streamthumbnails',
placement: currPage+"-468",
target_type: 'mix'
});
</script>
</div>
<div class="text_nav">
</div>
<p class="copyright">
</p>
</div>
<div class="ad-wrapper">
<div id="taboola--1c-x-3r-thumbnails" class="thumbnails-1x1"></div>
<script type="text/javascript">
window._taboola = window._taboola || [];
_taboola.push({
mode: 'thumbnails-1X1',
container: 'taboola--1c-x-3r-thumbnails',
placement: currPage+"-1x1",
target_type: 'mix'
});
</script>
</div>
</div>
<script>function KeyboardInputManager(){this.events={},window.navigator.msPointerEnabled?(this.eventTouchstart="MSPointerDown",this.eventTouchmove="MSPointerMove",this.eventTouchend="MSPointerUp"):(this.eventTouchstart="touchstart",this.eventTouchmove="touchmove",this.eventTouchend="touchend"),this.listen()}function HTMLActuator(){this.tileContainer=document.querySelector(".tile-container"),this.scoreContainer=document.querySelector(".score-container"),this.bestContainer=document.querySelector(".best-container"),this.messageContainer=document.querySelector(".game-message"),this.score=0}function Grid(t,e){this.size=t,this.cells=e?this.fromState(e):this.empty()}function Tile(t,e){this.x=t.x,this.y=t.y,this.value=e||2,this.previousPosition=null,this.mergedFrom=null}function LocalStorageManager(){this.bestScoreKey="bestScore",this.gameStateKey="gameState";var t=this.localStorageSupported();this.storage=t?window.localStorage:window.fakeStorage}function GameManager(t,e,i,n){this.size=t,this.inputManager=new e,this.storageManager=new n,this.actuator=new i,this.startTiles=2,this.inputManager.on("move",this.move.bind(this)),this.inputManager.on("restart",this.restart.bind(this)),this.inputManager.on("keepPlaying",this.keepPlaying.bind(this)),this.setup()}Function.prototype.bind=Function.prototype.bind||function(t){var e=this;return function(i){i instanceof Array||(i=[i]),e.apply(t,i)}},function(){if(!(void 0===window.Element||"classList"in document.documentElement)){var t,e,i,n=Array.prototype,o=n.push,a=n.splice,r=n.join;s.prototype={add:function(t){this.contains(t)||(o.call(this,t),this.el.className=this.toString())},contains:function(t){return-1!=this.el.className.indexOf(t)},item:function(t){return this[t]||null},remove:function(t){if(this.contains(t)){for(var e=0;e<this.length&&this[e]!=t;e++);a.call(this,e,1),this.el.className=this.toString()}},toString:function(){return r.call(this," ")},toggle:function(t){return this.contains(t)?this.remove(t):this.add(t),this.contains(t)}},window.DOMTokenList=s,t=HTMLElement.prototype,e="classList",i=function(){return new s(this)},Object.defineProperty?Object.defineProperty(t,e,{get:i}):t.__defineGetter__(e,i)}function s(t){this.el=t;for(var e=t.className.replace(/^\s+|\s+$/g,"").split(/\s+/),i=0;i<e.length;i++)o.call(this,e[i])}}(),function(){for(var t=0,e=["webkit","moz"],i=0;i<e.length&&!window.requestAnimationFrame;++i)window.requestAnimationFrame=window[e[i]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[e[i]+"CancelAnimationFrame"]||window[e[i]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(e){var i=(new Date).getTime(),n=Math.max(0,16-(i-t)),o=window.setTimeout(function(){e(i+n)},n);return t=i+n,o}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(t){clearTimeout(t)})}(),KeyboardInputManager.prototype.on=function(t,e){this.events[t]||(this.events[t]=[]),this.events[t].push(e)},KeyboardInputManager.prototype.emit=function(t,e){var i=this.events[t];i&&i.forEach(function(t){t(e)})},KeyboardInputManager.prototype.listen=function(){var t,e,i=this,n={38:0,39:1,40:2,37:3,75:0,76:1,74:2,72:3,87:0,68:1,83:2,65:3};document.addEventListener("keydown",function(t){var e=t.altKey||t.ctrlKey||t.metaKey||t.shiftKey,o=n[t.which];e||void 0!==o&&(t.preventDefault(),i.emit("move",o)),e||82!==t.which||i.restart.call(i,t)}),this.bindButtonPress(".retry-button",this.restart),this.bindButtonPress(".restart-button",this.restart),this.bindButtonPress(".keep-playing-button",this.keepPlaying);var o=document.getElementsByClassName("game-container")[0];o.addEventListener(this.eventTouchstart,function(i){!window.navigator.msPointerEnabled&&i.touches.length>1||i.targetTouches.length>1||(window.navigator.msPointerEnabled?(t=i.pageX,e=i.pageY):(t=i.touches[0].clientX,e=i.touches[0].clientY),i.preventDefault())}),o.addEventListener(this.eventTouchmove,function(t){t.preventDefault()}),o.addEventListener(this.eventTouchend,function(n){if(!(!window.navigator.msPointerEnabled&&n.touches.length>0||n.targetTouches.length>0)){var o,a;window.navigator.msPointerEnabled?(o=n.pageX,a=n.pageY):(o=n.changedTouches[0].clientX,a=n.changedTouches[0].clientY);var r=o-t,s=Math.abs(r),l=a-e,c=Math.abs(l);Math.max(s,c)>10&&i.emit("move",s>c?r>0?1:3:l>0?2:0)}})},KeyboardInputManager.prototype.restart=function(t){t.preventDefault(),this.emit("restart")},KeyboardInputManager.prototype.keepPlaying=function(t){t.preventDefault(),this.emit("keepPlaying")},KeyboardInputManager.prototype.bindButtonPress=function(t,e){var i=document.querySelector(t);i.addEventListener("click",e.bind(this)),i.addEventListener(this.eventTouchend,e.bind(this))},HTMLActuator.prototype.actuate=function(t,e){var i=this;window.requestAnimationFrame(function(){i.clearContainer(i.tileContainer),t.cells.forEach(function(t){t.forEach(function(t){t&&i.addTile(t)})}),i.updateScore(e.score),i.updateBestScore(e.bestScore),e.terminated&&(e.over?i.message(!1):e.won&&i.message(!0))})},HTMLActuator.prototype.continueGame=function(){this.clearMessage()},HTMLActuator.prototype.clearContainer=function(t){for(;t.firstChild;)t.removeChild(t.firstChild)},HTMLActuator.prototype.addTile=function(t){var e=this,i=document.createElement("div"),n=document.createElement("div"),o=t.previousPosition||{x:t.x,y:t.y},a=this.positionClass(o),r=["tile","tile-"+t.value,a];t.value>2048&&r.push("tile-super"),this.applyClasses(i,r),n.classList.add("tile-inner"),n.textContent=t.value,t.previousPosition?window.requestAnimationFrame(function(){r[2]=e.positionClass({x:t.x,y:t.y}),e.applyClasses(i,r)}):t.mergedFrom?(r.push("tile-merged"),this.applyClasses(i,r),t.mergedFrom.forEach(function(t){e.addTile(t)})):(r.push("tile-new"),this.applyClasses(i,r)),i.appendChild(n),this.tileContainer.appendChild(i)},HTMLActuator.prototype.applyClasses=function(t,e){t.setAttribute("class",e.join(" "))},HTMLActuator.prototype.normalizePosition=function(t){return{x:t.x+1,y:t.y+1}},HTMLActuator.prototype.positionClass=function(t){return"tile-position-"+(t=this.normalizePosition(t)).x+"-"+t.y},HTMLActuator.prototype.updateScore=function(t){this.clearContainer(this.scoreContainer);var e=t-this.score;if(this.score=t,this.scoreContainer.textContent=this.score,e>0){var i=document.createElement("div");i.classList.add("score-addition"),i.textContent="+"+e,this.scoreContainer.appendChild(i)}},HTMLActuator.prototype.updateBestScore=function(t){this.bestContainer.textContent=t},HTMLActuator.prototype.message=function(t){var e=t?"game-won":"game-over",i=t?"You win!":"Game over!";this.messageContainer.classList.add(e),this.messageContainer.getElementsByTagName("p")[0].textContent=i},HTMLActuator.prototype.clearMessage=function(){this.messageContainer.classList.remove("game-won"),this.messageContainer.classList.remove("game-over")},Grid.prototype.empty=function(){for(var t=[],e=0;e<this.size;e++)for(var i=t[e]=[],n=0;n<this.size;n++)i.push(null);return t},Grid.prototype.fromState=function(t){for(var e=[],i=0;i<this.size;i++)for(var n=e[i]=[],o=0;o<this.size;o++){var a=t[i][o];n.push(a?new Tile(a.position,a.value):null)}return e},Grid.prototype.randomAvailableCell=function(){var t=this.availableCells();if(t.length)return t[Math.floor(Math.random()*t.length)]},Grid.prototype.availableCells=function(){var t=[];return this.eachCell(function(e,i,n){n||t.push({x:e,y:i})}),t},Grid.prototype.eachCell=function(t){for(var e=0;e<this.size;e++)for(var i=0;i<this.size;i++)t(e,i,this.cells[e][i])},Grid.prototype.cellsAvailable=function(){return!!this.availableCells().length},Grid.prototype.cellAvailable=function(t){return!this.cellOccupied(t)},Grid.prototype.cellOccupied=function(t){return!!this.cellContent(t)},Grid.prototype.cellContent=function(t){return this.withinBounds(t)?this.cells[t.x][t.y]:null},Grid.prototype.insertTile=function(t){this.cells[t.x][t.y]=t},Grid.prototype.removeTile=function(t){this.cells[t.x][t.y]=null},Grid.prototype.withinBounds=function(t){return t.x>=0&&t.x<this.size&&t.y>=0&&t.y<this.size},Grid.prototype.serialize=function(){for(var t=[],e=0;e<this.size;e++)for(var i=t[e]=[],n=0;n<this.size;n++)i.push(this.cells[e][n]?this.cells[e][n].serialize():null);return{size:this.size,cells:t}},Tile.prototype.savePosition=function(){this.previousPosition={x:this.x,y:this.y}},Tile.prototype.updatePosition=function(t){this.x=t.x,this.y=t.y},Tile.prototype.serialize=function(){return{position:{x:this.x,y:this.y},value:this.value}},window.fakeStorage={_data:{},setItem:function(t,e){return this._data[t]=String(e)},getItem:function(t){return this._data.hasOwnProperty(t)?this._data[t]:void 0},removeItem:function(t){return delete this._data[t]},clear:function(){return this._data={}}},LocalStorageManager.prototype.localStorageSupported=function(){try{var t=window.localStorage;return t.setItem("test","1"),t.removeItem("test"),!0}catch(t){return!1}},LocalStorageManager.prototype.getBestScore=function(){return this.storage.getItem(this.bestScoreKey)||0},LocalStorageManager.prototype.setBestScore=function(t){this.storage.setItem(this.bestScoreKey,t)},LocalStorageManager.prototype.getGameState=function(){var t=this.storage.getItem(this.gameStateKey);return t?JSON.parse(t):null},LocalStorageManager.prototype.setGameState=function(t){this.storage.setItem(this.gameStateKey,JSON.stringify(t))},LocalStorageManager.prototype.clearGameState=function(){this.storage.removeItem(this.gameStateKey)},GameManager.prototype.restart=function(){this.storageManager.clearGameState(),this.actuator.continueGame(),this.setup()},GameManager.prototype.keepPlaying=function(){this.keepPlaying=!0,this.actuator.continueGame()},GameManager.prototype.isGameTerminated=function(){return this.over||this.won&&!this.keepPlaying},GameManager.prototype.setup=function(){var t=this.storageManager.getGameState();t?(this.grid=new Grid(t.grid.size,t.grid.cells),this.score=t.score,this.over=t.over,this.won=t.won,this.keepPlaying=t.keepPlaying):(this.grid=new Grid(this.size),this.score=0,this.over=!1,this.won=!1,this.keepPlaying=!1,this.addStartTiles()),this.actuate()},GameManager.prototype.addStartTiles=function(){for(var t=0;t<this.startTiles;t++)this.addRandomTile()},GameManager.prototype.addRandomTile=function(){if(this.grid.cellsAvailable()){var t=Math.random()<.9?2:4,e=new Tile(this.grid.randomAvailableCell(),t);this.grid.insertTile(e)}},GameManager.prototype.actuate=function(){this.storageManager.getBestScore()<this.score&&this.storageManager.setBestScore(this.score),this.over?this.storageManager.clearGameState():this.storageManager.setGameState(this.serialize()),this.actuator.actuate(this.grid,{score:this.score,over:this.over,won:this.won,bestScore:this.storageManager.getBestScore(),terminated:this.isGameTerminated()})},GameManager.prototype.serialize=function(){return{grid:this.grid.serialize(),score:this.score,over:this.over,won:this.won,keepPlaying:this.keepPlaying}},GameManager.prototype.prepareTiles=function(){this.grid.eachCell(function(t,e,i){i&&(i.mergedFrom=null,i.savePosition())})},GameManager.prototype.moveTile=function(t,e){this.grid.cells[t.x][t.y]=null,this.grid.cells[e.x][e.y]=t,t.updatePosition(e)},GameManager.prototype.move=function(t){var e=this;if(!this.isGameTerminated()){var i,n,o=this.getVector(t),a=this.buildTraversals(o),r=!1;this.prepareTiles(),a.x.forEach(function(t){a.y.forEach(function(a){if(i={x:t,y:a},n=e.grid.cellContent(i)){var s=e.findFarthestPosition(i,o),l=e.grid.cellContent(s.next);if(l&&l.value===n.value&&!l.mergedFrom){var c=new Tile(s.next,2*n.value);c.mergedFrom=[n,l],e.grid.insertTile(c),e.grid.removeTile(n),n.updatePosition(s.next),e.score+=c.value,2048===c.value&&(e.won=!0)}else e.moveTile(n,s.farthest);e.positionsEqual(i,n)||(r=!0)}})}),r&&(this.addRandomTile(),this.movesAvailable()||(this.over=!0),this.actuate())}},GameManager.prototype.getVector=function(t){return{0:{x:0,y:-1},1:{x:1,y:0},2:{x:0,y:1},3:{x:-1,y:0}}[t]},GameManager.prototype.buildTraversals=function(t){for(var e={x:[],y:[]},i=0;i<this.size;i++)e.x.push(i),e.y.push(i);return 1===t.x&&(e.x=e.x.reverse()),1===t.y&&(e.y=e.y.reverse()),e},GameManager.prototype.findFarthestPosition=function(t,e){var i;do{t={x:(i=t).x+e.x,y:i.y+e.y}}while(this.grid.withinBounds(t)&&this.grid.cellAvailable(t));return{farthest:i,next:t}},GameManager.prototype.movesAvailable=function(){return this.grid.cellsAvailable()||this.tileMatchesAvailable()},GameManager.prototype.tileMatchesAvailable=function(){for(var t,e=0;e<this.size;e++)for(var i=0;i<this.size;i++)if(t=this.grid.cellContent({x:e,y:i}))for(var n=0;n<4;n++){var o=this.getVector(n),a={x:e+o.x,y:i+o.y},r=this.grid.cellContent(a);if(r&&r.value===t.value)return!0}return!1},GameManager.prototype.positionsEqual=function(t,e){return t.x===e.x&&t.y===e.y},window.requestAnimationFrame(function(){new GameManager(4,KeyboardInputManager,HTMLActuator,LocalStorageManager)});</script>
<script>for(var EVALUATE_ONLY=!1,AUTO_RETRY=!1,SEARCH_DEPTH=4,SEARCH_TIME=50,RETRY_TIME=1e3,ACCEPT_DEFEAT_VALUE=-999999,NUM_EMPTY_WEIGHT=5,ADJ_DIFF_WEIGHT=-.5,INSULATION_WEIGHT=-2,POSITION_WEIGHT=.04,POSITION_VALUE=[0,0,0,10,0,0,0,15,0,0,-5,20,10,15,20,50],LOG2={},i=0;i<20;i++)LOG2[1<<i]=i;var botOn,GRID_SIZE=4,PROB_2=.9,MOVE_UP={drow:-1,dcol:0,dir:0,keyCode:38,key:"Up"},MOVE_DOWN={drow:1,dcol:0,dir:1,keyCode:40,key:"Down"},MOVE_LEFT={drow:0,dcol:-1,dir:0,keyCode:37,key:"Left"},MOVE_RIGHT={drow:0,dcol:1,dir:1,keyCode:39,key:"Right"},botText=document.getElementsByClassName("bot-button")[0];function gameControl(e){e?(botOn=setInterval(nextMove,SEARCH_TIME),botText.innerHTML="Stop bot!"):(clearInterval(botOn),botText.innerHTML="Activate Bot?")}if(setInterval(function(){gameWon()&&keepPlaying()},RETRY_TIME),AUTO_RETRY){var games=0,bestScore=0,averageScore=0,bestLargestTile=0,averageLargestTile=0;setInterval(function(){if(gameLost()){var e=getScore();bestScore=Math.max(bestScore,e);for(var t=getGrid(),r=0,n=0;n<t.length;n++)r=Math.max(r,t[n]);bestLargestTile=Math.max(bestLargestTile,r),averageScore=(averageScore*games+e)/(games+1),averageLargestTile=(averageLargestTile*games+r)/(games+1),games++,console.log("Game "+games+"\nScore "+e+"\nLargest tile "+r+"\nAverage score "+Math.round(averageScore)+"\nAverage largest tile "+Math.round(averageLargestTile)+"\nBest score "+bestScore+"\nBest largest tile "+bestLargestTile+"\n\n"),search.table={},AUTO_RETRY&&tryAgain()}},RETRY_TIME)}function nextMove(){pressKey(search(getGrid(),SEARCH_DEPTH,Number.NEGATIVE_INFINITY,!0))}function search(e,t,r,n){if(t<=0)return evaluate(e);search.table||(search.table={});var a=getGridKey(e),o=search.table[a];if(o&&o.depth>=t&&(!o.isBound||o.value<=r))return n?o.move:o.value;var i=[MOVE_RIGHT,MOVE_DOWN,MOVE_LEFT,MOVE_UP];if(o){var l=i.indexOf(o.move),s=i[l];i[l]=i[0],i[0]=s}for(var c=void 0,g=!1,I=0;I<i.length;I++){var E=copy(e),f=i[I];if(make(E,f)){c=c||f;for(var v=Number.POSITIVE_INFINITY,u=E.length-1;u>=0&&v>r;u--)E[u]||(E[u]=2,v=Math.min(v,search(E,t-1,r)),E[u]=0);v>r&&(r=v,c=f,g=!0)}}return c?(search.table[a]={depth:t,value:r,move:c,isBound:!g},n?c:r):n?MOVE_LEFT:ACCEPT_DEFEAT_VALUE+evaluate(e)}function evaluate(e,t){for(var r=0,n=0,a=0,o=0,i=0,l=0;l<GRID_SIZE;l++)for(var s=0;s<GRID_SIZE;s++){var c=get(e,l,s);if(c){if(n+=c*POSITION_VALUE[l*GRID_SIZE+s],s<GRID_SIZE-1){var g=get(e,l,s+1);if(g)if(a+=levelDifference(c,g)*Math.log(c+g),s<GRID_SIZE-2)if((I=get(e,l,s+2))&&levelDifference(c,I)<=1.1)o+=levelDifference(E=Math.min(c,I),g)*Math.log(E)}var I,E;if(l<GRID_SIZE-1)if(g=get(e,l+1,s))if(a+=levelDifference(c,g)*Math.log(c+g),s<GRID_SIZE-2)if((I=get(e,l+2,s))&&levelDifference(c,I)<=1.1)o+=levelDifference(E=Math.min(c,I),g)*Math.log(E)}else i++}var f=11.12249+-11.06513413/(1+Math.pow(i/2.480941,2.717769));return r+=POSITION_WEIGHT*n,r+=NUM_EMPTY_WEIGHT*f,r+=ADJ_DIFF_WEIGHT*a,r+=INSULATION_WEIGHT*o,t&&console.log("EVALUATION "+r+"\n position "+POSITION_WEIGHT*n+"\n numEmpty "+NUM_EMPTY_WEIGHT*f+"\n adjDiff "+ADJ_DIFF_WEIGHT*a+"\n insulation "+INSULATION_WEIGHT*o+"\n"),r}function levelDifference(e,t){return e>t?LOG2[e]-LOG2[t]:LOG2[t]-LOG2[e]}function get(e,t,r){return e[t*GRID_SIZE+r]}function set(e,t,r,n){e[t*GRID_SIZE+r]=n}function print(e){function t(e,t){for(t-=e.length;t-- >0;)e=" "+e;return e}for(var r="",n=0;n<GRID_SIZE;n++){for(var a=0;a<GRID_SIZE;a++){var o=get(e,n,a);r+=o?t(o+"",5):" ."}r+="\n"}console.log(r)}function copy(e){return e.slice()}function inBounds(e,t){return 0<=e&&e<GRID_SIZE&&0<=t&&t<GRID_SIZE}function make(e,t){for(var r=t.dir*(GRID_SIZE-1),n=(1-t.dir)*(GRID_SIZE+1)-1,a=1-2*t.dir,o=!1,i=r;i!=n;i+=a)for(var l=r;l!=n;l+=a)if(get(e,i,l))for(var s=i+t.drow,c=l+t.dcol,g=i,I=l;inBounds(s,c);){var E=get(e,s,c),f=get(e,g,I);if(E){if(E===f){set(e,s,c,-2*f),set(e,g,I,0),o=!0;break}}else set(e,s,c,f),set(e,g,I,0),o=!0;g=s,I=c,s+=t.drow,c+=t.dcol}if(!o)return!1;for(var v=0,u=0;u<e.length;u++)e[u]<0?e[u]*=-1:e[u]||v++;if(0===v)throw"No empty squares after making move.";return!0}function getGridKey(e){if(!getGridKey.table1){getGridKey.table1={},getGridKey.table2={};for(var t=0;t<e.length;t++)for(var r=2;r<=8192;r*=2){var n=r*e.length+t;getGridKey.table1[n]=Math.round(4294967295*Math.random()),getGridKey.table2[n]=Math.round(4294967295*Math.random())}}var a=0,o=0;for(t=0;t<e.length;t++){var i=e[t];if(i){n=i*e.length+t;a^=getGridKey.table1[n],o^=getGridKey.table2[n]}}return a+""+o}function getGrid(){for(var e=document.getElementsByClassName("tile-container")[0],t=[],r=0;r<e.children.length;r++){var n=(I=e.children[r]).children[0],a=parseInt(n.innerHTML),o=I.className,i=o.indexOf("tile-position-")+"tile-position-".length,l=o.substring(i,i+3),s=parseInt(l[2])-1,c=parseInt(l[0])-1;t.push({value:a,row:s,col:c})}var g=new Array(GRID_SIZE*GRID_SIZE);for(r=0;r<g.length;r++)g[r]=0;for(r=0;r<t.length;r++){var I;set(g,(I=t[r]).row,I.col,I.value)}return g}function pressKey(e){var t=new Event("keydown",{bubbles:!0,cancelable:!0});t.altKey=!1,t.char="",t.charCode=0,t.ctrlKey=!1,t.defaultPrevented=!1,t.eventPhase=3,t.isTrusted=!0,t.key=e.key,t.keyCode=e.keyCode,t.locale="en-CA",t.location=0,t.metaKey=!1,t.repeat=!1,t.shiftKey=!1,t.which=e.keyCode,document.body.dispatchEvent(t)}function gameLost(){return document.getElementsByClassName("game-message")[0].className.indexOf("game-over")>=0}function gameWon(){return document.getElementsByClassName("game-message")[0].className.indexOf("game-won")>=0}function tryAgain(){document.getElementsByClassName("retry-button")[0].click()}function keepPlaying(){document.getElementsByClassName("keep-playing-button")[0].click()}function getScore(){var e=document.getElementsByClassName("score-container")[0];return parseInt(e.innerHTML)}function getBestScore(){var e=document.getElementsByClassName("best-container")[0];return parseInt(e.innerHTML)}</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>
<script async src="https://cdn.jsdelivr.net/npm/autotrack@2.4.1/autotrack.js"></script>
<script async defer src="../js/script.js"></script>
<script type="text/javascript">
window._taboola = window._taboola || [];
_taboola.push({flush: true});
</script>
</body>
</html>
Also see: Tab Triggers