Skip to content

nwrenger/hadar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hadar

This crate contains some simple battlesnake agents. The structure of this project is forked from this crate.

Usage

Running the Server

First, the rust toolchain has to be installed (https://www.rust-lang.org/learn/get-started).

Starting the server:

cargo run --release --bin server -- [-h] [--host <ip:port>] [--config <json>]

There are additional options for --runtime and visual representation of the snake (--head, --tail, --color). Run cargo run --release --bin server -- -h to see all the commandline options.

config defines the agent to be used (AStar, Random) and configures the agent's heuristic. The default config for the AStar agent is, for example:

{
  "AStar": null
}

If a config parameter (like f.e. health) is excluded the default value is used.

Simulating Configs

This tool can be used to simulate different configurations. These configurations specify the agent and its hyperparameters. If no parameters are provided, the default values for the agent are used. The number of simulated games can be specified with --game-count. Use -h for more information about other arguments to define the board size and game rules.

The example below simulates the AStar and Random agents for 10 games:

cargo run --release --bin simulate -- '{"AStar":{ }}' '{"Random":{ }}' --game-count 10

The last line of the standard output contains the number of wins of the first snake and the total number of games played:

Result: 3/10

Testing moves

The move program outputs the chosen move for a given game state and agent configuration. This can be useful for debugging situational bugs. The game input can be downloaded from the battlesnake with this Firefox extension.

cargo run --release --bin move -- [--config <json>] [--runtime] <json>

Running tests & benchmarks

There are multiple tests for the different modules that can be run, as shown below. For more information on unit testing in Rust, see https://doc.rust-lang.org/book/ch11-01-writing-tests.html.

cargo test -- [--nocapture] [testname]

Besides the functional tests, there are several performance benchmarks. They are executed with the release config with compiler and linker optimizations. The criterion benchmark runner tracks the execution times from previous runs and reports any improvements or degradations.

cargo bench -- [testname]

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages