Refactored
This commit is contained in:
+3
-6
@@ -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}")
|
||||
|
||||
Reference in New Issue
Block a user