experiment.agentprogram.agentprogram module

class experiment.agentprogram.agentprogram.AgentProgram(world=None, agent=None)

Bases: object

get_direction_to_position(position)

Get the direction (left, right, backward, straight ahead) of a position relative to this agent.

Parameters:position – The position to get the direction for.
Returns:“a” for ahead, “l” for left, “r” for right, “b” for behind
get_interaction(percept)

Get the interaction to enact.

Returns:The primitive interaction that the enact should enact.
get_nearest(cls)

Get the entity of a certain class that is nearest to the agent.

NOTE: Uses heuristic (Manhattan) distance.

Parameters:cls – The class the entity should be an instance of
get_nearest_block()
get_nearest_food()
set_agent(agent)
set_world(world)
class experiment.agentprogram.agentprogram.SimpleEatingAndDestroyingAgent(world=None, agent=None)

Bases: experiment.agentprogram.agentprogram.AgentProgram

An agent that wants to eat if there is food and attempts to break a block if there is a block.

get_interaction(percept)
class experiment.agentprogram.agentprogram.TrivialAgentProgram(world=None, agent=None)

Bases: experiment.agentprogram.agentprogram.AgentProgram

A trivial agent program that simply attempts to perform the first primitive known by the agent.

get_interaction(percept)
experiment.agentprogram.agentprogram.create_programmable_agent(program_class, world)