Skip to content

Commit

Permalink
Merge pull request #134 from ImogenBits/improve_iterated
Browse files Browse the repository at this point in the history
Improve iterated battles
  • Loading branch information
Benezivas authored Oct 8, 2023
2 parents 2e7e692 + c69da71 commit a1b1987
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 3 additions & 2 deletions algobattle/battle.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ class Config(Battle.Config):

type: Literal["Iterated"] = "Iterated"

rounds: int = 5
rounds: int = 3
"""Number of times the instance size will be increased until the solver fails to produce correct solutions."""
maximum_size: int = 50_000
"""Maximum instance size that will be tried."""
Expand Down 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 a1b1987

Please sign in to comment.