Build a bot to play 2048
About 2048
Bot Requirements
- The bot should be a HTTP server listening on port
5000 (dockerized)
- It will receive a
GET request with the current game state as a state query parameter
- The query parameter will be a string of 16 numbers separated by commas
- These 16 numbers represent block values in col-major format (0 means an empty block)
- The bot should respond with a single character (
0, 1, 2, or 3) representing the following actions:
0 → UP
1 → RIGHT
2 → DOWN
3 → LEFT
- The bot should not return anything else besides the single character response
- Enable CORS and listen on all IPs (
0.0.0.0)
- Samples:
- Sample Request 01: http://localhost:5000/?state=0,0,0,0,0,0,0,0,0,0,2,0,0,2,0,0
- Sample Request 02: http://localhost:5000/?state=0,0,4,0,0,2,8,4,2,8,4,4,8,16,32,128
- Sample Gameplay
- Sample Server Code
- Sample Dockerfile
Grader Information
- Runner:
docker run -p 5000:5000 $(docker build -q .)
- Try Online: https://hack.levels.fyi/bot
- Ensure your server is running on port 5000
- Failed requests are retried after every 5000 ms
- Use the slider to increase / decrease request speed