2048-bot 😎
A bot that can bash out possible games with a very simple calculation module, which recursively determines which move would result in the most null strings. While bashing out each possible game, it keeps a log of all the moves it has done. The user can decide if they want to keep logs for lost games. If it fails, it outputs the last 2048 field it got to, resets the field, and effectively starts over. Once it succeeds it outputs "THE END" in the console.
The Code:
Automatized User Commands (options.py
): 💬
Essentially has 4 possible commands.
moveleft
: shifts all of the tiles leftmoveright
: shifts all of the tiles rightmoveup
: shifts all of the tiles upmovedown
: shifts all of the tiles down
Autonomous Commands(addint.py
): 🤖
Adds a 2 or 4 (50% chance of each) to a random empty spot in the 2048 field
Calculation (calculate.py
): 🧮
Uses a function called compareoptions
This recursively checks which
logs (logs.txt
): 📜
Where the logs are stored
Main (main.py
): 👾
The code which is executed when you run the code. This is where the looping happens and logs are written. This also allows the user to decide what level of depth they would like the bot to calculate, and if they want logs for failed games
Beating the game 🥇:
Making a 2048 "tile" or element in the field
What's Changed
- Depth 2 calculation by @ArnoUUU in #1
- Added comments to every file by @ArnoUUU in #2
- Revert "Added comments to every file" by @ArnoUUU in #3
- user-input by @ArnoUUU in #4
- feat: implemented user-input by @ArnoUUU in #5
- Cooler logs by @ArnoUUU in #6
- feat: added game number iterator for logs by @ArnoUUU in #7
- Bugfixes by @ArnoUUU in #8
New Contributors
Full Changelog: v0.0.1-alpha...v1.0.0
Future Changelog:
- In the future, the calculation module will be improved, the depth will be either removed (based on new calculation module), or tuned for high win-rates (at least 95%). The user will no longer be able to control this value.
- Logs will become easier to read and interact with.
- A GUI may be added