當前位置: 首頁>>代碼示例>>Python>>正文


Python agents.Agent方法代碼示例

本文整理匯總了Python中agents.Agent方法的典型用法代碼示例。如果您正苦於以下問題:Python agents.Agent方法的具體用法?Python agents.Agent怎麽用?Python agents.Agent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在agents的用法示例。


在下文中一共展示了agents.Agent方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import agents [as 別名]
# 或者: from agents import Agent [as 別名]
def __init__(self):
        Agent.__init__(self)
        state = []
        seq = []

        def program(percept):
            state = self.update_state(state, percept)
            if not seq:
                goal = self.formulate_goal(state)
                problem = self.formulate_problem(state, goal)
                seq = self.search(problem)
            action = seq[0]
            seq[0:1] = []
            return action

        self.program = program

#______________________________________________________________________________
## Uninformed Search algorithms 
開發者ID:kengz,項目名稱:robocup-soccer,代碼行數:21,代碼來源:search.py

示例2: WalkSAT

# 需要導入模塊: import agents [as 別名]
# 或者: from agents import Agent [as 別名]
def WalkSAT(clauses, p=0.5, max_flips=10000):
    ## model is a random assignment of true/false to the symbols in clauses
    ## See ~/aima1e/print1/manual/knowledge+logic-answers.tex ???
    model = dict([(s, random.choice([True, False])) 
                 for s in prop_symbols(clauses)])
    for i in range(max_flips):
        satisfied, unsatisfied = [], []
        for clause in clauses:
            if_(pl_true(clause, model), satisfied, unsatisfied).append(clause)
        if not unsatisfied: ## if model satisfies all the clauses
            return model
        clause = random.choice(unsatisfied)
        if probability(p):
            sym = random.choice(prop_symbols(clause))
        else:
            ## Flip the symbol in clause that miximizes number of sat. clauses
            raise NotImplementedError
        model[sym] = not model[sym]


# PL-Wumpus-Agent [Fig. 7.19] 
開發者ID:kengz,項目名稱:robocup-soccer,代碼行數:23,代碼來源:logic.py

示例3: get_action

# 需要導入模塊: import agents [as 別名]
# 或者: from agents import Agent [as 別名]
def get_action(self, state, legal_moves=None):
        """Agent method, called by the game to pick a move."""
        if legal_moves is None:
            legal_moves = self.reversi.legal_moves(state)

        if not legal_moves:
            # no actions available
            return None
        else:
            move = None
            if self.epsilon > random.random():
                move = random.choice(legal_moves)
            else:
                move = self.policy(state, legal_moves)
            if self.learning_enabled:
                self.train(state, legal_moves)
                self.prev_move = move
                self.prev_state = state
            return move 
開發者ID:andysalerno,項目名稱:reversi_ai,代碼行數:21,代碼來源:q_learning_agent.py

示例4: __init__

# 需要導入模塊: import agents [as 別名]
# 或者: from agents import Agent [as 別名]
def __init__(self, belief_state):
        agents.Agent.__init__(self)

        def program(percept):
            belief_state.observe(action, percept)
            program.action = argmax(belief_state.actions(), 
                                    belief_state.expected_outcome_utility)
            return program.action

        program.action = None
        self.program = program

#______________________________________________________________________________ 
開發者ID:kengz,項目名稱:robocup-soccer,代碼行數:15,代碼來源:probability.py

示例5: __init__

# 需要導入模塊: import agents [as 別名]
# 或者: from agents import Agent [as 別名]
def __init__(self,location,shape,plot):
        self.location = location
        self.shape = shape
        self.plot = plot
        self.env = Environment(self.shape)
        self.agent = Agent()
        self.child = Child(self.env.state) 
開發者ID:avelkoski,項目名稱:VacuumAI,代碼行數:9,代碼來源:__init__.py

示例6: create_agents

# 需要導入模塊: import agents [as 別名]
# 或者: from agents import Agent [as 別名]
def create_agents(self):
    agents = []
    for _ in range(self.config.num_threads):
      memory = ReplayMemory(self.config)
      agent = Agent(self.policy_network(), memory, self.summary, self.config)
      agents.append(agent)

    return agents 
開發者ID:brendanator,項目名稱:atari-rl,代碼行數:10,代碼來源:factory.py


注:本文中的agents.Agent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。