Exemplo n.º 1
0
class AlphaBetaPlayer:
    """
    Minimax player with Alpha-Beta pruning
    for mutiplayer games.  Makes "paranoid assumption"
    if number of players > 2.

    Most of the work is done in search.py
    """
    def __init__(self, gd, sim, role, heuristic=None, maxDepth=-1):
        from ggp.search import Search
        self.gd = gd
        self.sim = sim
        self.role = role
        self.heuristic = heuristic
        self.maxDepth = maxDepth
        self.move = None
        self.search = Search(gd, sim, role, self.shouldIStop,
                             self.processResponse)

    def processResponse(self, sr):
        self.move = sr.bestMove

    def shouldIStop(self):
        return False

    def act(self, state, legal):
        self.move = legal[self.role][0]
        self.search.search(state, self.heuristic, maxDepth=self.maxDepth)
        return self.move

    def processReward(self, rewards):
        # Clear out transposition table at end of match
        self.search.tt = None
Exemplo n.º 2
0
class AlphaBetaPlayer:
    """
    Minimax player with Alpha-Beta pruning
    for mutiplayer games.  Makes "paranoid assumption"
    if number of players > 2.

    Most of the work is done in search.py
    """
    def __init__(self, gd, sim, role, heuristic=None, maxDepth=-1):
        from ggp.search import Search
        self.gd = gd
        self.sim = sim
        self.role = role
        self.heuristic = heuristic
        self.maxDepth = maxDepth
        self.move = None
        self.search = Search(gd, sim, role, self.shouldIStop, self.processResponse)

    def processResponse(self, sr):
        self.move = sr.bestMove

    def shouldIStop(self):
        return False

    def act(self, state, legal):
	self.move = legal[self.role][0]
	self.search.search(state, self.heuristic, maxDepth=self.maxDepth)
	return self.move

    def processReward(self, rewards):
        # Clear out transposition table at end of match
        self.search.tt = None
Exemplo n.º 3
0
 def __init__(self, gd, sim, role, heuristic=None, maxDepth=-1):
     from ggp.search import Search
     self.gd = gd
     self.sim = sim
     self.role = role
     self.heuristic = heuristic
     self.maxDepth = maxDepth
     self.move = None
     self.search = Search(gd, sim, role, self.shouldIStop,
                          self.processResponse)
Exemplo n.º 4
0
 def __init__(self, gd, sim, role, heuristic=None, maxDepth=-1):
     from ggp.search import Search
     self.gd = gd
     self.sim = sim
     self.role = role
     self.heuristic = heuristic
     self.maxDepth = maxDepth
     self.move = None
     self.search = Search(gd, sim, role, self.shouldIStop, self.processResponse)