def next_move(self, game): """ Just looking at one step ahead for now 1. Generate all possible game states 2. Evaluate h = w1*f1 + w2*f2 + w3*f3... 3. Pick the best one (greedy breadth first search) """ game_states = heuristic.get_next_states(game,self.name,1) h = [] for game_state in game_states[1]: h.append((self.get_score(game_state), game_state)) next_node = max(h)[1][2] return (next_node.x, next_node.y)
def next_minmax_move(self, game): """ Just looking at one step ahead for now 1. Generate all possible game states 2. Evaluate h = w1*f1 + w2*f2 + w3*f3... 3. Pick the best one (greedy breadth first search) """ import copy #print "Getting next states..." game_states = heuristic.get_next_states(copy.deepcopy(game),self.depth) #print "Searching..." next_score, next_game = self.minimax_search(game_states, self.depth) #print next_score, next_game next_node = next_game[2] #print "Found %s." % str((next_node.x, next_node.y)) return (next_node.x, next_node.y)