A simple, easy-to-use parser for GIB in Kotlin.
GIB is the file format the Tygem Go Server produces instead of a plain SGF.
For build.gradle.kts
:
repositories {
maven {
url = uri("https://jitpack.io")
}
}
dependencies {
implementation("com.github.Ekenstein:gibson:0.1.4")
}
For examples, see the test resources
import com.github.ekenstein.gibson.Gib
import com.github.ekenstein.gibson.Move
import com.github.ekenstein.gibson.parser.from
import java.nio.file.Path
fun main() {
val file = Path.of("some_messy_name.gib..gib")
// parse the file
val gib = Gib.from(file)
// get some information about the file such as the game place
val place: String? = gib.gamePlace
// ... or komi
val komi: Double? = gib.komi
// ... or the handicap used for the game
val handicap: Int = gib.handicap
// ... or the name of the players
val playerBlack: String? = gib.playerBlack
val playerWhite: String? = gib.playerWhite
// ... or the game result.
val gameResult: GameResult? = gib.gameResult
// ... or maybe traverse the game tree
gib.moves.map {
when (it) {
is Move.Pass -> { /* handle a pass */ }
is Move.Point -> { /* handle a stone */}
}
}
}