Portability | portable |
---|---|
Stability | experimental |
Maintainer | amy@nualeargais.ie |
Safe Haskell | None |
Provides a habitat for artificial life.
- class (Clock (Clock u), Logger (Logger u), Database (AgentDB u), AgentNamer (AgentNamer u), Checklist (Checklist u), Agent (Agent u), Record (Agent u), Agent u ~ DBRecord (AgentDB u)) => Universe u where
- type Agent u
- type Clock u
- type Logger u
- type AgentDB u
- type AgentNamer u
- type Checklist u
- clock :: u -> Clock u
- setClock :: u -> Clock u -> u
- logger :: u -> Logger u
- setLogger :: u -> Logger u -> u
- agentDB :: u -> AgentDB u
- setAgentDB :: u -> AgentDB u -> u
- agentNamer :: u -> AgentNamer u
- setAgentNamer :: u -> AgentNamer u -> u
- checklist :: u -> Checklist u
- setChecklist :: u -> Checklist u -> u
- data SimpleUniverse a
- mkSimpleUniverse :: String -> FilePath -> Int -> SimpleUniverse a
- currentTime :: Universe u => StateT u IO Time
- incTime :: Universe u => StateT u IO ()
- writeToLog :: Universe u => String -> StateT u IO ()
- agentIds :: Universe u => StateT u IO [AgentId]
- archivedAgentIds :: Universe u => StateT u IO [AgentId]
- popSize :: Universe u => StateT u IO Int
- getAgent :: (Universe u, Serialize (Agent u)) => AgentId -> StateT u IO (Either String (Agent u))
- getAgentFromArchive :: (Universe u, Serialize (Agent u)) => AgentId -> StateT u IO (Either String (Agent u))
- getAgents :: (Universe u, Serialize (Agent u)) => [AgentId] -> StateT u IO (Either String [Agent u])
- store :: (Universe u, Serialize (Agent u)) => Agent u -> StateT u IO ()
- genName :: Universe u => StateT u IO AgentId
- type AgentProgram u = Agent u -> StateT u IO (Agent u)
- withAgent :: (Universe u, Serialize (Agent u)) => AgentProgram u -> AgentId -> StateT u IO ()
- type AgentsProgram u = [Agent u] -> StateT u IO [Agent u]
- withAgents :: (Universe u, Serialize (Agent u)) => AgentsProgram u -> [AgentId] -> StateT u IO ()
- isNew :: Universe u => AgentId -> StateT u IO Bool
- lineup :: Universe u => StateT u IO [AgentId]
- endOfRound :: Universe u => StateT u IO Bool
- refresh :: Universe u => StateT u IO ()
- markDone :: Universe u => AgentId -> StateT u IO ()
Constructors
class (Clock (Clock u), Logger (Logger u), Database (AgentDB u), AgentNamer (AgentNamer u), Checklist (Checklist u), Agent (Agent u), Record (Agent u), Agent u ~ DBRecord (AgentDB u)) => Universe u whereSource
A habitat containing artificial life.
type AgentNamer u Source
setClock :: u -> Clock u -> uSource
setLogger :: u -> Logger u -> uSource
agentDB :: u -> AgentDB uSource
setAgentDB :: u -> AgentDB u -> uSource
agentNamer :: u -> AgentNamer uSource
setAgentNamer :: u -> AgentNamer u -> uSource
checklist :: u -> Checklist uSource
setChecklist :: u -> Checklist u -> uSource
(Agent a, Serialize a) => Universe (SimpleUniverse a) |
data SimpleUniverse a Source
(Agent a, Serialize a) => Universe (SimpleUniverse a) |
mkSimpleUniverse :: String -> FilePath -> Int -> SimpleUniverse aSource
Clock
Logging
writeToLog :: Universe u => String -> StateT u IO ()Source
Write a message to the log file for this universe.
Database
archivedAgentIds :: Universe u => StateT u IO [AgentId]Source
Returns the list of (dead) agents in the archive.
getAgent :: (Universe u, Serialize (Agent u)) => AgentId -> StateT u IO (Either String (Agent u))Source
getAgentFromArchive :: (Universe u, Serialize (Agent u)) => AgentId -> StateT u IO (Either String (Agent u))Source
Fetches the agent with the specified ID from the archive.
getAgents :: (Universe u, Serialize (Agent u)) => [AgentId] -> StateT u IO (Either String [Agent u])Source
Fetches the agents with the specified IDs from the population.
store :: (Universe u, Serialize (Agent u)) => Agent u -> StateT u IO ()Source
If the agent is alive, adds it to the population (replacing the the previous copy of that agent, if any). If the agent is dead, places it in the archive.
Names
Agent programs
type AgentProgram u = Agent u -> StateT u IO (Agent u)Source
A program involving one agent. The input parameter is the agent. The program must return the agent (which may have been modified).
withAgent :: (Universe u, Serialize (Agent u)) => AgentProgram u -> AgentId -> StateT u IO ()Source
Run a program involving one agent
type AgentsProgram u = [Agent u] -> StateT u IO [Agent u]Source
A program involving multiple agents. The input parameter is a list of agents. The program must return a list of agents that have been *modified*. The order of the output list is not important.
withAgents :: (Universe u, Serialize (Agent u)) => AgentsProgram u -> [AgentId] -> StateT u IO ()Source
Agent rotation
lineup :: Universe u => StateT u IO [AgentId]Source
Returns the current lineup of (living) agents in the universe.
Note: Check for
and call endOfRound
if needed
before invoking this function.
refresh
endOfRound :: Universe u => StateT u IO BoolSource
Returns true if the lineup is empty or if all of the agents in the lineup have had their turn at the CPU.