fix(SAC_LSTM_Bot): MA history self-truncation — read before > redirect; campaign v2 attempt-3 prep (#60)
$(cat f) inside a command redirected to f saw the already-truncated file, so every eval cycle wiped ma_history_*.txt back to one leading-space value and degraded the composite best-gate to last-cycle mean. Read is hoisted into its own statement; unquoted expansion + tail -n keeps exactly the last MA_WINDOW values. Verified: fresh/5+/6+ cycle edges reproduce sliding window.
This commit is contained in:
@@ -119,8 +119,16 @@ eval_checkpoint() {
|
||||
wr=$(( 100 * wins / rounds ))
|
||||
echo ">>> [eval] win rate: $wins/$rounds ($wr%) vs $opp"
|
||||
cat "$otmp" >> "$tmp"; rm -f "$otmp"
|
||||
# Per-opponent history: append this cycle's win rate, keep last MA_WINDOW.
|
||||
printf '%s\n' "$(cat "$(ma_hist_file "$opp")" 2>/dev/null)" "$wr" \
|
||||
# Per-opponent history: append this cycle's win rate, keep last MA_WINDOW
|
||||
# values on one line. Read FIRST, separately: `$(cat f)` inside a command
|
||||
# redirected `> f` executes against the already-truncated file (bash sets
|
||||
# up the redirect before running the substitution) — every cycle wiped the
|
||||
# history back to a single leading-space value (#60). $hist is UNQUOTED on
|
||||
# purpose: word-splitting turns the stored line into one value per line so
|
||||
# tail keeps the last MA_WINDOW values.
|
||||
local hist
|
||||
hist="$(cat "$(ma_hist_file "$opp")" 2>/dev/null)"
|
||||
printf '%s\n' $hist "$wr" \
|
||||
| tail -n "$MA_WINDOW" | tr '\n' ' ' > "$(ma_hist_file "$opp")"
|
||||
done
|
||||
mv "$tmp" "$EVAL_LOG_FILE"
|
||||
|
||||
Reference in New Issue
Block a user