48 releases (12 breaking)

7.0.0 Dec 9, 2019
0.15.2 Nov 20, 2020
0.15.1 Sep 8, 2020
0.12.2 Jul 19, 2020
0.1.9 Dec 24, 2018

#76 in Parser implementations

Download history 86/week @ 2020-08-08 86/week @ 2020-08-15 9/week @ 2020-08-22 132/week @ 2020-08-29 157/week @ 2020-09-05 6/week @ 2020-09-12 8/week @ 2020-09-19 9/week @ 2020-09-26 99/week @ 2020-10-03 4/week @ 2020-10-10 69/week @ 2020-10-17 8/week @ 2020-10-24 3/week @ 2020-10-31 21/week @ 2020-11-07 39/week @ 2020-11-14 59/week @ 2020-11-21

186 downloads per month

MIT license

82KB
2.5K SLoC

Goban

Library to play with a rusty "Goban" (name of the board where we play Go ! )

Use the version > 0.5.0 because in a bug detecting dead stones and in Ko detection Before 0.15.1 bug in the importation of SGF, player color was inverted

Channel : stable

Only contains move generation, and rules there is no IA, neither front-end.

Features:

  • thread-safe // for using Arc instead of Rc for thread safety. Decrease perfs !
  • history // each game will have his all history so you can iterate over it. Decrease perfs !

Thanks to some help in profiling and optimisation we can run a playout randomly of an entire game in 3 ms (i7u 3.0 Ghz) (before it was 600ms ) !

Example :

use crate::goban::rules::*;
use crate::goban::rules::game::*;
use rand::seq::IteratorRandom;

let mut g = Game::new(GobanSizes::Nine, Rule::Chinese);
let mut i = 35;
while !g.over() && i != 0 {
   g.play(
        // legals return an iterator on (x,y) points
       g.legals()
           .choose(&mut rand::thread_rng())
           .map(|point| Move::Play(point.0,point.1))
           .unwrap());
   i -= 1;
   println!("{}", g);
}
┏┯┯┯┯┯┯┯┓
┠┼┼┼┼┼┼┼┨
┠┼┼┼┼┼┼┼┨
┠┼┼┼┼┼┼┼┨
┠┼┼┼┼┼┼┼┨
┠┼┼┼┼┼┼┼┨
┠┼┼┼┼┼┼┼┨
○┼┼┼┼┼┼┼┨
┗┷┷┷┷┷┷┷┛


etc...

What works

  • Capturing stones
  • Playing
  • Passing
  • Resigning
  • Implementation to count points
  • Printing a pretty unicode Board on the terminal !
  • SGF Import
  • Generate legals moves (Handling Ko detection, Suicide moves, Super ko)
  • Japanese Rules
  • Chinese Rules
  • Boards of different sizes (4x5 , 4x9) Limited to (19x19) (Due to Zobrist hashing) cas be easy increased in a fork.
  • Experimental dead stones detection with MCTS rollouts.

Waiting for

  • Const generics or maybe not (benchmark with a Goban with backed array is slightly faster)
  • Into-Iter for arrays for removing arrayvec dep

Dependencies

~1.7–2.4MB
~53K SLoC