An unofficial Battlesnake template written in Swift. Get started at play.battlesnake.com. This is a port of the official JavaScript starter Battlesnake Javascript Starter.
This project is a great starting point for anyone wanting to program their first Battlesnake in Swift. It can be run locally or easily deployed to a cloud provider of your choosing. See the Battlesnake API Docs for more detail.
This project uses Vapor. It also comes with an optional Dockerfile to help with deployment.
# swift test
# swift run
You should see the following output once it is running:
[ NOTICE ] Server starting on http://0.0.0.0:8000Open localhost:8000 in your browser and you should see
{
"apiversion": "1",
"version": "0.0.1-beta",
"head": "default",
"author": "SwiftUser",
"color": "#888888",
"tail": "default"
}Install the Battlesnake CLI
- You can download compiled binaries here
- or install as a go package (requires Go 1.18 or higher)
Command to run a local game
battlesnake play -W 11 -H 11 --name 'Swift Starter Project' --url http://localhost:8000 -g solo --browser- Hostname and port number are set in
configure.swift. - Configure your colors and name in the
static vardefault: BattlesnakeInfoinBattlesnake.swift.
Continue with the Battlesnake Quickstart Guide to customize and improve your Battlesnake's behavior. You can find pointers to do so in MovementTests.swift (i.e. adopt TDD to get a smarter snake.). Implement the behaviour itself in Movement.swift
Note: To play games on play.battlesnake.com you'll need to deploy your Battlesnake to a live web server OR use a port forwarding tool like ngrok to access your server locally.
startandstopdon't decode theBattlesnakeGameStateyet.
- This project is licensed under the terms of the Apache 2.0 license.
- This project is based on the official Battlesnake Javascript Starter (c) 2022 Battlesnake Inc.