fix(test_bullet_economy): correct bot name and rank comparison for winner detection
- Match "Walls (Nim)" instead of "WallsBot" — sample bot reports with "(Nim)" suffix - Guard against unmatched bot (rank=0) so a missing entry doesn't silently flip the winner - The rank comparison itself (lower = better) was correct; the stale name was the root cause Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -39,20 +39,21 @@ var snnWins, wallsWins: int
|
||||
for rnd in r.rounds:
|
||||
var snn, walls: BotRoundResult
|
||||
for br in rnd.results:
|
||||
if br.name == "SNNBot": snn = br
|
||||
if br.name == "WallsBot": walls = br
|
||||
let winner = if snn.rank < walls.rank: "SNNBot" else: "WallsBot"
|
||||
if br.name == "SNNBot": snn = br
|
||||
if br.name == "Walls (Nim)": walls = br
|
||||
# rank 1 = winner; lower rank is better; default rank=0 means bot not found
|
||||
let winner = if snn.rank > 0 and (walls.rank == 0 or snn.rank < walls.rank): "SNNBot" else: "Walls"
|
||||
if winner == "SNNBot": inc snnWins else: inc wallsWins
|
||||
echo fmt"Round {rnd.round:2}: {winner} wins | SNNBot score={snn.score} survived={snn.survived} | WallsBot score={walls.score} survived={walls.survived}"
|
||||
echo fmt"Round {rnd.round:2}: {winner} wins | SNNBot score={snn.score} survived={snn.survived} | Walls score={walls.score} survived={walls.survived}"
|
||||
|
||||
# Summary
|
||||
echo ""
|
||||
echo "=== Summary (10 rounds) ==="
|
||||
var snnFinal, wallsFinal: BotResult
|
||||
for b in r.results:
|
||||
if b.name == "SNNBot": snnFinal = b
|
||||
if b.name == "WallsBot": wallsFinal = b
|
||||
if b.name == "SNNBot": snnFinal = b
|
||||
if b.name == "Walls (Nim)": wallsFinal = b
|
||||
|
||||
echo fmt"SNNBot : wins={snnWins}/10 totalScore={snnFinal.totalScore} survivalRounds={snnFinal.survivalCount} firstPlaces={snnFinal.firstPlaces}"
|
||||
echo fmt"WallsBot : wins={wallsWins}/10 totalScore={wallsFinal.totalScore} survivalRounds={wallsFinal.survivalCount} firstPlaces={wallsFinal.firstPlaces}"
|
||||
echo fmt"SNNBot : wins={snnWins}/10 totalScore={snnFinal.totalScore} survivalRounds={snnFinal.survivalCount} firstPlaces={snnFinal.firstPlaces}"
|
||||
echo fmt"Walls : wins={wallsWins}/10 totalScore={wallsFinal.totalScore} survivalRounds={wallsFinal.survivalCount} firstPlaces={wallsFinal.firstPlaces}"
|
||||
echo fmt"Win rate : {snnWins * 100 div 10}%"
|
||||
|
||||
Reference in New Issue
Block a user