Skip to content

Commit

Permalink
chore: remove unused method str_to_bool()
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianFredrikJohnsen committed May 2, 2024
1 parent e58bb42 commit fc9e8c9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
10 changes: 0 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,6 @@ def play(context: GameContext, first: bool, mcts: bool = False):
save_path=connect4_path
)

def str2bool(v: str) -> bool:
if isinstance(v, bool):
return v
if v.lower() in ('yes', 'true', 't', 'y', '1'):
return True
elif v.lower() in ('no', 'false', 'f', 'n', '0'):
return False
else:
raise ArgumentTypeError('Boolean value expected.')

parser: ArgumentParser = ArgumentParser(description='Control the execution of the AlphaZero game playing system.')
parser.add_argument('--test_overfit', action='store_true', help='Test overfitting on Connect Four.')
parser.add_argument('--train_ttt', action='store_true', help='Train AlphaZero on Tic Tac Toe.')
Expand Down
3 changes: 1 addition & 2 deletions src/alphazero/agents/alphazero_play_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AlphaZero:
def __init__(self, context: GameContext):
self.context = context
self.shape = [1] + context.game.observation_tensor_shape()
self.c = 1.41 # Exploration constant
self.c = 4. # Exploration constant

def run_simulation(self, state, num_simulations=800): # Num-simulations 800 is good for tic-tac-toe
"""
Expand Down Expand Up @@ -57,7 +57,6 @@ def alphazero_self_play(context: GameContext, num_simulations=800):

while (not state.is_terminal()):
action = alphazero.run_simulation(state, num_simulations)
print("best action\t", action, "\n")
state.apply_action(action)
print(state)

Expand Down

0 comments on commit fc9e8c9

Please sign in to comment.