Refactored

This commit is contained in:
2024-06-08 21:00:00 +02:00
parent f97c3b6f56
commit 8cdb816409
+12 -5
View File
@@ -119,10 +119,14 @@ class APlayer(object):
class MachinePlayer(APlayer):
def __init__(self, mark='X', with_debug=False):
def __init__(self, mark='X', with_debug=False, values=None):
APlayer.__init__(self, mark)
self.with_debug = with_debug
self.values = {}
if values is None:
self.values = {}
else:
self.values = values
def get_value(self, state):
try:
@@ -230,8 +234,11 @@ def play(player_provider: PlayerProvider, k_max=10000, with_print=False):
move += 1
with_debug = True
players = PlayerProvider(MachinePlayer(mark='X', with_debug=with_debug), MachinePlayer(mark='O', with_debug=with_debug))
play(players, 10000, with_debug)
px = MachinePlayer(mark='X')
po = MachinePlayer(mark='O')
players = PlayerProvider(px, po)
play(players, 10000, False)
players = PlayerProvider(MachinePlayer(mark='X', with_debug=True, values=px.values), MachinePlayer(mark='O', with_debug=True, values=po.values))
play(players, 100, True)