aind_behavior_gym.dynamic_foraging.agent package

Submodules

aind_behavior_gym.dynamic_foraging.agent.base module

Generic agent class for dynamic foraging

class aind_behavior_gym.dynamic_foraging.agent.base.DynamicForagingAgentBase(seed=None)[source]

Bases: object

Generic agent class for dynamic foraging

act(observation)[source]

Chooses an action based on the current observation.

Parameters:

observation – The current observation from the environment.

Returns:

The action chosen by the agent.

Return type:

action

fit(data)[source]

Fit the parameters of the agent to data.

Parameters:

data – Either from animal data (model fitting) or simulated data (model recovery)

learn(observation, action, reward, next_observation, done)[source]

Updates the agent’s knowledge or policy based on the last action and its outcome.

This is the core method that should be implemented by all non-trivial agents. It could be Q-learning, policy gradients, neural networks, etc.

Parameters:
  • observation – The observation before the action was taken.

  • action – The action taken by the agent.

  • reward – The reward received after taking the action.

  • next_observation – The next observation after the action.

  • done – Whether the episode has ended.

load(filepath)[source]

Loads the agent’s state or learned parameters from a file.

Parameters:

filepath (str) – The path to the file from which the agent’s state will be loaded.

perform(task: DynamicForagingTaskBase)[source]

Perform one session (eposide) of the dynamic foraging task while learning.

reset()[source]

Resets the agent’s internal state. Override this if your agent has an internal state.

save(filepath)[source]

Saves the agent’s current state or learned parameters to a file.

Parameters:

filepath (str) – The path to the file where the agent’s state will be saved.

aind_behavior_gym.dynamic_foraging.agent.random_agent module

A Random agent

class aind_behavior_gym.dynamic_foraging.agent.random_agent.RandomAgent(seed=None)[source]

Bases: DynamicForagingAgentBase

A Random agent

act(observation)[source]

Simply random choose in the action space

learn(observation, action, reward, next_observation, done)[source]

No learning for a random agent

class aind_behavior_gym.dynamic_foraging.agent.random_agent.RandomAgentBiasedIgnore(seed=None)[source]

Bases: RandomAgent

A biased agent with ignores

act(*args)[source]

Random choose from three actions

Module contents

Agent module