|
1 | 1 | # Tetris-AI |
2 | 2 |
|
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. |
4 | 4 |
|
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. |
6 | 7 |
|
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 |
8 | 14 |
|
9 | 15 |  |
| 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) |
0 commit comments