# Introduction

In this article, we develop a simple AI for the game 2048 using the Expectimax algorithm and “weight matrices”, which will be described below, to determine the best possible move at each turn.

The implementation of the AI described in this article can be found here. The source files for the implementation can be found here.

# Recursivity of score function

We define some symbols and functions in order to construct a function to compute the score of any one game state (i.e. grid).

- Game state: A $latex 4 times 4$ square matrix $latex mathbf{A}$ where $latex mathbf{A}_{ij}$ is equal to the value of the cell in the game grid at row $latex i$ and column $latex j$.
- $latex text{score}(mathbf{A})$ : The numerical score of the game state $latex mathbf{A}$.
- $latex D_mathbf{A}$ : The set of possible move directions (up, down, left, right) for $latex mathbf{A}$.
- $latex…

View original post 825 more words