From 105d2a2951856093de28c97371fa88e92fee57bd Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 19 Feb 2022 22:12:23 -0500 Subject: [PATCH] [F] A2 pyta warnings --- assignments/A2/a2_part2.py | 14 +++++++------- assignments/A2/a2_part3.py | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/assignments/A2/a2_part2.py b/assignments/A2/a2_part2.py index c8bc6f0..3f8aba2 100644 --- a/assignments/A2/a2_part2.py +++ b/assignments/A2/a2_part2.py @@ -205,13 +205,13 @@ def part2_runner(d: int, n: int, white_greedy: bool) -> None: if __name__ == '__main__': - # import python_ta - # python_ta.check_all(config={ - # 'max-line-length': 100, - # 'max-nested-blocks': 4, - # 'disable': ['E1136'], - # 'extra-imports': ['random', 'a2_minichess', 'a2_game_tree'] - # }) + import python_ta + python_ta.check_all(config={ + 'max-line-length': 100, + 'max-nested-blocks': 4, + 'disable': ['E1136'], + 'extra-imports': ['random', 'a2_minichess', 'a2_game_tree'] + }) # Sample call to part2_runner (you can change this, just keep it in the main block!) part2_runner(5, 50, True) diff --git a/assignments/A2/a2_part3.py b/assignments/A2/a2_part3.py index 02bbf71..cd87e4a 100644 --- a/assignments/A2/a2_part3.py +++ b/assignments/A2/a2_part3.py @@ -54,7 +54,7 @@ class ExploringPlayer(a2_minichess.Player): self._game_tree = self._game_tree.find_subtree_by_move(previous_move) # Tree has been explored, make a random choice - if self._game_tree is None or len(self._game_tree.get_subtrees()) == 0 : + if self._game_tree is None or len(self._game_tree.get_subtrees()) == 0: move = random.choice(game.get_valid_moves()) # "If the random number is < p, the player chooses a random move from among all valid moves @@ -119,6 +119,7 @@ def run_learning_algorithm(exploration_probabilities: list[float], a2_minichess.RandomPlayer()) # After the game, insert move sequence with white win probability game_tree.insert_move_sequence(seq, float(winner == 'White')) + results_so_far.append(winner) # Print progress print(f'Winner: {winner}')