snakebot

package module
v1.0.0-rc.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2023 License: MIT Imports: 1 Imported by: 0

README

Snake-Bot

Demo

Install
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 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}"
Make API calls
# 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
How it works

wiki: Dijkstra's algorithm

License

See LICENSE.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OpenAPISpec string

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd
internal
app
bot
connect/connectfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
core/corefakes
Code generated by counterfeiter.
Code generated by counterfeiter.
http/handlers/handlersfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
utils/utilsfakes
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL