#!/bin/bash

DIR=$( cd $(dirname "${BASH_SOURCE[0]}") && pwd )
cd "$DIR/.."

set -ex

cargo clean
cargo build --release
rm -f gnugo-benchmark*
rm -f previous-version-benchmark*

GNUGO="gnugo --mode gtp --level 0 --chinese-rules --positional-superko --capture-all-dead --score aftermath --play-out-aftermath"
IOMRASCALAI1="./target/release/iomrascalai -e mc -t 8"
IOMRASCALAI2="./target/release/iomrascalai -e amaf -t 8"
REFEREE="$GNUGO"
SIZE=9
GAMES=100
TIME="5m"
THREADS=4

gogui-twogtp -auto -black "$IOMRASCALAI1" -white "$IOMRASCALAI2" \
             -size $SIZE -alternate -games $GAMES -sgffile selfplay-benchmark \
             -time $TIME -threads $THREADS
gogui-twogtp -analyze selfplay-benchmark.dat
