Beispiel #1
0
def generic_preset_advisor(board_string, player=None, opponent=None, random_fill=False):
    advisor = Advisor()
    player = player or generic_actor("player")
    opponent = opponent or generic_actor("opponent")
    advisor.reset(Board(board_string), player, opponent, 0)
    # patch the game not to do random fills
    advisor._game.random_fill = random_fill
    return advisor
Beispiel #2
0
 def test_reset_sets_a_new_internal_root(self):
     advisor = Advisor()
     # patch the root to some value
     original_root = advisor._root = "fake root"
     # confirm reset changes the root and it's not None
     advisor.reset(Board(), generic_actor("player"), generic_actor("opponent"), 0)
     self.assertIsNot(
         advisor._root,
         original_root,
         "Unexpectedly found the same root after resetting:" "\n{}".format(original_root),
     )
     self.assertIsNotNone(advisor._root, 'Unexpectedly found "None" as the root after' " resetting")
Beispiel #3
0
 def test_reset_sets_the_current_completed_turn_to_zero(self):
     advisor = Advisor()
     # set a fake original value
     advisor._current_completed_turn = 2
     advisor.reset(Board(), generic_actor("player"), generic_actor("opponent"), 0)
     # confirm reset of the current turn indicator
     completed_turn = advisor.current_completed_turn
     self.assertEqual(
         completed_turn,
         0,
         "Unexpectedly found {} instead of zero for the"
         "current completed turn value after resetting"
         "the advisor".format(completed_turn),
     )
Beispiel #4
0
 def test_current_summaries_generates_empty_sequence_for_None_root(self):
     advisor = Advisor()
     advisor._root = None  # just to be sure
     summaries_for_None = list(advisor.sorted_current_summaries())
     empty_sequence = tuple()
     self.assertSequenceEqual(summaries_for_None, empty_sequence)
Beispiel #5
0
 def test_reset_sets_root_state_actions_remaining_to_1_plus_extra(self):
     advisor = Advisor()
     extra_actions = 2
     advisor.reset(Board(), generic_actor("player"), generic_actor("opponent"), extra_actions)
     actions_remaming_spec = 1 + extra_actions
     self.assertEqual(advisor._root.actions_remaining, actions_remaming_spec)