trictrac/bot/scripts/train.sh

44 lines
1 KiB
Bash
Raw Normal View History

2025-08-10 15:32:41 +02:00
#!/usr/bin/env sh
ROOT="$(cd "$(dirname "$0")" && pwd)/../.."
LOGS_DIR="$ROOT/bot/models/logs"
CFG_SIZE=12
2025-08-19 21:39:55 +02:00
BINBOT=train_sac_burn
# BINBOT=train_ppo_burn
2025-08-19 17:46:22 +02:00
# BINBOT=train_dqn_burn
2025-08-17 17:42:59 +02:00
# BINBOT=train_dqn_burn_big
2025-08-13 18:16:30 +02:00
# BINBOT=train_dqn_burn_before
2025-08-10 15:32:41 +02:00
OPPONENT="random"
PLOT_EXT="png"
train() {
2025-08-13 18:16:30 +02:00
cargo build --release --bin=$BINBOT
2025-08-17 17:42:59 +02:00
NAME="$(date +%Y-%m-%d_%H:%M:%S)"
LOGS="$LOGS_DIR/$BINBOT/$NAME.out"
mkdir -p "$LOGS_DIR/$BINBOT"
2025-08-13 18:16:30 +02:00
LD_LIBRARY_PATH="$ROOT/target/release" "$ROOT/target/release/$BINBOT" | tee "$LOGS"
2025-08-10 15:32:41 +02:00
}
plot() {
2025-08-17 17:42:59 +02:00
NAME=$(ls -rt "$LOGS_DIR/$BINBOT" | tail -n 1)
LOGS="$LOGS_DIR/$BINBOT/$NAME"
2025-08-10 15:32:41 +02:00
cfgs=$(head -n $CFG_SIZE "$LOGS")
for cfg in $cfgs; do
eval "$cfg"
done
# tail -n +$((CFG_SIZE + 2)) "$LOGS"
tail -n +$((CFG_SIZE + 2)) "$LOGS" |
grep -v "info:" |
awk -F '[ ,]' '{print $5}' |
2025-08-17 17:42:59 +02:00
feedgnuplot --lines --points --unset grid --title "adv = $OPPONENT ; density = $dense_size ; decay = $eps_decay ; max steps = $max_steps" --terminal $PLOT_EXT >"$LOGS_DIR/$BINBOT/$NAME.$PLOT_EXT"
2025-08-10 15:32:41 +02:00
}
if [ "$1" = "plot" ]; then
plot
else
train
fi