-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up some code in games and powersystem (#420)
- Loading branch information
Showing
3 changed files
with
196 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,17 @@ | ||
from ...common import testing | ||
from typing import Any | ||
from typing import List | ||
import typing as tp | ||
from nevergrad.common import testing | ||
import numpy as np | ||
from . import game | ||
|
||
@testing.parametrized(**{name: (name,) for name in ["war", "flip", "batawaf", "guesswho", "bigguesswho"]}) | ||
|
||
@testing.parametrized(**{name: (name,) for name in game._Game().get_list_of_games()}) | ||
def test_games(name: str) -> None: | ||
dimension = game._Game().play_game(name) | ||
res: List[Any] = [] | ||
res: tp.List[tp.Any] = [] | ||
for _ in range(200): | ||
res += [game._Game().play_game(name, np.random.uniform(0, 1, dimension), None)] | ||
score = (float(sum(1 if r == 2 else 0 if r == 1 else 0.5 for r in res)) / len(res)) | ||
assert score >= 0.1 | ||
assert score <= 0.9 | ||
function = game.Game(name) | ||
function(function.instrumentation.random_state.normal(size=function.dimension)) | ||
|
||
|
||
|
Oops, something went wrong.