Skip to content

Commit d2cee2d

Browse files
committed
change order of nodes while traversing GameNodes
1 parent afab480 commit d2cee2d

1 file changed

Lines changed: 44 additions & 44 deletions

File tree

tests/test_behav.py

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -584,64 +584,64 @@ def test_set_probabilities_player_by_label(game: gbt.Game, player_label: str, be
584584

585585
@pytest.mark.parametrize(
586586
"game,node_idx,realiz_prob,rational_flag",
587-
[(games.create_mixed_behav_game_efg(), 0, "1", True),
588-
(games.create_mixed_behav_game_efg(), 1, "1/2", True),
587+
[(games.create_mixed_behav_game_efg(), 0, "1/8", True),
588+
(games.create_mixed_behav_game_efg(), 1, "1/8", True),
589589
(games.create_mixed_behav_game_efg(), 2, "1/4", True),
590590
(games.create_mixed_behav_game_efg(), 3, "1/8", True),
591591
(games.create_mixed_behav_game_efg(), 4, "1/8", True),
592592
(games.create_mixed_behav_game_efg(), 5, "1/4", True),
593-
(games.create_mixed_behav_game_efg(), 6, "1/8", True),
593+
(games.create_mixed_behav_game_efg(), 6, "1/2", True),
594594
(games.create_mixed_behav_game_efg(), 7, "1/8", True),
595-
(games.create_mixed_behav_game_efg(), 8, "1/2", True),
595+
(games.create_mixed_behav_game_efg(), 8, "1/8", True),
596596
(games.create_mixed_behav_game_efg(), 9, "1/4", True),
597597
(games.create_mixed_behav_game_efg(), 10, "1/8", True),
598598
(games.create_mixed_behav_game_efg(), 11, "1/8", True),
599599
(games.create_mixed_behav_game_efg(), 12, "1/4", True),
600-
(games.create_mixed_behav_game_efg(), 13, "1/8", True),
601-
(games.create_mixed_behav_game_efg(), 14, "1/8", True),
602-
(games.create_mixed_behav_game_efg(), 0, 1.0, False),
603-
(games.create_mixed_behav_game_efg(), 1, 0.5, False),
600+
(games.create_mixed_behav_game_efg(), 13, "1/2", True),
601+
(games.create_mixed_behav_game_efg(), 14, "1", True),
602+
(games.create_mixed_behav_game_efg(), 0, 0.125, False),
603+
(games.create_mixed_behav_game_efg(), 1, 0.125, False),
604604
(games.create_mixed_behav_game_efg(), 2, 0.25, False),
605605
(games.create_mixed_behav_game_efg(), 3, 0.125, False),
606606
(games.create_mixed_behav_game_efg(), 4, 0.125, False),
607607
(games.create_mixed_behav_game_efg(), 5, 0.25, False),
608-
(games.create_mixed_behav_game_efg(), 6, 0.125, False),
608+
(games.create_mixed_behav_game_efg(), 6, 0.5, False),
609609
(games.create_mixed_behav_game_efg(), 7, 0.125, False),
610-
(games.create_mixed_behav_game_efg(), 8, 0.5, False),
610+
(games.create_mixed_behav_game_efg(), 8, 0.125, False),
611611
(games.create_mixed_behav_game_efg(), 9, 0.25, False),
612612
(games.create_mixed_behav_game_efg(), 10, 0.125, False),
613613
(games.create_mixed_behav_game_efg(), 11, 0.125, False),
614614
(games.create_mixed_behav_game_efg(), 12, 0.25, False),
615-
(games.create_mixed_behav_game_efg(), 13, 0.125, False),
616-
(games.create_mixed_behav_game_efg(), 14, 0.125, False),
617-
(games.create_myerson_2_card_poker_efg(), 0, "1", True),
618-
(games.create_myerson_2_card_poker_efg(), 1, "1/2", True),
615+
(games.create_mixed_behav_game_efg(), 13, 0.5, False),
616+
(games.create_mixed_behav_game_efg(), 14, 1, False),
617+
(games.create_myerson_2_card_poker_efg(), 0, "1/8", True),
618+
(games.create_myerson_2_card_poker_efg(), 1, "1/8", True),
619619
(games.create_myerson_2_card_poker_efg(), 2, "1/4", True),
620-
(games.create_myerson_2_card_poker_efg(), 3, "1/8", True),
621-
(games.create_myerson_2_card_poker_efg(), 4, "1/8", True),
622-
(games.create_myerson_2_card_poker_efg(), 5, "1/4", True),
623-
(games.create_myerson_2_card_poker_efg(), 6, "1/2", True),
620+
(games.create_myerson_2_card_poker_efg(), 3, "1/4", True),
621+
(games.create_myerson_2_card_poker_efg(), 4, "1/2", True),
622+
(games.create_myerson_2_card_poker_efg(), 5, "1/8", True),
623+
(games.create_myerson_2_card_poker_efg(), 6, "1/8", True),
624624
(games.create_myerson_2_card_poker_efg(), 7, "1/4", True),
625-
(games.create_myerson_2_card_poker_efg(), 8, "1/8", True),
626-
(games.create_myerson_2_card_poker_efg(), 9, "1/8", True),
627-
(games.create_myerson_2_card_poker_efg(), 10, "1/4", True),
628-
(games.create_myerson_2_card_poker_efg(), 0, 1.0, False),
629-
(games.create_myerson_2_card_poker_efg(), 1, 0.5, False),
625+
(games.create_myerson_2_card_poker_efg(), 8, "1/4", True),
626+
(games.create_myerson_2_card_poker_efg(), 9, "1/2", True),
627+
(games.create_myerson_2_card_poker_efg(), 10, "1", True),
628+
(games.create_myerson_2_card_poker_efg(), 0, 0.125, False),
629+
(games.create_myerson_2_card_poker_efg(), 1, 0.125, False),
630630
(games.create_myerson_2_card_poker_efg(), 2, 0.25, False),
631-
(games.create_myerson_2_card_poker_efg(), 3, 0.125, False),
632-
(games.create_myerson_2_card_poker_efg(), 4, 0.125, False),
633-
(games.create_myerson_2_card_poker_efg(), 5, 0.25, False),
634-
(games.create_myerson_2_card_poker_efg(), 6, 0.5, False),
631+
(games.create_myerson_2_card_poker_efg(), 3, 0.25, False),
632+
(games.create_myerson_2_card_poker_efg(), 4, 0.5, False),
633+
(games.create_myerson_2_card_poker_efg(), 5, 0.125, False),
634+
(games.create_myerson_2_card_poker_efg(), 6, 0.125, False),
635635
(games.create_myerson_2_card_poker_efg(), 7, 0.25, False),
636-
(games.create_myerson_2_card_poker_efg(), 8, 0.125, False),
637-
(games.create_myerson_2_card_poker_efg(), 9, 0.125, False),
638-
(games.create_myerson_2_card_poker_efg(), 10, 0.25, False)]
636+
(games.create_myerson_2_card_poker_efg(), 8, 0.25, False),
637+
(games.create_myerson_2_card_poker_efg(), 9, 0.5, False),
638+
(games.create_myerson_2_card_poker_efg(), 10, 1, False)]
639639
)
640640
def test_realiz_prob_nodes_reference(game: gbt.Game, node_idx: int,
641641
realiz_prob: typing.Union[str, float], rational_flag: bool):
642642
profile = game.mixed_behavior_profile(rational=rational_flag)
643643
realiz_prob = (gbt.Rational(realiz_prob) if rational_flag else realiz_prob)
644-
node = game.nodes()[node_idx]
644+
node = list(game.nodes)[node_idx]
645645
assert profile.realiz_prob(node) == realiz_prob
646646

647647

@@ -890,7 +890,7 @@ def test_martingale_property_of_node_value(game: gbt.Game, rational_flag: bool):
890890
realization probabilities of those children
891891
"""
892892
profile = game.mixed_behavior_profile(rational=rational_flag)
893-
for node in game.nodes():
893+
for node in game.nodes:
894894
if node.is_terminal or node.player.is_chance:
895895
continue
896896
expected_val = 0
@@ -1080,23 +1080,23 @@ def _get_and_check_answers(game: gbt.Game, action_probs1: tuple, action_probs2:
10801080
######################################################################################
10811081
# belief (at nodes)
10821082
(games.create_mixed_behav_game_efg(), PROBS_1A_doub, PROBS_2A_doub, False,
1083-
lambda x, y: x.belief(y), lambda x: x.nodes()),
1083+
lambda x, y: x.belief(y), lambda x: x.nodes),
10841084
(games.create_mixed_behav_game_efg(), PROBS_1A_rat, PROBS_2A_rat, True,
1085-
lambda x, y: x.belief(y), lambda x: x.nodes()),
1085+
lambda x, y: x.belief(y), lambda x: x.nodes),
10861086
(games.create_myerson_2_card_poker_efg(), PROBS_1B_doub, PROBS_2B_doub, False,
1087-
lambda x, y: x.belief(y), lambda x: x.nodes()),
1087+
lambda x, y: x.belief(y), lambda x: x.nodes),
10881088
(games.create_myerson_2_card_poker_efg(), PROBS_1A_rat, PROBS_2A_rat, True,
1089-
lambda x, y: x.belief(y), lambda x: x.nodes()),
1089+
lambda x, y: x.belief(y), lambda x: x.nodes),
10901090
######################################################################################
10911091
# realiz_prob (at nodes)
10921092
(games.create_mixed_behav_game_efg(), PROBS_1A_doub, PROBS_2A_doub, False,
1093-
lambda x, y: x.realiz_prob(y), lambda x: x.nodes()),
1093+
lambda x, y: x.realiz_prob(y), lambda x: x.nodes),
10941094
(games.create_mixed_behav_game_efg(), PROBS_1A_rat, PROBS_2A_rat, True,
1095-
lambda x, y: x.realiz_prob(y), lambda x: x.nodes()),
1095+
lambda x, y: x.realiz_prob(y), lambda x: x.nodes),
10961096
(games.create_myerson_2_card_poker_efg(), PROBS_1B_doub, PROBS_2B_doub, False,
1097-
lambda x, y: x.realiz_prob(y), lambda x: x.nodes()),
1097+
lambda x, y: x.realiz_prob(y), lambda x: x.nodes),
10981098
(games.create_myerson_2_card_poker_efg(), PROBS_1A_rat, PROBS_2A_rat, True,
1099-
lambda x, y: x.realiz_prob(y), lambda x: x.nodes()),
1099+
lambda x, y: x.realiz_prob(y), lambda x: x.nodes),
11001100
######################################################################################
11011101
# infoset_prob
11021102
(games.create_mixed_behav_game_efg(), PROBS_1A_doub, PROBS_2A_doub, False,
@@ -1141,16 +1141,16 @@ def _get_and_check_answers(game: gbt.Game, action_probs1: tuple, action_probs2:
11411141
# node_value
11421142
(games.create_mixed_behav_game_efg(), PROBS_1A_doub, PROBS_2A_doub, False,
11431143
lambda x, y: x.node_value(player=y[0], node=y[1]),
1144-
lambda x: list(product(x.players, x.nodes()))),
1144+
lambda x: list(product(x.players, x.nodes))),
11451145
(games.create_mixed_behav_game_efg(), PROBS_1A_rat, PROBS_2A_rat, True,
11461146
lambda x, y: x.node_value(player=y[0], node=y[1]),
1147-
lambda x: list(product(x.players, x.nodes()))),
1147+
lambda x: list(product(x.players, x.nodes))),
11481148
(games.create_myerson_2_card_poker_efg(), PROBS_1B_doub, PROBS_2B_doub, False,
11491149
lambda x, y: x.node_value(player=y[0], node=y[1]),
1150-
lambda x: list(product(x.players, x.nodes()))),
1150+
lambda x: list(product(x.players, x.nodes))),
11511151
(games.create_myerson_2_card_poker_efg(), PROBS_1A_rat, PROBS_2A_rat, True,
11521152
lambda x, y: x.node_value(player=y[0], node=y[1]),
1153-
lambda x: list(product(x.players, x.nodes()))),
1153+
lambda x: list(product(x.players, x.nodes))),
11541154
######################################################################################
11551155
# liap_value (of profile, hence [1] for objects_to_test, any singleton collection would do)
11561156
(games.create_mixed_behav_game_efg(), PROBS_1A_doub, PROBS_2A_doub, False,

0 commit comments

Comments
 (0)