Skip to content

Commit

Permalink
skip to last instance size if max was stepped over
Browse files Browse the repository at this point in the history
  • Loading branch information
ImogenBits committed Oct 7, 2023
1 parent 719241f commit c69da71
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 2 additions & 1 deletion algobattle/battle.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,10 @@ async def run_battle(self, fight: FightHandler, config: Config, min_size: int, u
def sizes(size: int, max_size: int) -> Iterable[int]:
counter = count(1)
size = max(size, min_size)
while size <= max_size:
while size < max_size:
yield size
size += next(counter) ** config.exponent
yield max_size

note = "Starting battle..."
for _ in range(config.rounds):
Expand Down
6 changes: 1 addition & 5 deletions tests/test_battles.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,7 @@ async def test_full_battle(self) -> None:
await self._expect_fights(always(fail), [1])
await self._expect_fights(
always(succ),
[1, 2, 6, 15, 31, 56, 92, 141, 205, 286, 386, 507, 651, 820]
+ [821, 822, 826, 835, 851, 876, 912, 961]
+ [962, 963, 967, 976, 992]
+ [993, 994, 998]
+ [999, 1000],
[1, 2, 6, 15, 31, 56, 92, 141, 205, 286, 386, 507, 651, 820, 1000],
score=1000,
total=True,
)
Expand Down

0 comments on commit c69da71

Please sign in to comment.