当前位置: 首页>>代码示例>>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;未经允许,请勿转载。