Skip to content

Commit 987cc86

Browse files
committed
refactor folders
1 parent e947c20 commit 987cc86

File tree

11 files changed

+18
-18
lines changed

11 files changed

+18
-18
lines changed

src/__main__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
# from digit_party.digit_party import human_game as digit_party_human_game
2-
# from digit_party.digit_party import many_trained_games as digit_party_many_trained_games
3-
# from digit_party.digit_party import trained_game as digit_party_trained_game
1+
# from games.digit_party.digit_party import human_game as digit_party_human_game
2+
# from games.digit_party.digit_party import many_trained_games as digit_party_many_trained_games
3+
# from games.digit_party.digit_party import trained_game as digit_party_trained_game
44

55
# digit_party_human_game()
66
# digit_party_trained_game(game_size=3)
77
# digit_party_many_trained_games(game_size=3)
88

9-
# from random_walk.random_walk import q_trained_game as random_walk_trained_game
9+
# from games.random_walk.random_walk import q_trained_game as random_walk_trained_game
1010

1111
# random_walk_trained_game()
1212

13-
# from tictactoe.tictactoe import monte_carlo_many_games as ttt_mc_many_games
14-
# from tictactoe.tictactoe import monte_carlo_trained_game as ttt_mc_trained_game
13+
# from games.tictactoe.tictactoe import monte_carlo_many_games as ttt_mc_many_games
14+
# from games.tictactoe.tictactoe import monte_carlo_trained_game as ttt_mc_trained_game
1515

1616
# ttt_mc_trained_game(training_episodes=0)
1717
# ttt_mc_many_games()
1818

19-
from tictactoe.ultimate import trained_game
19+
from games.tictactoe.ultimate import trained_game
2020

2121
trained_game()
File renamed without changes.
File renamed without changes.

src/digit_party/digit_party.py renamed to src/games/digit_party/digit_party.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def trained_game(game_size: int) -> None:
346346
# for a 2x2 game, the result is trivially 100%
347347
q = DigitPartyQLearner(
348348
game_size,
349-
q_pickle=f"src/digit_party/q-{game_size}x{game_size}.pkl",
349+
q_pickle=f"src/games/digit_party/q-{game_size}x{game_size}.pkl",
350350
epsilon=0.5,
351351
)
352352
g = DigitPartyQTrainer(player=q, n=game_size)
@@ -370,7 +370,7 @@ def trained_game(game_size: int) -> None:
370370

371371
def many_trained_games(game_size: int, games=10000) -> None:
372372
q = DigitPartyQLearner(
373-
game_size, q_pickle=f"src/digit_party/q-{game_size}x{game_size}.pkl"
373+
game_size, q_pickle=f"src/games/digit_party/q-{game_size}x{game_size}.pkl"
374374
)
375375
g = DigitPartyQTrainer(player=q, n=game_size)
376376

File renamed without changes.
File renamed without changes.

src/random_walk/random_walk.py renamed to src/games/random_walk/random_walk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def train_once(self) -> None:
114114

115115

116116
def q_trained_game() -> None:
117-
pkl_file = "src/random_walk/q.pkl"
117+
pkl_file = "src/games/random_walk/q.pkl"
118118
q = RandomWalkQLearner(epsilon=0.5, q_pickle=pkl_file)
119119
g = RandomWalkQTrainer(player=q)
120120
g.train()
@@ -173,7 +173,7 @@ def train_once(self) -> None:
173173

174174

175175
def monte_carlo_trained_game(training_episodes=10000):
176-
policy_pkl = "src/random_walk/monte_carlo_player.pkl"
176+
policy_pkl = "src/games/random_walk/monte_carlo_player.pkl"
177177
p = RandomWalkMonteCarloLearner(policy_file=policy_pkl)
178178
g = RandomWalkMonteCarloTrainer(p)
179179
g.train(episodes=training_episodes)
File renamed without changes.

src/tictactoe/tictactoe.py renamed to src/games/tictactoe/tictactoe.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,8 @@ def _many_games(
395395
print(f"{ties} ties")
396396

397397

398-
MCP1_POLICY = "src/tictactoe/mcp1.pkl"
399-
MCP2_POLICY = "src/tictactoe/mcp2.pkl"
398+
MCP1_POLICY = "src/games/tictactoe/mcp1.pkl"
399+
MCP2_POLICY = "src/games/tictactoe/mcp2.pkl"
400400

401401

402402
def monte_carlo_trained_game(training_episodes=0):
@@ -416,8 +416,8 @@ def monte_carlo_many_games(games=10000):
416416
_many_games(g, computer1, computer2, games)
417417

418418

419-
QP1_POLICY = "src/tictactoe/qp1.pkl"
420-
QP2_POLICY = "src/tictactoe/qp2.pkl"
419+
QP1_POLICY = "src/games/tictactoe/qp1.pkl"
420+
QP2_POLICY = "src/games/tictactoe/qp2.pkl"
421421

422422

423423
def q_trained_game(training_episodes=0):

src/tictactoe/ultimate.py renamed to src/games/tictactoe/ultimate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,8 @@ def apply(
423423
return UltimateTicTacToe.apply(state, action)
424424

425425

426-
MCP1_POLICY = "src/tictactoe/ultimate-mcp1.pkl"
427-
MCP2_POLICY = "src/tictactoe/ultimate-mcp2.pkl"
426+
MCP1_POLICY = "src/games/tictactoe/ultimate-mcp1.pkl"
427+
MCP2_POLICY = "src/games/tictactoe/ultimate-mcp2.pkl"
428428

429429

430430
def trained_game():

src/learners/alpha_zero/monte_carlo_tree_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def search(self, state: State) -> float:
9898
best_a = -1
9999

100100
# find the action with the highest upper confidence bound u
101-
# u(s, a) = q(s, q) + c_puct * pi(s, a) * sqrt(sum all actions b: (N(s, b)) / (1 + N(s, a))
101+
# u(s, a) = q(s, a) + c_puct * pi(s, a) * sqrt(sum all actions b: (N(s, b)) / (1 + N(s, a))
102102
for a in range(self.game.num_actions()):
103103
if valids[a]:
104104
if (ir, a) in self.q:

0 commit comments

Comments
 (0)