Skip to content

Commit 1218eec

Browse files
authored
README.md
1 parent ed728e2 commit 1218eec

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

AI-driven 2048(New game)/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
Package/Script Name: AI-Driven 2048
2+
3+
Short description: AI-Driven 2048 is a Python package that implements an AI player for the popular 2048 game using the Expectimax algorithm. The AI player tries to maximize the score by making informed decisions to achieve higher tile values and ultimately reaching the 2048 tile.
4+
5+
Functionalities/Scripts:
6+
7+
AI2048 class: Implements the AI player for the 2048 game using the Expectimax algorithm.
8+
get_best_move(): Returns the best move (left, right, up, or down) for the current board state based on the Expectimax algorithm.
9+
Setup Instructions:
10+
11+
Ensure you have Python installed on your system (Python 3.6 or higher).
12+
Install the required libraries using pip:
13+
bash
14+
Copy code
15+
pip install numpy
16+
Download the AI2048.py file from the repository or package.
17+
Explanation of Script:
18+
The AI2048 class represents the AI player for the 2048 game. It has methods to calculate the heuristic score, perform moves (left, right, up, down), generate children states, and use the Expectimax algorithm to choose the best move based on the current board state.
19+
20+
Usage:
21+
22+
Create a 4x4 board with the initial tile configuration. The value 0 represents an empty cell.
23+
python
24+
Copy code
25+
board = [
26+
[0, 2, 2, 4],
27+
[0, 2, 0, 4],
28+
[0, 4, 2, 0],
29+
[0, 0, 2, 2]
30+
]
31+
Initialize the AI2048 class with the board configuration.
32+
python
33+
Copy code
34+
from AI2048 import AI2048
35+
36+
ai = AI2048(board)
37+
To get the best move for the current board state, call the get_best_move() method.
38+
python
39+
Copy code
40+
best_move = ai.get_best_move()
41+
print("Best Move:", best_move)
42+
Perform the best move and update the board state accordingly.
43+
python
44+
Copy code
45+
ai.move(best_move)
46+
Output:
47+
The script will output the best move (left, right, up, or down) based on the current board state.
48+
49+
Author:
50+
Shikhar9425

0 commit comments

Comments
 (0)