ai-hex 0.1.0

A small Hex rules and Monte Carlo tree search engine
Documentation
use crate::Engine;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub struct HexSession {
    inner: Engine,
}

#[wasm_bindgen]
impl HexSession {
    #[wasm_bindgen(constructor)]
    pub fn new() -> Self {
        Self {
            inner: Engine::new(),
        }
    }

    pub fn command(&mut self, line: &str) -> String {
        self.inner.command(line).join("\n")
    }

    pub fn snapshot(&self) -> String {
        self.inner.snapshot_json()
    }
}

impl Default for HexSession {
    fn default() -> Self {
        Self::new()
    }
}