Skip to content

Commit 2ac8e56

Browse files
readme update
and a small docstring fix
1 parent e45ec8e commit 2ac8e56

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

README.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,40 @@
11
# Tetris-AI
22

3-
Building a tetris player to win money in an online tetris game
3+
We built a bot to play online tetris _better than we ever could_, and this bot won a few dollars.
44

5-
The bot won a few dollars
5+
The bot works with screen information and emulates key presses,
6+
thus, it can be adapted to _any_ tetris game.
67

7-
Gameplay demonstration:
8+
After reading the screen, it uses an algorithm to determine the best piece placement and executes it.
9+
10+
The algorithm has various modes, for example, focusing on getting a _tetris_,
11+
which is clearing 4 lines with a single piece.
12+
13+
### Gameplay demonstration
814

915
![demo gif](https://media.giphy.com/media/kg1Ng8ZXTUQ2efOpUk/giphy.gif)
16+
17+
## Usage guide
18+
19+
### How to run
20+
1. Take a screenshot of your Tetris game
21+
2. Go to `config.py` and define a `DisplayConsts` instance
22+
3. Set 'display consts' in `CONFIG` to your instance
23+
4. If necessary, define a `colors` array with piece colors for recognition of the next piece
24+
5. Set other config parameters
25+
6. Run `src/main.py`
26+
7. Switch to the Tetris window
27+
28+
### Runtime tuning
29+
You can control how the bot plays while the game is going.
30+
31+
This is only checked when a new piece appears, so you need to hold the key.
32+
33+
Piece dropping speed
34+
1 - the fastest speed, always hard drop
35+
2 - no hard drop
36+
3 - let the piece land on its own, the bot is always scared
37+
Number of computing paths for the next piece:
38+
z, x, c - 1, 3, 5
39+
n - try to clean the field
40+
m - disable cleaning mode (focus on getting tetrises)

src/AI_main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,10 @@ def runtime_tuning(self):
318318
3 - for the late game, always scared
319319
control number of paths for the next piece:
320320
z, x, c - 1, 3, 5
321+
n - try to clean the field
322+
m - disable cleaning mode (try to get tetrises)
321323
322-
This is only checked when a new piece appears so you need to hold the key
324+
This is only checked when a new piece appears, so you need to hold the key
323325
:return:
324326
"""
325327
if keyboard.is_pressed('1'):

0 commit comments

Comments
 (0)