Refactored

This commit is contained in:
2024-06-10 21:07:38 +02:00
parent 61d1ab0431
commit e47959373b
5 changed files with 65 additions and 61 deletions
+3 -6
View File
@@ -6,8 +6,8 @@ from state import get_potential_moves
class MachinePlayer(APlayer):
class Params:
def __init__(self, p_exp, alpha):
self.p_exp = p_exp
def __init__(self, p_explore, alpha):
self.p_exp = p_explore
self.alpha = alpha
def __init__(self, mark, params: Params, values):
@@ -53,7 +53,6 @@ class MachinePlayer(APlayer):
self.state_last = None
def move(self, state: np.array):
do_sample = False
values = np.array([])
# get possible move
moves = get_potential_moves(state)
@@ -74,13 +73,11 @@ class MachinePlayer(APlayer):
next_move = best_move
is_exp = False
# Randomly perform exploratory move
if uniform() < self.params.p_exp:
index = np.random.randint(len(moves))
next_move = moves[index]
is_exp = best_move != next_move
elif do_sample:
index = sample(values)
next_move = moves[index]
if self.with_debug:
print(f"{self.mark}: Values = {values}")