Skip to content

danuiachimovschi/snake_validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Snake Validator

Stateless HTTP API that validates Snake game moves.

Run

make run
# custom port/secret
./bin/snake-validator --port 8080 --secret my-secret

Endpoints

GET /new?w=10&h=10 — Start a new game. Returns initial state with a random fruit.

POST /validate — Validate a tick sequence. Returns updated state on success.

{
  "gameId": "...", "width": 10, "height": 10, "score": 0,
  "fruit": { "x": 3, "y": 4 },
  "snake": { "x": 0, "y": 0, "velX": 1, "velY": 0 },
  "ticks": [{ "velX": 1, "velY": 0 }]
}
Status Meaning
200 Valid — returns new state
400 Invalid request or tampered state
404 Ticks did not reach the fruit
405 Wrong HTTP method
418 Invalid move or out of bounds
500 Internal error

Test & Lint

make test
make lint

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors