2048.Today API Challenge

The Challenge

Can you write an algorithm to solve the 2048.Today challenge?

Detailed below is the local JS API that is exposed on the 2048.Today page, can you using this API plus any automation tools of your choosing write an alogrithm that can solve the daily 2048.Today puzzle?

Getting Started

A template git repo has been created here to kick start your development. It uses Javascript with Cypress automated testing tool to run and control an instance of Chrome to run an algorithm.

Fork 2048.Today Challenge Template

Feel free to use the above template or use any other technologies you prefer, the key is the algorithm should require no human intervention to solve the puzzle.

API Documentation

Syntax

                
window.TFET
                
            

Properties

currentBoard:
type BoardConfig = {
    position: { 
        row: number, 
        col: number 
    }, 
    value: number 
}

readonly Array <BoardConfig>

An array of all blocks that are currently on the board. Position refers to the location on the 6x6 grid the block is currently located, the two values are base 0.

Value is the current value of the tile with 0 representing a solid obstacle block.

moves:
readonly number

A number respresenting the number of moves or actions that have been taken in the current play game instance.

gameWon:
readonly boolean

A boolean representing if the current game is in the game win state.

gameLost:
readonly boolean

A boolean respresenting if the current game is in the game lost state.

Methods

swipeLeft
() => { currentState: BoardConfig, previousState: BoardConfig }
                    

A method that triggers the swipe left action on the game board.

Returns and object containing the new state of the game board and the previous game board state.

swipeRight
() => { currentState: BoardConfig, previousState: BoardConfig }
                    

A method that triggers the swipe right action on the game board.

Returns and object containing the new state of the game board and the previous game board state.

swipeUp
() => { currentState: BoardConfig, previousState: BoardConfig }
                    

A method that triggers the swipe up action on the game board.

Returns and object containing the new state of the game board and the previous game board state.

swipeDown
() => { currentState: BoardConfig, previousState: BoardConfig }
                    

A method that triggers the swipe down action on the game board.

Returns and object containing the new state of the game board and the previous game board state.

Events

onGameStart
window.addEventListener('onGameStart', ( ProgressEvent: { 
    detail: { 
        state: BoardConfig, 
        moves: number 
    } 
} ) => { // Do something... }

This event fires once the initial game start has loaded and the board is ready to be interacted with.

Returns a custom event that contains an property called detail with the progress event object as it's value containing, a board config for the current board state and the current number of moves in the game state.

onGameRestart
window.addEventListener('onGameRestart', ( ProgressEvent: { 
    detail: { 
        state: BoardConfig, 
        moves: number 
    } 
} ) => { // Do something... }

This event fires after the restart game button has been pressed and the new board state has loaded and the board is ready to be interacted with.

Returns a custom event that contains an property called detail with the progress event object as it's value containing, a board config for the current board state and the current number of moves in the game state.

onSwipeLeft
window.addEventListener('onSwipeLeft', ( SwipeEvent: { 
    detail: { 
        state: BoardConfig, 
        moves: number, 
        previousState: BoardConfig, 
        direction: string 
    } 
} ) => { // Do something... }

This event fires after the internal board state of the game has been updated after a swipe left action has been triggered either manually or programmatically.

Returns a custom event that contains an property called detail with the swipe event object as it's value containing, a board config for the current board state, the current number of moves in the game state, the previous board state and the direction of the swipe event.

onSwipeRight
window.addEventListener('onSwipeRight', ( SwipeEvent: { 
    detail: { 
        state: BoardConfig, 
        moves: number, 
        previousState: BoardConfig, 
        direction: string 
    } 
} ) => { // Do something... }

This event fires after the internal board state of the game has been updated after a swipe right action has been triggered either manually or programmatically.

Returns a custom event that contains an property called detail with the swipe event object as it's value containing, a board config for the current board state, the current number of moves in the game state, the previous board state and the direction of the swipe event.

onSwipeUp
window.addEventListener('onSwipeUp', ( SwipeEvent: { 
    detail: { 
        state: BoardConfig, 
        moves: number, 
        previousState: BoardConfig, 
        direction: string 
    } 
} ) => { // Do something... }

This event fires after the internal board state of the game has been updated after a swipe up action has been triggered either manually or programmatically.

Returns a custom event that contains an property called detail with the swipe event object as it's value containing, a board config for the current board state, the current number of moves in the game state, the previous board state and the direction of the swipe event.

onSwipeDown
window.addEventListener('onSwipeDown', ( SwipeEvent: { 
    detail: { 
        state: BoardConfig, 
        moves: number, 
        previousState: BoardConfig, 
        direction: string 
    } 
} ) => { // Do something... }

This event fires after the internal board state of the game has been updated after a swipe down action has been triggered either manually or programmatically.

Returns a custom event that contains an property called detail with the swipe event object as it's value containing, a board config for the current board state, the current number of moves in the game state, the previous board state and the direction of the swipe event.