https://github.com/ivan1993spb/snake-bot
A snake bot for no reason at all
https://github.com/ivan1993spb/snake-bot
bot snake websocket
Last synced: 9 months ago
JSON representation
A snake bot for no reason at all
- Host: GitHub
- URL: https://github.com/ivan1993spb/snake-bot
- Owner: ivan1993spb
- License: mit
- Created: 2021-06-20T03:40:43.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-04-19T08:36:27.000Z (about 2 years ago)
- Last Synced: 2025-06-22T05:06:24.062Z (about 1 year ago)
- Topics: bot, snake, websocket
- Language: Go
- Homepage: https://snakeonline.xyz
- Size: 245 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Snake-Bot
### Install Snake-Bot
```
go install github.com/ivan1993spb/snake-bot@latest
```
### Start Snake-Server
```
docker run --rm -d -p 8080:8080 ivan1993spb/snake-server:latest --enable-web
# Create a game
curl -X POST -d limit=15 -d width=100 -d height=60 -d enable_walls=true localhost:8080/api/games
```
### Start Snake-Bot
```
# Generate a secret for JWT
openssl rand -base64 -out secret.base64 32
snake-bot -snake-server localhost:8080 -jwt-secret secret.base64 -address :9090
```
### Generate JWT
```
python3 scripts/getjwt.py --subject admin --jwt-secret secret.base64 > token.jwt
token=`cat token.jwt`
header="Authorization: Bearer ${token}"
```
### Call the API
```
# Get config
curl -X GET -H "$header" localhost:9090/api/bots
# Add 1 bot in game 1
curl -X POST -H "$header" -d game=1 -d bots=1 localhost:9090/api/bots
cd examples
curl -X POST -H "$header" --data-binary @bots.yaml -H 'Content-Type: text/yaml' localhost:9090/api/bots
curl -X POST -H "$header" --data-binary @bots.json -H 'Content-Type: application/json' localhost:9090/api/bots
```
### Watch the result
[](http://localhost:8080)
### How it works
[wiki: Dijkstra's algorithm](https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm)
### License
See [LICENSE](LICENSE).