Skip to content

Java implementation of Battlesnake.com game state view

License

Notifications You must be signed in to change notification settings

und3f/battlesnake-viewer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

battlesnake-viewer

Java implementation of Battlesnake Game States viewer.

Overview

battlesnake-viewer is the command-line tool that renders Battlesnake Game State states.

Features

  • view game frame from battlesnake.com engine
  • view saved moveRequest
  • CLI

Supported games' data sources:

  • file in Battle Snake JSON move request format
  • battlesnake.com engine
  • locale cache

Supported output formats

  • ascii
    • uses utf8 squares to render game state
  • snek
    • based on Snek-Spec by Echosec. Plain text game representation that could be used for snake unit tests.

A snake always begins and ends with capital letter, with the middle segments represented by lower case letters . By default Snek-Spec assumes your snake is the snake starting with S (for snake) and ending in T (for tail).

Thus SttT represents a snake with a length of 4 that is moving to the left. Details https://github.com/mike-anderson/snek-spec.

Build

run mvn package to build jar file

Run

After build is done, run the viewer:

java -jar target/battlesnake-viewer-1.0-SNAPSHOT-jar-with-dependencies.jar

You may add function to your shell's init script (~/.bashrc, ~/.zshrc):

battlesnake-viewer () {
  java -jar ~/Downloads/battlesnake-viewer/target/battlesnake-viewer-1.0-SNAPSHOT-jar-with-dependencies.jar ${@}
}

Reload shell, and you should be able to run viewer with a simple command battlesnake-viewer.

Usage

Usage: battlesnake-viewer [--color] [-f=<codingName>] [-t=<turn>] <uri|file>
Display Battlesnake game state.
      <uri|file>      Uri of the Battlesnake engine game or JSON file.
                      The JSON file should be in move request format. Examples:
                        https://play.battlesnake.com/game/d3537a9c-8f1d-41f3-9596-0f4a38e00e29
                        battlesnake://d3537a9c-8f1d-41f3-9596-0f4a38e00e29 # Alias to previous
                        path/to/local-file.json
      --color         Enable colors. Default true
  -f, --format=<codingName>
                      Format for displaying the state. Possible values: ascii, snek. Default: ascii
  -t, --turn=<turn>   Display specific turn. Defaults to the last turn

Examples

ASCII rendering

standard game
  01234567890
0 ·········
9 ·······
8 ·······
7 ·······
6 ········
5 ···········
4 ···········
3 ········
2 ······
1 ·········
0 ···········

maze
  0123456789012345678
0 #·###############·#
9 #········#········#
8 #·##·###·#·###·##·#
7 #················#
6 #·##·#·#####·#·##·#
5 #····#···#···#····#
4 #··#·###·#·###·#··#
3 #··#·#·······#·#··#
2 ####·#·##·#·#·####
1 ·······#··#····
0 ####·#·##·#·#·####
9 #··#·#·······#·#··#
8 #··#·#·#####·##··#
7 #········#·······#
6 #·##·###·#·#####·#
5 #··#··········#··#
4 ##·#·#·#####·##·##
3 #····#···#···#···#
2 #·######·#·######·#
1 #·················#
0 #·###############·#


Snek spec rendering

  01234567890
0 -----------
9 --tt-------
8 --ST-------
7 ------vV---
6 ------vv---
5 -------U---
4 ---------0-
3 0----------
2 -----------
1 -----------
0 --0----0---

About

Java implementation of Battlesnake.com game state view

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages