EDIT : Recently, my question has been proposed as a duplicate of 2048 Bot Challenge. I would like to stress that this question is different from that question, and will require answers to be thought of differently than that question. 2048 Bot Challenge asked the user to create a bot, and it would be run for an hour, with the highest score being the user's score. Additionally, it had a limit of 555 bytes. My challenge runs the code much less frequently, only 3 times. Your score is calculated by using the average score of those three times and dividing by the character length of your golfed code. My question encourages entries to be "smarter," and not try and get the highest score by brute force.
EDIT: The get method was changed to getTile, to avoid confliction with the JS keyword get. Additionally, a high score section was added.
An Ace Editor is located above the board. You place code in it, which is run once every 250 ms, or 4 times per second. This is called a cycle.
Use the following methods to control the board. You can't use the arrow keys.
up(); //move up down(); //move down left(); //move left right(); //move right move(integer); //integer is a direction. 0:up,1:right,2:down,3:left getTile(y,x); //gets the value of the tile in position y,x on the board. See diagram
The following variables are defined for your convenience:
eother //boolean, alternates every cycle frozen //integer, counts how many cycles the board has remained stationary lastDir //integer, indicates the last direction that was tried to move in //uses same format as the move method above. startup //boolean, will always be true when the game first starts //you can change it as you wish a b //a b and c are all persistant variables, they do not change each cycle c //any other variables defined in the cycle will be reset every time
- No Randomness, you must use logic. (Yes, I know the example code uses random.)
- No hooking into the game functions or cheating in other ways
- Generally, try to only call one move method per cycle. It is OK if you use more, but it screws with the animation
- The board must start in a random state, no modification of pre-game state
- You must provide both the uncompressed and golfed version of the code in your post.
- You must provide a link to the site that already loads the uncompressed version of your code, served via PasteBin (For example, ...thatcoolidea.com/2048?i=pH18GWtu loads the example code.)
- Your code will be scored by me.
- Part A of your score is an average of 3 runs of the code, rounded down.
- Part B of your score is the character length of your golfed code.
- Your final score is Part A divided by Part B
The winner will have their code immortalized as the example code on the site, if they choose, and acknowledged in a comment in the code.
Good luck! Hope you enjoy the challenge.
Current High Score 225.22 - Freezer - user3217109