Go (Weiqi/Baduk) rules engine library for MoonBit: captures, ko & positional superko, area scoring, SGF (FF[4]) parse/write/replay and an embeddable GTP engine / 围棋规则引擎:提子、劫与全局同形禁止、数子法计分、SGF 棋谱与 GTP 引擎
| Package | What it provides | Typical consumer |
|---|---|---|
| moonbaduk (root) | Board data structure, Game rules engine (Chinese rules) | any tool that must judge legality, captures, ko/superko or score |
| moonbaduk/sgf | SGF FF[4] parser/writer, game-tree model, replay against the rules engine | record databases, editors, converters, server-side validation |
| moonbaduk/gtp | Text-based GTP v2 engine over the rules engine (I/O free) | GUI frontends, bot harnesses, engine test suites |
wbgxiaosu/moonbaduklet g = @moonbaduk.Game::new(19, 7.5) // 19x19, Chinese rules, komi 7.5
let r = g.play_stone(@moonbaduk.Black, 3, 3) // Ok(captured) or Err(PlayError)
let legal = g.legal_points(@moonbaduk.White) // ko / superko / suicide excluded
let _ = g.play_pass(@moonbaduk.White)
let score = g.final_score() // "B+2.5" / "W+0.5" / "0" / "void"let tree = @sgf.parse_sgf_one("(;GM[1]FF[4]SZ[19]KM[7.5];B[pd];W[dp])")
let root_size = tree.root().get("SZ") // Some("19")
let rep = tree.replay() // replayed on a fresh Game
// rep.moves, rep.warnings, rep.game
let out = tree.to_sgf() // writer, roundtrip-safelet e = @gtp.GtpEngine::new("my-client", "1.0")
let resp = e.handle("play black Q16") // "= \n\n" or "? reason\n\n"
let resp2 = e.handle("genmove white") // "= D4\n\n" / "= pass\n\n"
// resp.quit tells the host whether to shut downpub struct Board {
size : Int
// private fields
}pub struct Game {
// private fields
}Install
Download zipGo (Weiqi/Baduk) rules engine library for MoonBit: captures, ko & positional superko, area scoring, SGF (FF[4]) parse/write/replay and an embeddable GTP engine / 围棋规则引擎:提子、劫与全局同形禁止、数子法计分、SGF 棋谱与 GTP 引擎