예제 #1
0
def test_random_subgames(players, strategies):
    game = rsgame.BaseGame(players, strategies)
    rand_subgames = subgame.random_subgames(game, 30)
    assert rand_subgames.shape[0] == 30
    assert game.role_reduce(rand_subgames, ufunc=np.logical_or).all(), \
        "Not all subgames were valid"

    rand_subgames2 = subgame.subgame_from_id(
        game, subgame.subgame_id(game, rand_subgames))
    assert np.all(rand_subgames == rand_subgames2)
예제 #2
0
def test_all_subgames(players, strategies):
    game = rsgame.BaseGame(players, strategies)
    all_subgames = subgame.all_subgames(game)
    assert game.role_reduce(all_subgames, ufunc=np.logical_or).all(), \
        "Not all subgames were valid"

    distinct = np.unique(utils.axis_to_elem(all_subgames)).size
    assert distinct == all_subgames.shape[0]

    ids = subgame.subgame_id(game, all_subgames)
    distinct_ids = np.unique(ids).size
    assert distinct_ids == all_subgames.shape[0]

    all_subgames2 = subgame.subgame_from_id(game, ids)
    assert np.all(all_subgames == all_subgames2)