battlesnake_game_types/
lib.rs

1#![deny(
2    warnings,
3    missing_copy_implementations,
4    missing_debug_implementations,
5    missing_docs
6)]
7//! Types for working with [battlesnake](https://docs.battlesnake.com/).
8//! The goal is to provide simulation tooling and fast representations that
9//! enable development of efficient minmax/MCTS.
10//! you will likely be most interested in the CellBoard type which implements
11//! all the traits necessary for minmax/MCTS and is much faster than using the
12//! wire representation, in our benchmarks, we see that our compact representation
13//! is on the order of about 33% faster for simulation than the wire representation.
14//! ```plain
15//!Gnuplot not found, using plotters backend
16//! compact start of game   time:   [2.7520 us 2.7643 us 2.7774 us]
17//!                         change: [-9.0752% -8.5713% -8.0468%] (p = 0.00 < 0.05)
18//!                         Performance has improved.
19//!
20//! vec game start of game  time:   [4.1108 us 4.1303 us 4.1498 us]
21//!                         change: [-12.869% -9.2803% -5.8488%] (p = 0.00 < 0.05)
22//!                         Performance has improved.
23//! Found 1 outliers among 100 measurements (1.00%)
24//!   1 (1.00%) high mild
25//!
26//! compact late stage      time:   [14.098 us 14.152 us 14.209 us]
27//!
28//! vec late stage          time:   [21.124 us 21.337 us 21.592 us]
29//! Found 14 outliers among 100 measurements (14.00%)
30//! ```
31
32use wire_representation::Game;
33
34pub mod compact_representation;
35pub mod hazard_algorithms;
36pub mod types;
37pub mod wire_representation;
38
39/// Loads a fixture from a given string
40pub fn game_fixture(game_fixture: &str) -> Game {
41    let g: Result<Game, _> = serde_json::from_str(game_fixture);
42    g.expect("the json literal is valid")
43}