Refactored

This commit is contained in:
2024-06-10 20:48:50 +02:00
parent 285549568d
commit 61d1ab0431
4 changed files with 47 additions and 44 deletions
+4 -4
View File
@@ -2,7 +2,7 @@ import numpy as np
from a_player import APlayer
from helper import sample
from numpy.random import uniform
from state import get_potential_moves
class MachinePlayer(APlayer):
class Params:
@@ -56,7 +56,7 @@ class MachinePlayer(APlayer):
do_sample = False
values = np.array([])
# get possible move
moves = self.get_potential_moves(state)
moves = get_potential_moves(state)
if moves.size == 0:
return state, False
@@ -64,7 +64,7 @@ class MachinePlayer(APlayer):
best_value = -1
for move in moves:
# create hypothetical next state
state_next = self.state_from_move(state.copy(), move)
state_next = self.to_state(state.copy(), move)
# evaluate value
value = self.get_value(state_next)
if best_value < value:
@@ -91,7 +91,7 @@ class MachinePlayer(APlayer):
if self.state is not None:
self.state_last = self.state.copy()
self.state = self.state_from_move(state.copy(), next_move)
self.state = self.to_state(state.copy(), next_move)
# Learn
if not is_exp and self.state_last is not None: