agentframework module

class agentframework.Agent(env, agents, x, y)

Bases: object

An Agent takes a random walk through a two-dimensional environment.

environment

The environment in which the Agent is moving. A list of equal-length lists of integers.

env_height

The height of the environment.

env_width

The width of the environment.

y

Integer. The Agent’s y-coordinate within the environment.

x

Integer. The Agent’s x-coordinate within the environment.

distance_between(agent)

Find Euclidean distance between this Agent and another Agent.

Parameters:agent – Another Agent.
eat()

Define an agent’s eating of resource from environment.

move()

Move agent with random unit-sized step in each of two dimensions.

class agentframework.Environment(file)

Bases: object

Transforms a CSV file into a 2-d environment with which an agent can interact.

env

A list of equal-length lists of integers representing grass in a field.

class agentframework.Fox(env, agents, x, y)

Bases: agentframework.Agent

TODO: A Fox is an Agent that hunts rabbits and eats them.

class agentframework.Rabbit(env, agents, x, y, lifespan)

Bases: agentframework.Agent

A Rabbit is an Agent that eats grass, reproduces, ages, and dies.

die()

When a Rabbit dies, it is removed from the list of living Rabbits.

eat()

A Rabbit eats just like an Agent, but dies if it runs out of energy.

get_older()

Rabbits age; and when their age exceeds their lifespan, they die.

mate(range)

Mature female rabbits become pregnant whenever male is in range, and then give birth after ten steps.

Parameters:range – Integer. Distance within which Rabbits mate.
move()

Rabbit moves just like an Agent, but uses energy to do so.