1601517600

# How to apply Minimax to 2048

Minimax is an algorithm designated for playing adversarial games, that is games that involve an adversary. In this article, we’ll see how we can apply the minimax algorithm to solve the 2048 game. This is the first article from a 3-part sequence. This one will consist of planning our game-playing program at a conceptual level, and in the next 2 articles, we’ll see the actual Python implementation.

Here I assume you already know how the minimax algorithm works in general and only focus on how to apply it to the 2048 game. So, if you don’t already know about the minimax algorithm, take a look at:

The main 4 things that we need to think of when applying minimax to 2048, and really not only to 2048 but to any other game, are as follows:

1. How we can think of 2048 as a 2-player game? Who is Max? Who is Min?

2. How do we decide when a game state is terminal?

3. How do we evaluate the score/utility of a game state?

4. How do we determine the children of a game state?

#algorithms #programming #algorithmic-thinking #artificial-intelligence #game-theory

1601517600

## How to apply Minimax to 2048

Minimax is an algorithm designated for playing adversarial games, that is games that involve an adversary. In this article, we’ll see how we can apply the minimax algorithm to solve the 2048 game. This is the first article from a 3-part sequence. This one will consist of planning our game-playing program at a conceptual level, and in the next 2 articles, we’ll see the actual Python implementation.

Here I assume you already know how the minimax algorithm works in general and only focus on how to apply it to the 2048 game. So, if you don’t already know about the minimax algorithm, take a look at:

The main 4 things that we need to think of when applying minimax to 2048, and really not only to 2048 but to any other game, are as follows:

1. How we can think of 2048 as a 2-player game? Who is Max? Who is Min?

2. How do we decide when a game state is terminal?

3. How do we evaluate the score/utility of a game state?

4. How do we determine the children of a game state?

#algorithms #programming #algorithmic-thinking #artificial-intelligence #game-theory

1602702000

## How to control the game board of 2048

In this article, we will finish implementing the minimax algorithm for playing the 2048 game, and then we will use this implementation to automatically play a web version of this game which can be found on this Github page.

Here is the previous article about this subject, in which I showed how to represent the game state of 2048.

For that, we will first create the `GameDriver` class which will act as a middleman between our minimax implementation and the game found on this webpage. The `GameDriver` class is responsible for interacting with the game. We’ll need 2 operations to be handled: getting data about the current state of the game, and making one of the moves: up, down, left, right. These 2 operations are implemented in the following methods:

• `.getGrid()` — this will get the game state data and return it as a `Grid` object.
• `.move()` — this will take as parameter a move direction code and emulate a keypress of the appropriate arrow key.

The move direction codes that we chose in our implementation are:

• 0 = Up
• 1 = Down
• 2 = Left
• 3 = Right

#playing-2048-with-minimax #algorithms #artificial-intelligence #python #programming

1624966800

## The Benefits of Applying Analytics to Hidden Data Sources

Data usage to drive business insight has exploded. These days, every successful company is data-driven. The challenge that companies face these days is collecting more data than they bargained. As IoT and mobile devices continue to proliferate across industries, companies are increasingly sitting on data pools that remain untapped.

Bringing analytics to these hidden data pools will help organizations leap ahead of their competition. Here are 3 digital gold mines that are ripe for tapping.

### Untapped Gold Mines

#big data #latest news #benefits #applying analytics #hidden data sources #the benefits of applying analytics to hidden data sources

1623907200

## Python and OpenCV: Apply Filters to Images

I am pretty sure you have tried out various filters available on the social platforms and your camera as well.

Today in this tutorial, we will be applying few of the filters to images. Exciting right?

Let’s begin!

### 1. Importing Modules

#python programming examples #python and opencv: apply filters to images #apply filters to images #python and opencv #opencv #filters to images

1623233520

## Efficient Pandas: Apply vs Vectorized Operations

### Time and efficiency matters

Pandas is one of the most commonly used data analysis and manipulation libraries in data science ecosystem. It offers plenty of functions and methods to perform efficient operations.

What I like most about Pandas is that there are almost always multiple ways to accomplish a given task. However, we should consider time and computational complexity when selection a method from available options.

It is not enough just to complete a given task. We should make it as efficient as possible. Thus, having a comprehensive understanding of how functions and methods work is of crucial importance.

In this article, we will do examples to compare the apply and applymap functions of pandas to vectorized operations. The apply and applymap functions come in hand for many tasks. However, as the size of data increases, time becomes an issue.

#programming #data-science #machine-learning #artificial-intelligence #efficient pandas: apply vs vectorized operations #apply vs vectorized operations