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