creatur-4.3.2: Framework for artificial life experiments.

Portabilityportable
Stabilityexperimental
Maintaineramy@nualeargais.ie
Safe HaskellNone

ALife.Creatur.Universe.Task

Description

Provides tasks that you can use with a daemon. These tasks handle reading and writing agents, which reduces the amount of code you need to write.

It’s also easy to write your own tasks, using these as a guide.)

Synopsis

Documentation

type AgentProgram c l d n x a s = a -> StateT (Universe c l d n x a) IO (a, Maybe s)Source

A program for an agent which doesn't interact with other agents. The input parameter is the agent whose turn it is to use the CPU. The program must return the agent (which may have been modified), along with any data (e.g., statistics) to be used by the summary program.

type AgentsProgram c l d n x a s = [a] -> StateT (Universe c l d n x a) IO ([a], Maybe s)Source

A program which allows an agent to interact with one or more of its neighbours.

The input parameter is a list of agents. The first agent in the list is the agent whose turn it is to use the CPU. The rest of the list contains agents it could interact with. For example, if agents reproduce sexually, the program might check if the first agent in the list is female, and the second one is male, and if so, mate them to produce offspring. The input list is generated in a way that guarantees that every possible sequence of agents has an equal chance of occurring.

The program must return a list of agents that it has modified, along with any data (e.g., statistics) to be used by the summary program. The order of the output list is not important.

type SummaryProgram c l d n x a s = [s] -> StateT (Universe c l d n x a) IO ()Source

A program that processes the outputs from all the agent programs. For example, this program might aggregate the statistics and record the result.

withAgent :: (Clock c, Logger l, Database d, Agent a, Serialize a, Record a, a ~ DBRecord d) => AgentProgram c l d n x a s -> AgentId -> StateT (Universe c l d n x a) IO (Maybe s)Source

withAgents :: (Clock c, Logger l, Database d, Agent a, Serialize a, Record a, a ~ DBRecord d) => AgentsProgram c l d n x a s -> [AgentId] -> StateT (Universe c l d n x a) IO (Maybe s)Source

runNoninteractingAgents :: (Clock c, Logger l, Database d, Agent a, Serialize a, Record a, a ~ DBRecord d) => AgentProgram c l d n x a s -> SummaryProgram c l d n x a s -> StateT (Universe c l d n x a) IO ()Source

runInteractingAgents :: (Clock c, Logger l, Database d, Agent a, Serialize a, Record a, a ~ DBRecord d) => AgentsProgram c l d n x a s -> SummaryProgram c l d n x a s -> StateT (Universe c l d n x a) IO ()Source