Skip to content

Commit

Permalink
RunCycle: stop execution when one warrior left living (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
bobertlo authored Nov 17, 2024
1 parent e7c2776 commit 0dfeb50
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sim.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ func (s *reportSim) RunCycle() int {
s.Report(Report{Type: WarriorTerminate, Cycle: int(s.cycleCount), WarriorIndex: i, Address: pc})
s.warriors[i].state = WarriorDead
s.warriorLivingCount--

if s.warriorCount > 1 {
if s.warriorLivingCount == 1 {
return s.warriorLivingCount
}
}
}
}
}
Expand Down

0 comments on commit 0dfeb50

Please sign in to comment.