\documentclass[12pt,fleqn,a4paper]{report}
\usepackage{amsfonts}
\usepackage{latexsym}
\usepackage{xspace}
\usepackage{epsfig}
\usepackage{graphicx}

\textheight     680pt
\textwidth      460pt
\topmargin      -40pt
\oddsidemargin    5pt
\evensidemargin   5pt
\parindent        0pt

\begin{titlepage}

\title{\textbf{ALGAE}\\Programmierpraktikum II SS 2000}

\author{\textbf{Clemens Bauer}\\\textit{cbauer@cosy.sbg.ac.at}
\\\textbf{Peter Eisenmann}\\\textit{peisen@cosy.sbg.ac.at}
\\\textbf{Thomas Frommwald}\\\textit{tfromm@cosy.sbg.ac.at}
\\\textbf{Daniel Kadir}\\\textit{dkadir@cosy.sbg.ac.at}
\\\textbf{Michael Liedlgruber}\\\textit{mliedl@cosy.sbg.ac.at}
\\
\\
\\Project manager: Roland Schwaiger}


\end{titlepage}

\begin{document}
\maketitle

\begin{abstract}

In our project for the course \textit{Programmierpraktikum II} we simulate a multiple agent system. The agents are algaes which live in an aquarium. They are controlled via an artificial neural network that determines the actions of the agent based on the inputs it gets through the sensors an agent is equipped with.\\
Agents may reproduce either sexually or a-sexually, and we got a certain mutation rate so the descendants are not exactly like their parent.\\
 Agents are able to spread pheromones to attract partners. Actions reduce the energy level of an agent, so it has to regain life force either through photo-synthesis or by consuming nutrition substrate. A light source resides on top of the aquarium and most of the substrate is at the bottom.

\end{abstract}


\tableofcontents

\chapter{Introduction}

ALGAE is a followup system of elc (evolution, learning and communication), which is an implementation of a multi agent system (MAS) conceptualized and implemented by Roland Schwaiger and Konrad Lang.  They investigate the evolution of wandering behavior of simple, reactive agents in a highly dynamic environment.  Those simple agents wander based on the outcomes of feed forward ANNs (multi layer perceptrons).\\
The world where our simulation will take place is an two-dimensional aquarium. On the top resides a uniform light source and at the bottom there is some nutrition substrate. Algae (agents) live in the world between. They move around consuming light and substrate (to regain energy), and may produce pheromones to find reproduction partners. The reproduction cycle takes place either sexual through meiosis or a-sexual through mitosis. There is a certain mutation rate when new agents are ``produced''.\\
All actions an agent can perform except photosynthesis and substrate accomodation reduce the agent's energy level. Once it reaches zero, the agent dies.
\\ \\ 
The simulation may be configured in every detail by the user before it is started, and a huge amount of statistics is provided once a simulation ends.

\chapter{Explanation of used symbols}

\section{Simulation}

\begin{itemize}
\item $d$ Duration of the simulation in time-steps
\item $worldx, worldy$ Horizontal and vertical dimensions of the aquarium
\item $state_L$ Light state - \texttt{all the time, never, function.}
\item $i_L$ Light intensity at light source position
\item $d_L$ Light distribution function
\item $c_L$ Light cycle function
\item $a_S$ Total initial substrate amount
\item $d_S$ Substrate distribution function
\item $ren_S$ Substrate renewal rate
\item $dec_P$ Amount of time a pheromone particle will exist
\item $t$ Timestep
\end{itemize}


\section{Algaes}

\begin{itemize}
\item $ini_a$ Initial number of algaes
\item $ini_e$ Initial energy of an agent
\item $\tau$ Transparency factor of algaes
\item $a$ An agent
\item $e$ Actual energy level of $a$
\item $x$, $y$ Position of $a$
\item $C$ An agent's chromosome
\item $m$ \textit{Modified Miller Matrix}, used for the ANN
\end{itemize}


\subsection{Sensors}
\begin{itemize}
\item $f_P$ Field of view of pheromone sensor (in degrees)
\item $r_P$ Range of pheromone sensor (in world units)
\item $f_L$ Field of view of light sensor
\item $r_L$ Range of light sensor
\item $f_S$ Field of view of substrate sensor
\item $r_S$ Range of substrate sensor
\item $f_B$ Field of view of bumper sensor
\item $r_B$ Range of bumper sensor
\end{itemize}


\subsection{Actions}

\begin{itemize}
\item $e_M$ Necessary energy for movement
\item $e_I$ Energylevel necessary for mitosis
\item $e_E$ Energylevel necessary for meiosis
\item $e_P$ Energy used for pheromone output
\item $e_S$ Amount of energy gathered by consuming substrate
\item $e_L$ Amount of energy gathered by photosynthesis (at standard light intensity)

\end{itemize}


\chapter{World of ALGAE}


\section{The Simulation}
Our task is to provide a simulation environment that sets the input to the ANN and performs the actions, shown by the graphical output. It also should take care of reproduction methods and the death of an agent when out of energy.  At last the simulation should be visualized.\\
At the beginning a certain amount of agents is randomly initialized.  This includes the position and the heading as well as the neural network associated with each agent.  This is the point, where the aquarium (the concrete matrix) gets initialized too.  This includes the substrate distribution and the light, which are both set to a starting value.  The pheromone level is set to zero at each point in the matrix.\\
After this global initialization, the main simulation loop is started.  In that loop each agent performs some actions, which result from influences of its neighborhood.\\

\section{Aquarium}

\begin{figure}[hbt]
\centerline{\epsfxsize=10cm   
\epsfbox{./aquarium.xfig.eps}}   
\caption{The world where our simulation takes place.}
\label{}
\end{figure}

The aquarium has a two dimensional extension, specified by $(worldx, worldy)$. The borders on the left and right have a transparency factor of zero, i.e. no light may shine through the borders.

\section{World}
Basically, the ``world'' is responsible for controlling the experiment, some of its tasks are:
\begin{enumerate}
\item Set the output of the experiment in the GUI, i.e. show the agent, light distribution, substrate distribution, show details of the agents, s.a. energy level, genotype, phenotype.
\item Perform all calculations from one time-step $t_i$ to time-step $t_{i+1}$, new agent positions\footnote{The agents perform their steps and request from the world their new positions, since only the world knows about the positions of the other agents. Furthermore, just the world knows about the concentrations (light, substrate, pheromone).}, set sensor values of the agents\footnote{This has to happen in the first phase of interval $[t_i,t_{i+1}]$ since all further actions of the agents rely on the sensors values.}   
\item Insert new agents in the world once reproduction has taken place.
\item Remove agents with $e$ of zero (or below).
\end{enumerate}


\section{Light and Substrate}

The light source is completely uniform, rays are sent from top to bottom in a straight line. The light source can be set to simulate a day/night cycle or another function, but may also be set to a specific value during the simulation, or even turned off completely by the user. Light has a higher intensity at the top of the aquarium than at the bottom. Per default,the intensity is modeled by the function 1/y, where y represents the vertical world axis, but an other function may be chosen by the user. \\
Agents reduce the light intensity for every spot below them, but they do not block the light completely due to a certain transparency value.
\\
Similarly conditions apply for the substrate which diffuses into the water. We only have a certain amount of substrate particles which difuse into the water over time. The distribution of substrate is based on a mathematical function. If a substrate particle is consummated, it is rebuilt after a specific amount of time, until the supply is used up completely. At bottom, substrate is rebuilt faster than above because the source resides there.\\ \\

Let us denote the light distribution by $d_L(x)$ and the substrate distribution by $d_S(x)$. An example for both distribution functions would be $d(x) = \frac{1}{x}$.

im Aquarium\begin{figure}[hbt]
\centerline{\epsfxsize=7cm   
\epsfbox{./substrate_distribution.xfig.eps}}   
\caption{The concentration and distribution of the substrate, according to $d_S(x) = x^2$.}
\label{ds}
\end{figure}

In figure~\ref{ds} the distribution of the substrate is given. In each location $(x,y)$ the substrate has concentration 1 or 0. Once a substrate is consumed by an agent the substrate will be rebuilt according to the given $d_S(x)$. In the given figure we have chosen $d_S(x) = y^2$, for $y = 3$ we get $d_S(3) = 9$ which are the time-steps the system needs to rebuild the substrate concentration\footnote{In a future release of the simulation the substrate concentration in $(x,y)$ only may be rebuilt if there is a substrate concentration in locations $\{(x,y') | \forall y': y' < y\}$}. 

Next let's consider the light distribution $d_L(x)$. Consider that an agent $a_i$ in spot $(x,y)$ blocks part of the light for all the agents $a_j$ in locations $(x,y'), y' < y$. The light intensity will degrade according to a certain transparency factor $\tau_i$ of agent $a_i$.  

\begin{figure}[hbt]
\centerline{\epsfxsize=14cm   
\epsfbox{./light_distribution.xfig.eps}}   
\caption{The concentration and distribution of the light, according to $d_L(x) = 1/x$.}
\label{dl}
\end{figure}

In order to model day and night in the simulation $d_L(x)$ may depend on the time. As an example consider the $\sin$ function, as seen in figure~\ref{dl}. Further the time dependent modeling of the substrate concentration may be considered. The light intensity can also be changed manually by the user during the simulation.


\section{Agents: Energy}
Every agent is ``born'' with the same amount of energy. Energy is used for every action the agent may perform. If the energy level $e$ reaches zero, the algae dies. Energy may be regained through photo-synthesis or substrate accomondation.
It should be stated out clearly that our agents do not have a fixed life span. They live as long as they got an amount of energy greater than zero.

\section{Agents: Sensors}

\begin{figure}[hbt]
\centerline{\epsfxsize=10cm   
\epsfbox{./sensors.xfig.eps}}   
\caption{The various sensors of agents $a_i$.}
\label{}
\end{figure}

To enable the agents to get information about their environment, we equip them with several sensors. An agent got four different sensors, where each points into the main directions forward, right, left and backward. Therefore, the agent gets 16 different sensor input (4 sensors * 4 directions) every time-step.\\
All sensors  have a certain field of view (FOV) and a specific range. Due to the fact the strength of the input values from the various positions of the sensor directions differ, the agent should be able to detect where the source of signal is.


\subsection{Light sensor}
This sensor gets the summed light intensity of its FOV within its range.

\subsection{Substrate sensor}
This sensor gets the value of the substrate particles in its FOV. The value each particle adds to the sensor input depends on its distance.

\subsection{Pheromone sensor}
This sensor delivers the pheromon density in its FOV (Pheromons are released by the agents in order to find reproduction partners). The value each particle adds to the sensor input depends on its distance.

\subsection{Bumper sensor}
This sensor detects obstacles (other agents or the world's border) around the algae.


\section{Agents: Actions}
An agent is able to perform an arbitrary amount of \textit{different} actions every time-step of the simulation. All of these actions consume/produce a specific amount of energy. Of course, the agent won't perform actions that would use a higher amount of energy than it currently has. 


\subsection{Movement}

\begin{figure}[hbt]
\centerline{\epsfxsize=7cm   
\epsfbox{./moving.xfig.eps}}   
\caption{The possible moving directions of agent $a_i$.}
\label{}
\end{figure}

Moving is probably the most important task an agent has to perform, in order to navigate to reproduction partners, towards substrate or higher light intensity. The agent may move one unit per time-step.\\
The agent always turns towards the new direction if necessary - it cannot make some kind of sidestep.

\subsection{Photo-synthesis}
One way for an agent to regain energy is photo-synthesis. The agent directly converts the light intensity at its current location into life energy. Higher light intensity produces a higher amount of energy.

\subsection{Substrate acommomdation}
If an agent is at the same location as a substrate particle, it consumes the particle and regains a specific amount of energy. The substrate is rebuilt after a certain number of time-steps, depending on its $y$ position.

\subsection{Reproduction}
If the energy level $e$ of an algae reaches a certain amount the algae may reproduce either sexually through meiosis or a-sexually (mitosis).

\begin{itemize}

\item{Meiosis, Pheromones}\\
Once an agent $a_i$ has collected enough energy points it may reach a critical limit $e_E$ for sexual reproduction. From that moment on the agent may produce pheromone in order to signal other agents its ability for sexual reproduction. The agent will release the pheromone in its actual location\footnote{In future releases of the simulation we may consider some distribution function for pheromone release in the neighborhood of the agent}. The pheromone will be apparent in the spot for a given amount of time-steps, let's denote the amount of time by $dec_P$.

For the case $e$ of an agent is higher than $e_E$ and therfore it may start producing pheromone, we discussed several possibilities:

\begin{enumerate}
\item To distinguish between the pheromones of different agents we may introduce two genders, male and female. The two genders release different kinds of pheromone. As can be seen easily, we reduce the probability of reproduction significantly.
\item Another way to consider pheromone of different agents we may intro two agent types. The first type just releases pheromone and the second agent type just senses pheromone. Apply the argument above.
\item If one agent releases pheromone and meets another agent it will force the agent to reproduce, no matter if the other agent has an energy level greater than $e_E$. There is no way for an agent to distingiush between its own or other pheromone.
\item Finally, we introduce a flag for pheromone for each agent. With this method we get the possibility to differentiate between the pheromone of the various agents. Unfortunately not a biological plausible proposal.
\end{enumerate}
In our simulation we will use on the third possibility: If one agent is willing to reproduce and meets another agent it will force the other one to reproduce, without taking care for the other's current energy level.

\item{Mitosis}\\
If an agent reaches an energy level $e_I$ before it finds a partner for meiosis, it can reproduce itself a-sexually through the way of mitosis. This means the agent parts itself so we get two nearly identical individuals (they do not have exactly the same genotype because there is a certain mutation rate).

\end{itemize}

\begin{figure}[hbt]
\centerline{\epsfxsize=7cm   
\epsfbox{./reproduction.xfig.eps}}   
\caption{Reproduction of the agents $a_i$ and $a_j$ .}
\label{}
\end{figure}


\section{Agents: Neural Network}

\begin{figure}[hbt]
\centerline{\epsfxsize=7cm   
\epsfbox{./ann.xfig.eps}}   
\caption{The ANN of agent $a_i$ .}
\label{}
\end{figure}

The various actions of an agent are partially determined by its mapping from input of the environment to output, i.e. reactions. This type of agent may be called reactive agent or stimulus/response agent. In our multi agent system we model this stimulus/response relationship by means of an artificial neural network -- multi layer perceptron -- (ANN). The input to the ANN consists of the sensor inputs and the $e$ of the agent. Various hidden layers are used to perform transformations of the signals. Finally at the output level the calculated moving directions are shown.

\begin{figure}[hbt]
\centerline{\epsfxsize=7cm   
\epsfbox{./ann_detail.xfig.eps}}   
\caption{The detail view of one neuron in the ANN.}
\label{ad}
\end{figure}

\section{Evolutionary Cycle and Reproduction}
As pointed out above we want to build our system based on the steady state approach, i.e. no generations are built and definite end is proposed but reproduction occurs on the fly. Basically all relevant information has to be encoded into various chromosomes (bit-strings). In our simulation we want to use three chromosomes per agent. The first chromosome $C_1$ encodes the topology (neurons and connections) of the ANN in a Modified Miller Matrix (MMM) manner. Basically the main diagonal of the connectivity matrix where an entry $m_{ii} = 1$ states that the neuron is present. Whereas entry $m_{ii} = 0$ states that the neuron is not present. If the entry is not in the main diagonal $m_{ij}$, where $i <> j$, then the entry states the existence of the connection from neuron $i$ to neuron $j$.

The second chromosome $C_2$ encodes the weights of the connections and the biases of the neurons, two Bytes are used for encoding. The third chromosome $C_3$ encodes the cubic splines, where each point of the spline is encoded with its $x$ and $y$ coordinate, two Bytes respectively. 

\begin{figure}[hbt]
\centerline{\epsfxsize=10cm   
\epsfbox{./reproduction_detail.xfig.eps}}   
\caption{The details for crossing over between chromosome $C_1$ of agent $a_i$ and $a_j$.}
\label{rd}
\end{figure}

In order to reproduce we have to consider two different cases, meiosis and mitosis. In figure~\ref{rd} we give an example for meiosis. In the mitosis case we duplicate the chromosomes and perform the same steps as in the meiosis case.


\chapter{ALGAE File Format Specifications}

\textbf{The formats in which information in ALGAE will be saved to disk.}

\section{Configuration files}

\subsection{Introduction}
The ALGAE-settings for different simulation environment presets are saved using the XML file-format.\\
This format was chosen because of the flexibility and the fact, that one doesn't have to read or edit any binary file-format. Therefore the files can easily be created or modified with any text editor. The restrictions within the creation or modification process of such a settings file are donated in the file \textit{ElementDefinitions.DTD}. This file holds some simple guidelines for creating or modifying the ALGAE-settings and shouldn't be changed unless the format is to be extended or modified.

\subsection{Section \texttt{Settings}}

The settings-block is the main section and holds all subsections with information about the initial simulation environment. This time only one Settings-block per file is used, but it is also possible for future development of the file-format to extend the format in such a way, that more than one settings-block could be stored in one file. \\
This time, for each preset (or initial ALGAE-settings) a separate file is created.
\newline

The Settings-block has the following attributes:

\begin{itemize}
\item Version - this attribute stores the file-format version
\item Creator - the program (editor) which created this file (in most cases this would be ALGAE itself)
\item Name - the name of the settings-file 
\item Date - date and time of file-creation (or file-modification) in the format DD.MM.YY HH:MM:SS
\end{itemize}

\newpage
7
\subsection{Section \texttt{Simulation}}

This section holds some general information about the initial state of a simulation.

\begin{itemize}
\item Duration $d$
\item Width $worldx$
\item Height $worldy$
\item Light\_enabled $state_L$, may be
	\subitem \texttt{all the time}
	\subitem \texttt{never}
	\subitem \texttt{function}
\item Light\_intensity $i_L$
\item Light\_distribution\_func $d_L$
\item Light\_cycle\_func $c_L$
\item Substrate\_amount $a_S$
\item Substrate\_renew\_rate $ren_S$
\item Pheromone\_dec\_rate $dec_P$
\end{itemize}

\subsection{Section \texttt{ALGAES}}

This section stores information about the algaes and their initial states.

\begin{itemize}
\item Initial\_algaes $ini_a$ 
\item Initial\_energy $ini_e$
\end{itemize}

\subsection{Section \texttt{Sensors}}

This section stores information about the algaes' sensors and their initial states.

\begin{itemize}
\item Pheromone\_fov $f_P$
\item Pheromone\_range $r_P$
\item Substrate\_fov $f_S$
\item Substrate\_range $r_S$
\item Light\_fov $f_L$
\item Light\_range $r_L$
\item Bumper\_fov $f_B$
\item Bumper\_range $r_B$
\end{itemize}

\subsection{Section \texttt{Action}}

The attributes of this section store information about the amount of energy which is used respective collected by specific actions.

\begin{itemize}
\item Energy\_movement $e_M$
\item Energy\_mitose $e_I$
\item Energy\_meiose $e_E$
\item Energy\_pheromone\_output $e_P$
\item Energy\_substrate $e_S$
\item Energy\_light $e_L$
\end{itemize}


\section{Statistic Files}

\subsection{Introduction}
An ALGAE statistics file stores very detailed informations about
a simulation process.\\
\textit{NOTE: Statistics are only written if the program was started in Batch-Mode.}

\subsection{File Structure}
\begin{itemize}

\item Section \texttt{Setting}
\subitem Subsection \texttt{Simulation}
\subitem Subsection \texttt{Agent \#0}
\subitem Subsection \texttt{Agent \#1}
\subitem    .
\subitem    .                 
\subitem Subsection \texttt{Agent \#n}

\item Section \texttt{Step 1}
\subitem Subsection \texttt{General Stats}
\subitem Subsection \texttt{Agent \#1}
\subitem Subsection \texttt{Agent \#2}
\subitem    .                
\subitem    .             
\subitem Subsection \texttt{Agent \#n}

\item Section \texttt{Step 2}
\subitem Subsection \texttt{General Stats}
\subitem Subsection \texttt{Agent \#1}
\subitem Subsection \texttt{Agent \#2}
\subitem    .                
\subitem    .             
\subitem Subsection \texttt{Agent \#n}

\item Section \texttt{Step n}
\subitem Subsection \texttt{General Stats}
\subitem Subsection \texttt{Agent \#1}
\subitem Subsection \texttt{Agent \#2}
\subitem    .
\subitem    .
\subitem Subsection \texttt{Agent \#n}

\item Section \texttt{Summary}
\subitem Subsection \texttt{General Stats}
\subitem Subsection \texttt{Agent \#0}
\subitem Subsection \texttt{Agent \#1}
\subitem    .
\subitem    .                       
\subitem Subsection \texttt{Agent \#n}
      

\end{itemize}

\textbf{Following: The different sections described more detailed}

\subsection{Section \texttt{Settings}}
This section stores most of the information defined in the settingsfile
used for the simulation which generated this statistics file.\\
These settings are stored in the following subsection:
  
\subsubsection{Subsection \texttt{Simulation}}
\begin{itemize}
\item steps $d$(Integer value)
\item random\_seed (Integer value) - This is the number which is used as an initialization value for 
      the random number generator. Since this number is used
      forthroughout the whole simulation, the simulation may be repeated
      again and again, with the same results every time)
\item world\_width $worldx$ (Integer value)
\item world\_height $worldy$ (Integer value)
\item neurons\_used (integer value) - Total number of neurons used in the ANNs of the agents
\item input\_neurons\_used (integer value) - Number of input neurons used for an ANN of an agent
      (this time the input values for an ANN of an agent are
      his energylevel and the 16 values of his sensors).
\item output\_neurons\_used (integer value) - Number of output neurons used for an ANN of an agent.
   
\item initial\_agents $ini_a$ (integer value)
\item initial\_energy $ini_e$ (float value)
\item substrate $a_S$ (integer value)
\item substrate\_renew\_rate $ren_S$ (float value)
\item pheromone\_decrease\_rate $dec_P$ (float value)
\item pheromone\_sensor\_fov $f_P$ (integer value)
\item pheromone\_sensor\_range $r_P$ (integer value)
\item substrate\_sensor\_fov $f_S$ (integer value)
\item substrate\_sensor\_range $r_S$ (integer value)
\item light\_sensor\_fov $f_L$ (integer value)
\item light\_sensor\_range $r_L$ (integer value)
\item bumper\_sensor\_range $r_B$ (integer value)
\end{itemize}

Additionally this section includes information for each agent, initialized at the startup of the simulation.\\
As a consequence this section stores $n$ subsections of the following type (where $n$ is the number of initial agents)

\subsubsection{Subsection \texttt{Agent \#i}}
\begin{itemize}
\item agent\_index (integer value) - This is the index of the index in the list of all agents
      in the simulation. 
\item position\_x $x$ (integer value)
\item position\_y $y$ (integer value)
\item energy\_level $e$ (float value) - This is the energy-level of an agent. In this section it's
      always the same value as initial\_energy $ini_e$ in the SUBSECTION SIMULATION since we see  the initial state of an agent here
\end{itemize}

\subsection{Section \texttt{Step i}}
A section of this type is stored for each step of the simulation. The following subsection is stored once per step and stores some
general information of step i.
\subsubsection{Subsection \texttt{General Stats}}
\begin{itemize}
\item agents\_alive (integer value)-  How many agents were alive at the current step
\item agents\_died (integer value) - How many agents died at this step
\item mitosis\_count (integer value) - How often mitose occured at this step (indicates the number of new born agents in this step, too, when taken in addition with meiosis\_count)
\item meiosis\_count (integer value) - How often did meiose occur in this step (indicates the number of new born agents in this step, too, when taken in addition with mitosis\_count)
\item light\_intensity $i_L$ (float value)
\item substrate\_amount $a_S$ (float value)
\item substrate\_consumed (integer value) - How much substrate was consumed by the agents during this step
\item substrate\_renewed (integer value) - How much substrate was renewed in this step
\item pheromone\_dissolved (integer value)- How many pheromone particles dissolved in this step
\item pheromone\_renewed (integer value) - How much pheromone was renewed in this step.
\item light\_consumed (integer value) - How much light was consumed by the agents during this step.
\end{itemize}


The following n sections of the following type store informations about the agents and their state in step i.\\
\textit{NOTE: Only information of living agents is stored here.}

\subsubsection{Subsection \texttt{Agent \#a}}

\begin{itemize}
\item agent\_index (integer value) - Same as in subsection Subsection \texttt{Agent \#i} in Section \texttt{Settings}
\item heading (integer value) - This value stores the direction, the agent is currently heading towards
\item position\_x $x$ (integer value), position\_y $y$ (integer value) - Same as in subsection \texttt{Agent \#i} in section \texttt{Settings}, but updated during actions made by the agent
\item energy\_level $e$ (integer value) - Same as in subsection \texttt{Agent \#i} in Section \texttt{Settings}, but updated during actions made by the agent.
\item ann\_output (integer value) - This value is the numer of the ``winner'' (e.g. the one with the highest value) neuron of the ANN. Respectively it's in most cases the same value as then heading (except for zero: the agent stands still, but shows into a direction not equal zero.
\item mitosis (boolean value) - Did the agent do mitosis during this step?
\item meiosis (boolean value) - Was the agent involved into meiose during this step?
\item used\_light (boolean value) - Did the agent consume light in this step?
\item used\_substrate (boolean value) - Did the agent consume substrate in this step?
\item birth (boolean value) - Was this the ``birthdate'' of the agent?
\item sensors\_values - These are the values for the agent's sensors in step i. They are stored in a single line. The values are stored in the following order:
	\subitem bumper sensor values - one float value per sensor (4 values)
	\subitem pheromone sensor values - one float value per sensor (4 values)
        \subitem substrate sensor values - one float value per sensor (4 values)
	\subitem light sensor values - one float value per sensor (4 values)
\end{itemize}

\subsection{Section \texttt{Summary}}
This section is a short summarization of the agents who lived and died during the simulation.\\
The first subsection stores some general information about the ALGAE population.

\subsubsection{Subsection \texttt{General Stats}}

\begin{itemize}
\item dead\_agents (integer value) - How many agents of the entire population died?
\item living\_agents (integer value) - How many agents of the entire population are still alive at the end of the simulation?
\end{itemize}

Then a short summary for each agent follows (it doesn't matter wether an agent is dead or alive, this list contains the whole population).\\
The list consists of n subsections, where n is the total number of agents born during the simulation.

\subsubsection{Subsection \texttt{Agent \#i}}
\begin{itemize}
\item alive (boolean value) - Indication whether the agent is dead or if he survived the whole simulation
\item birth\_step (integer value) - During which timestep the agent was born
\item alife\_steps (integer value) - This is the time the agent was alive
\item mitosis\_count (integer value) - This counter stores how often the agent initiated a mitose
\item meiosis\_count integer value) - This counter stores how often the agent was involved into a meiose
\item used\_light (float value) - How much light did the agent consume?
\item used\_substrate (float value) - How much substrate did the agent consume?
\item number\_of\_parents (integer value) - If the agent was initialized at the beginning of the simulation, this value is 0. Otherwise, if the agent was born during mitosis/meiosis this value is 1/2
\item parent\_1 (integer value) - This parameter is only stored, if the agent has at least one parent. In that case it specifies the first parent (in case of mitosis the one and only parent)
\item parent\_2 (integer value) - This parameter is only stored, if the agent has two parents. In that case it specifies the second parent (only used in case of meiosis)
\item number\_of\_children (integer value) - This value stores the number of children of agent i. If the agent never was involved into mitosis or meiosis, this number is zero
\item children\_list - This is a list of number\_of\_children integer values. It stores the index for each child of agent $a_i$. This list is only stored if number\_of\_children is greater than zer
\item phenotype\_miller\_matrix (2-dimensional array of integer values) - This is a 2-dimensional with a size of n*n, where n is the number of total neurons used in an ANN of an agent. Ir is stored in n lines with n values (1 or 0) per line
\item phenotype\_weight\_matrix  (2-dimensional array of float values) - This is a 2-dimensional with a size of n*n, where n is the number of total neurons used in the ANN of an agent. It is stored in n lines with n values per line
\item phenotype\_spline\_matrix (2-dimensional array of float values) - This is a 2-dimensional with a size of 2*n, where n is the number of x/y-pairs used for the cubic splines in the ANNs
\end{itemize}    


\chapter{Class Diagrams and Use Cases}

\textbf{We will discuss the classes and use cases our project will based upon in this chapter.}

\section{Package GUI}

\begin{center}
\includegraphics[width=16.0cm]{ovpackagegui.eps}
\end{center}

\textbf{This package represents every function that the program's user interface provides.}

\subsection{Class \texttt{CostumDialog}}

\begin{itemize}
\item Private Attribute \texttt{magicWord:String}
\item Private Attribute \texttt{retVal:Integer}
\item Private Attribute \texttt{typedText:String}
\item Method \texttt{actionPerformed(e:ActionEvent):Void}
\item Method \texttt{customDialog(aFrame:Frame,steps:Integer,parent:ContinueDlg)}
\item Method \texttt{getResult():integer}
\item Method \texttt{getValidatedText():String}
\item Method \texttt{propertyChange(e:PropertyChangeEvent):Void}
\item Method \texttt{windowClosing(we:WindowEvent):Void}
\end{itemize}


\subsection{Immutable Class \texttt{SettingsDialog}}

\begin{itemize}
\item Attribute \texttt{iAmReady:Boolean = false}
\item Package-Attribute \texttt{presets:String[] = \{"-----"\}}
\item Method \texttt{actionPerformed(e:ActionEvent):Void}
\item Method \texttt{addASFFilesToCombo():Void}
\item Method \texttt{AreYouReady():Boolean}
\item Method \texttt{dialogImportSettingsFile():Void}
\item Method \texttt{dm(s:String):Void}
\item Method \texttt{exportActionSettings(xmldoc:XmlDocument,XML>ElementNode):Void}
\item Method \texttt{exportAlgaesSettings(xmldoc:XmlDocument,XML:ElementNode):Void}
\item Method \texttt{exportSensorSettings (xmldoc:XmlDocument,XML:
:ElementNode):Void}
\item Method \texttt{exportSimulationSettings(xmlDoc:XmlDocument,XML:ElementNode):Void}
\item Method \texttt{exportSettingsFile():Void}
\item Method \texttt{getAqua():ImagePanel}
\item Method \texttt{getSettingsVar():Settings}
\item Method \texttt{importActionsSettings(xn:org.w3c.dom.Node):Void}
\item Method \texttt{importAlgaesSettings(xn:org.w3c.dom.Node):Void}
\item Method \texttt{importSensorSettings(xn:org.w3c.dom.Node):Void}
\item Method \texttt{importSimulationSettings(xn:org.w3c.dom.Node):Void}
\item Method \texttt{importSettingsFile(s:String):Void}
\item Method \texttt{isPreset(s:String):Boolean}
\item Method \texttt{makeActionsPanel():void}
\item Method \texttt{makeAlgaesPanel():Void}
\item Method \texttt{makeSensorsPanel():Void}
\item Method \texttt{makeSimulationPanel():Void}
\item Method \texttt{msgErr(S:String):Boolean}
\item Method \texttt{settingsDialog()}
\item Method \texttt{storeSettingsToVar():Settings}
\item Method \texttt{verifySettings():Boolean}
\item Method \texttt{windowClosing(e:WindowEvent):Void}
\end{itemize}

\subsection{Class \texttt{ImagePanel}}

\begin{itemize}
\item Package-Attribute \texttt{algeaPos:Integer = null}
\item Package-Attribute \texttt{doubleBuffer:Boolean = true}
\item Package-Attribute \texttt{drawGrid:Boolean = true}
\item Package-Attribute \texttt{firstTime:Boolean = true}
\item Package-Attribute \texttt{height:Integer}
\item Package-Attribute \texttt{lightPos:Integer = null}
\item Package-Attribute \texttt{pheroPos:Integer = null}
\item Package-Attribute \texttt{subsbstratePos:Integer = null}
\item Package-Attribute \texttt{mouseX:Integer = -1}
\item Package-Attribute \texttt{mouseY:Integer = -1}
\item Static Package-Attribute \texttt{scale:Float = 0.0f}
\item Static Package-Attribute \texttt{scaleHalf:Float = 0.0f}
\item Package-Attribute \texttt{selX:Integer = -1}
\item Package-Attribute \texttt{selY:Integer = -1}
\item Package-Attribute \texttt{selected:Integer = -1}
\item Package-Attribute \texttt{width:Integer}
\item Package-Attribute \texttt{x:Integer}
\item Package-Attribute \texttt{y:Integer}
\\
\item Method \texttt{clearAList():Void}
\item Method \texttt{clearLList():Void}
\item Method \texttt{clearPList():Void}
\item Method \texttt{clearSList():Void}
\item Method \texttt{getGridX():Integer}
\item Method \texttt{getGridY():Integer}
\item Method \texttt{imagePanel(par:MainGUI)}
\item Method \texttt{mouseClicked(e:MouseEvent):Void}
\item Method \texttt{mouseDragged(e:MouseEvent):Void}
\item Method \texttt{mouseEntered(e:MouseEvent):Void}
\item Method \texttt{mouseExited(e:MouseEvent):Void}
\item Method \texttt{mouseMoved(e:MouseEvent):Void}
\item Method \texttt{mousePressed(e:MouseEvent):Void}
\item Method \texttt{mousePressed(e:MouseEvent):Void}
\item Method \texttt{mouseRealeased(e:MouseEvent):Void}
\item Method \texttt{paintAlgae(marked:Integer,pos:Integer):Void}
\item Method \texttt{paintAll():Void}
\item Method \texttt{paintComponent(g:graphics):Void}
\item Method \texttt{paintGrid():Void}
\item Method \texttt{paintLight(pos:Integer):Void}
\item Method \texttt{paintPheromone(pos:Integer):Void}
\item Method \texttt{paintSubstrate(pos:Integer):Void}
\item Method \texttt{paintRefresh():Void}
\item Method \texttt{setAlgae(sel:Integer,pos:Integer):Void}
\item Method \texttt{setLight(pos:Integer):Void}
\item Method \texttt{setPheromones(pos:Integer):Void}
\item Method \texttt{setSubstrates(pos:Integer):Void}
\item Method \texttt{turnOnOffDB(dbswitch:Boolean):Void}
\item Method \texttt{turnOnOffGrid(gSwitch:Boolean):Void}
\item Method \texttt{update(g:Graphics):Void}
\end{itemize}

\subsection{Immutable Class \texttt{MainGUI}}

\begin{itemize}
\item Package-Attribute \texttt{alreadyDrawing:Boolean = false}
\item Package-Attribute \texttt{aquaScale:Float = 1.0f}
\item Package-Attribute \texttt{dispAlgaes:Boolean = true}
\item Package-Attribute \texttt{dispPhero:Boolean = true}
\item Package-Attribute \texttt{dispSubstrate:Boolean = true}
\item Package-Attribute \texttt{drawGrid:Boolean = true}
\item Package-Attribute \texttt{drawing:Boolean = true}
\item Package-Attribute \texttt{first:Boolean = true}
\item Package-Attribute \texttt{running:Boolean = false}
\item Attribute \texttt{selection:Integer = -1}
\item Package-Attribute \texttt{simuPaused:Boolean = false}
\item Package-Attribute \texttt{simulationDelay:Integer = stepping-1}
\item Package-Attribute \texttt{stepCount:Integer = 1}
\item Package-Attribute \texttt{stepping:Integer = 1}
\item Package-Attribute \texttt{x:Integer = 0}
\item Package-Attribute \texttt{y:Integer = 0}
\\
\item Method \texttt{actionPerformed(e:ActionEven):Void}
\item Method \texttt{addCBS():Void}
\item Method \texttt{addCanvas():Void}
\item Method \texttt{addMenuItems{}:Void}
\item Method \texttt{addSliders():Void}
\item Method \texttt{addToolBar():Void}
\item Method \texttt{addToolBarButtons():Void}
\item Method \texttt{likeToContinue(doneSteps:Integer):Integer}
\item Method \texttt{mainGUI(set:Settings)}
\item Method \texttt{paintAll(w:WorldState,onlyStatus:Boolean):Void}
\item Method \texttt{paused():Boolean}
\item Method \texttt{selected():Integer}
\item Method \texttt{setNewAreaDimensions():Void}
\item Method \texttt{setState(stat:String):Void}
\item Method \texttt{setStatus(stat:String,light:Float,subAm:Float,numAlg:Integer,step:Integer,stepsToDo:Integer):Void}
\item Method \texttt{setupGUI():Void}
\item Method \texttt{stopped():Boolean}
\item Method \texttt{viewAlgae():Boolean}
\item Method \texttt{viewPheromone():Boolean}
\item Method \texttt{viewSubstrate():Boolean}
\item Method \texttt{windowClosing(e:WindowEvent):Void}
\end{itemize}

\subsection{Immutable Class \texttt{SliderListener}}

\begin{itemize}
\item Method \texttt{stateChanged(e:ChangeEvent):Void}
\end{itemize}

\subsection{Immutable Class \texttt{ContinueDlg}}

\begin{itemize}
\item Method \texttt{continueDlg(frame:JFrame,donwSteps:Integer)}
\item Method \texttt{getEnteredValue():Integer}
\end{itemize}

\subsection{Immutable Class \texttt{HelpWin}}

\begin{itemize}
\item Method \texttt{actionPerformed(e:ActionEvent):Void}
\item Method \texttt{helpWin(s:String)}
\item Method \texttt{windowClosing(e:WindowEvent):Void}
\end{itemize}

\subsection{Immutable Class \texttt{HtmlPanel}}

\begin{itemize}
\item Method \texttt{htmlPanel(fileName:String)}
\item Method \texttt{hyperLinkUpdate(e:HyperlinkEvent):Void}
\item Protected Method \texttt{linkActivated(u:URL):Void}
\end{itemize}

\subsection{Immutable Class \texttt{XMLFileFilter}}

\begin{itemize}
\item Method \texttt{accept(f:File):Boolean}
\item Method \texttt{getDescription():String}
\end{itemize}

\subsection{Immutable Class \texttt{InfoWin}}

\begin{itemize}
\item Method \texttt{actionPerformed(e:ActionEvent):Void}
\item Method \texttt{clearValues():Void}
\item Method \texttt{infoWin()}
\item Method \texttt{setValues(val:Float,sel:Integer):Void}
\item Method \texttt{windowClosing(e:WindowEvent):Void}
\end{itemize}



\section{Package Simulation}

\begin{center}
\includegraphics[width=16.0cm]{ovpackagesim.eps}
\end{center}

\subsection{Class \texttt{Settings}}

\begin{itemize}
\item Attribute \texttt{duration:Integer}
\item Attribute \texttt{width:Integer}
\item Attribute \texttt{height:Integer}
\item Attribute \texttt{initial\_algaes:Integer}
\item Attribute \texttt{initial\_energy:Float}
\item Attribute \texttt{light\_cycle\_function:Integer}
\item Attribute \texttt{light\_enabled:Integer}
\item Attribute \texttt{light\_function:Integer}
\item Attribute \texttt{light\_intensity:Integer}
\item Attribute \texttt{pheromone\_dec\_rate:integer}
\item Attribute \texttt{substrate\_amount:Integer}
\item Attribute \texttt{substrate\_renew\_rate:Float}
\item Attribute \texttt{energy\_light:Float}
\item Attribute \texttt{energy\_mitose:Float}
\item Attribute \texttt{energy\_meiose:Float}
\item Attribute \texttt{energy\_movement:Float}
\item Attribute \texttt{energy\_pheromone\_output:Float}
\item Attribute \texttt{energy\_substrate:Float}
\item Attribute \texttt{light\_fov:Integer}
\item Attribute \texttt{light\_range:Integer}
\item Attribute \texttt{pheromone\_fov:Integer}
\item Attribute \texttt{pheromone\_range:Integer}
\item Attribute \texttt{substrate\_fov:Integer}
\item Attribute \texttt{substrate\_range:Integer}
\item Attribute \texttt{bumper\_range:Integer}\\
\item Attribute \texttt{randSeed:Integer}
\end{itemize}


\subsection{Immutable Class \texttt{GUIWC}}

\begin{itemize}
\item Method \texttt{gUIWC(simulationSettings:Settings,p:MainGUI)}
\item Method \texttt{getAgentAt(px:Integer,py:Integer):Integer}
\item Method \texttt{getAgentInfos(n:Integer):Float[]}
\item Method \texttt{getLightAt(px:Integer,py:Integer):Float}
\item Method \texttt{getPheromoneAt(px:Integer,py:Integer):Float}
\item Method \texttt{getState():WorldState}
\item Method \texttt{getSubstrateAt(px:Integer,py:Integer):Float}
\item Method \texttt{run():WorldState}
\end{itemize}

\subsection{Class \texttt{WC}}

\begin{itemize}
\item Attribute \texttt{stepsRunning:Integer = 0}
\item Attribute \texttt{stepsToRun:Integer = 0}
\item Method \texttt{finish():Void}
\item Method \texttt{step():Void}
\item Method \texttt{WC(set:Settings)}
\end{itemize}

\subsection{Immutable Class \texttt{BatchWC}}

\begin{itemize}
\item Attribute \texttt{fileName:String}
\item Package-Attribute \texttt{Initialized:Boolean = false}
\item Method \texttt{batchWC(set:Settings,fn:String)}
\item Method \texttt{run():Void}
\end{itemize}

\subsection{Class \texttt{WorldState}}

\begin{itemize}
\item Attribute \texttt{dimx:Integer}
\item Attribute \texttt{dimy:Integer}
\item Attribute \texttt{lightIntensity:Float}
\item Attribute \texttt{pList:ViewPheromone[]}
\item Attribute \texttt{steps:Integer}
\item Attribute \texttt{stepsToRun:Integer}
\item Attribute \texttt{substrateAmount:Float}
\item Method \texttt{worldState(wc:WC)}
\end{itemize}

\subsection{Immutable Class \texttt{SimulationStats}}

\begin{itemize}
\item Package-Attribute \texttt{fileName:String}
\item Attribute \texttt{openStream(set:Settings,agw:AgentWorld):Boolean}
\item Attribute \texttt{closeStream():Boolean}
\item Attribute \texttt{simulationStats(s:String)}
\item Attribute \texttt{writeStats(stepNo:Integer):Boolean}
\end{itemize}

\section{Package Agents}

\begin{center}
\includegraphics{ovpackageagents.eps}
\end{center}

\textbf{With this package, the core of the program is built: The agents and their neural networks.}

\subsection{Immutable Class \texttt{Agent}}

\begin{itemize}
\item Attribute \texttt{ann\_output:integer = 0}
\item Attribute \texttt{born:Boolean = false}
\item Attribute \texttt{dead:Boolean = false}
\item Attribute \texttt{died:Boolean = false}
\item Attribute \texttt{dir:integer}
\item Attribute \texttt{energy\_level:Float = 0.0}
\item Attribute \texttt{madeMeiosis:Boolean = false}
\item Attribute \texttt{madeMitosis:Boolean = false}
\item Attribute \texttt{sensor\_values:Float[] = new float[SENSORCOUNT]}
\item Attribute \texttt{usedLight:Boolean = false}
\item Attribute \texttt{usedSubstrate:Boolean = false}
\item Attribute \texttt{x:Integer}
\item Attribute \texttt{y:Integer}
\item Method \texttt{agent(a:Agent,b:Agent,crossOverRate:Float,mutationRate:Float,\\c:Settings,rand:Random)}
\item Method \texttt{agent(a:Agent,mutationRate;Float,c:settings,rand:Random)}
\item Method \texttt{agent( sx:Integer,sy;Integer,c:Settings,rand:Random,aw:AgentWorld,\\sw:SubstrateWorld,pw:PheromonWorld,lw;LightWorld)}
\item Method \texttt{calcStep():Integer}
\item Method \texttt{getInfos():Float[]}
\item Method \texttt{isAlive():Boolean}
\end{itemize}


\subsection{Immutable Class \texttt{AgentSensor}}

\begin{itemize}
\item Attribute \texttt{fov:Integer}
\item Attribute \texttt{range:Integer}
\item Method \texttt{agentSensor(c:Settings,iRange:Integer,iFov:Integer)}
\item Method \texttt{getValuesA(x:Integer,y:Integer,w:AgentWorld):float[]}
\item Method \texttt{getValuesL(x:Integer,y:Integer,w:LightWorld):float[]}
\item Method \texttt{getValuesP(x:Integer,y:Integer,w:PheromoneWorldWorld):float[]}
\item Method \texttt{getValuesS(x:Integer,y:Integer,w:SubstrateWorld):float[]}
\item Method \texttt{inBounds(x:Integer,y:Integer):Boolean}
\end{itemize}

\subsection{Immutable Class \texttt{Phenotype}}

\begin{itemize}
\item Package-Attribute \texttt{hiddenCount:Integer}
\item Package-Attribute \texttt{inOutCount:Integer}
\item Attribute \texttt{inCount:Integer}
\item Attribute \texttt{nCount:Integer}
\item Attribute \texttt{neuronOutput:Float}
\item Attribute \texttt{neuron\_matrix:Integer}
\item Attribute \texttt{outCount:Integer}
\item Attribute \texttt{spline\_matrix:Float}
\item Attribute \texttt{visited:Boolean}
\item Attribute \texttt{weight\_matrix:Float}
\item Method \texttt{calculateNeuron(n:Integer):Float}
\item Method \texttt{connected(i:integer,j:integer):Boolean}
\item Method \texttt{getPrev(n:Integer):Integer}
\item Method \texttt{getPrevNum(n:Integer):Integer}
\item Method \texttt{phenotype(g:Genotype)}
\item Method \texttt{printNeuronMatrix():Void}
\item Method \texttt{printoutput():Void}
\item Method \texttt{printWeightMatrix():Void}
\item Method \texttt{processNet(inVec:Float):Integer}
\item Method \texttt{transferFunc(funcSel:Integer,val:Float):Float}
\end{itemize}


\subsection{Immutable Class \texttt{GenoType}}

\begin{itemize}
\item Package-Attribute \texttt{crippled:Integer}
\item Package-Attribute \texttt{randSeed:Integer}
\item Method \texttt{crippleness():Integer}
\item Method \texttt{crossOver(a:GenoType,b:Genotype,corssOverRate:Float,\\mutationRate:Float):Void}
\item Method \texttt{float2IEEE(f:Float):Bitset}
\item Method \texttt{iEEE2float(f:BitSet):Float}
\item Method \texttt{genoType(rs:Integer)}
\item Method \texttt{genoType(rs:Integer,a;GenoType,b:genotype,crossOverRate:Float,\\mutationRate:Float)}
\item Method \texttt{genoType(rs:Integer,a:GenoType,mutationRate:Float)}
\item Method \texttt{getFloatOuttaSm(idx:Integer):Float}
\item Method \texttt{getFloatOuttaWm(idx:Integer):Float}
\item Method \texttt{initRandomNm():Void}
\item Method \texttt{initRandomSm():Void}
\item Method \texttt{initRandomWm():Void}
\item Method \texttt{isCrippled():Boolean}
\item Method \texttt{mutate(mutationRate:Float):Void}
\item Method \texttt{putFloatIntoSm(idx:Integer,f:Float):Void}
\item Method \texttt{putFloatIntoWm(idx:Integer,f:Float):Void}
\item Method \texttt{showIEEE(f:BitSet):Void}
\item Method \texttt{showIEEE32(b:BitSet):Void}
\end{itemize}

\subsection{Immutable Class \texttt{CubicSpline}}

\begin{itemize}
\item Package-Attribute \texttt{nPoints:Integer}
\item Protected Method \texttt{cubicSpline(n:Integer,px:Vector,py:Vector)}
\item Method \texttt{getValue(px:Double):Double}
\end{itemize}


\section{Package Worlds}
 
\textbf{The world where our simulation takes place is built with these classes.}

\begin{center}
\includegraphics[width=16.0cm]{ovpackageworlds.eps}
\end{center}

\subsection{Class \texttt{SubstrateWorld}}

\begin{itemize}
\item Attribute \texttt{amount:Double}
\item Method \texttt{getList():ViewSubstrate[]}
\item Method \texttt{getSubstrateAmount():Double}
\item Method \texttt{step(step:Integer):Void}
\item Method \texttt{substrateWorld(set:Settings)}
\end{itemize}

\subsection{Class \texttt{LightWorld}}

\begin{itemize}
\item Attribute \texttt{intensity:Double}
\item Method \texttt{consume(x:Integer,y:integer):Double}
\item Method \texttt{getList():ViewLight[]}
\item Method \texttt{lightWorld(set:Settings)}
\item Method \texttt{setAgentWorld(aWorld:AgentWorld):Void}
\item Method \texttt{step(step:Integer):Void}
\item Method \texttt{update(fromX:Integer,fromY:Integer):Void}
\item Method \texttt{update (fromX:Integer,fromY:Integer,toX:Integer,toY:Integer):Void}
\end{itemize}


\subsection{Class \texttt{PheromoneWorld}}

\begin{itemize}
\item Method \texttt{getList():ViewPheromone[]}
\item Method \texttt{pheromoneWorld(set:Settings)}
\item Method \texttt{set(x:integer,y:Integer)}
\item Method \texttt{step(step:Integer):Void}
\end{itemize}


\subsection{Class \texttt{Element}}

\begin{itemize}
\item Attribute \texttt{x:Integer}
\item Attribute \texttt{y:Integer}
\item Method \texttt{add(s:Integer):Boolean}
\item Method \texttt{element(x:Integer,y:Integer)}
\item Method \texttt{exists():Boolean}
\item Method \texttt{remove(s:Integer):Boolean}
\item Protected Method \texttt{update():Boolean}
\end{itemize}


\subsection{Class \texttt{Element}}

\begin{itemize}
\item Attribute \texttt{stepsToResolve:Integer}
\item Method \texttt{add(steps:Integer):Boolean}
\item Method \texttt{element()}
\item Method \texttt{element(amount;Double,dec:Integer)}
\item Method \texttt{exists():Boolean}
\item Method \texttt{remove(steps:Integer):Boolean}
\item Protected Method \texttt{update():Boolean}
\end{itemize}

\subsection{Class \texttt{Element}}

\begin{itemize}
\item Attribute \texttt{stepsToGo:Integer}
\item Attribute \texttt{stepsToRegenerate:Integer}
\item Method \texttt{add(steps:Integer):Boolean}
\item Method \texttt{element()}
\item Method \texttt{element(amount;Double,dec:Integer)}
\item Method \texttt{exists():Boolean}
\item Method \texttt{remove(steps:Integer):Boolean}
\item Protected Method \texttt{update():Boolean}
\end{itemize}


\subsection{Class \texttt{Element}}

\begin{itemize}
\item Method \texttt{add(steps:Integer):Boolean}
\item Method \texttt{element()}
\item Method \texttt{exists():Boolean}
\item Method \texttt{remove(steps:Integer):Boolean}
\item Protected Method \texttt{update():Boolean}
\end{itemize}


\subsection{Class \texttt{Element}}

\begin{itemize}
\item Attribute \texttt{amount:Double}
\item Private Method \texttt{add(step:Integer):Boolean}
\item Method \texttt{element()}
\item Private Method \texttt{element()}
\item Private Method \texttt{exists():Boolean}
\item Protected Method \texttt{update():Boolean}
\item Method \texttt{value():Double}
\item Method \texttt{value(x:Integer,y:Integer):Double}
\end{itemize}

\subsection{Class \texttt{World}}

\begin{itemize}
\item Static Attribute \texttt{OUTOFWORLD:Double = 0.0}
\item Attribute \texttt{renew:Integer = 0}
\item Attribute \texttt{used:Integer = 0}
\item Abstract Method \texttt{step(step:Integer):Void}
\item Method \texttt{world()}
\item Method \texttt{world(y:Integer,x:Integer)}
\end{itemize}

\subsection{Immutable Class \texttt{AgentWorld}}

\begin{itemize}
\item Attribute \texttt{agentcount:Integer}
\item Attribute \texttt{mAX\_AGENTS:integer}
\item Attribute \texttt{stepDeadCount:Integer = 0}
\item Attribute \texttt{stepLightUsed:integer = 0}
\item Attribute \texttt{setpMeiosisCount:Integer = 0}
\item Attribute \texttt{stepMitosisCount:Integer = 0}
\item Attribute \texttt{stepPheromoneNew:integer = 0}
\item Attribute \texttt{stepPheromoneUsed:Integer = 0}
\item Attribute \texttt{stepSubstrateNew:Integer = 0}
\item Attribute \texttt{setpSubstrateUsed:Integer = 0}

\item Method \texttt{agentWorld(set:Settings,s:SubstrateWorld,p:PheromoneWorld,l:LightWorld):Boolean}
\item Method \texttt{aliveAgents():Integer}
\item Method \texttt{doPheromoneOutput(tmp:Agent):Integer}
\item Protected Method \texttt{findNeighbour(nOf:Integer,a:Agentempty:Boolean):Integer}
\item Method \texttt{getList():ViewAgent[]}
\item Method \texttt{initAgents():Void}
\item Method \texttt{move(tmp:Agent,sel:integer):Integer}
\item Method \texttt{step(steps:Integer):Void}
\end{itemize}


\section{Package \texttt{View}}

\begin{center}
\includegraphics{ovpackageview.eps}
\end{center}


\subsection{Class \texttt{ListElement}}

\begin{itemize}
\item Attribute \texttt{x:Integer}
\item Attribute \texttt{y:Integer}
\item Method \texttt{listElement(x:Integer,y:Integer)}
\end{itemize}

\subsection{Class \texttt{ViewListElement}}

\begin{itemize}
\item Attribute \texttt{x:Integer}
\item Attribute \texttt{y:Integer}
\item Method \texttt{viewListElement(x:Integer,y:Integer)}
\end{itemize}

\subsection{Class \texttt{ViewAgent}}

\begin{itemize}
\item Attribute \texttt{direction:Integer}
\item Attribute \texttt{indexOf:Integer}
\item Method \texttt{viewAgent(x:Integer,y:Integer)}
\end{itemize}

\subsection{Class \texttt{ViewLight}}

\begin{itemize}
\item Attribute \texttt{amount:Float}
\item Method \texttt{viewLight(x:Integer,y:Integer,amount:Float)}
\end{itemize}

\subsection{Class \texttt{ViewSubstrate}}

\begin{itemize}
\item Attribute \texttt{amount:Double}
\item Method \texttt{viewSubstrate(x:Integer,y:Integer,amount:Double)}
\end{itemize}

\subsection{Class \texttt{ViewPheromone}}

\begin{itemize}
\item Attribute \texttt{amount:Double}
\item Method \texttt{viewPheromone(x:Integer,y:Integer,amount:Double)}
\end{itemize}

\newpage



\section{Use Cases of the Program}

\begin{center}
\includegraphics[width=16.0cm]{usecases.eps}
\end{center}

These are the possibilities that a user of ALGAE has during the simulation. The first decision is wether (s)he wants to act as a \texttt{batch}- or an \texttt{online}-user.
\begin{itemize}
\item A \texttt{Batch User} starts Algae providing a filename of a pre-defined settingsfile as parameter. The simulation starts without any further inputs. The batch user doesn't see the graphical output or any part of the GUI of the program.
\subitem Once the simulation ran for a certain number of timesteps (defined in the settingsfile), it ends and the user may view the statistical output the simulation produced.
\item The \texttt{Online User} is able to watch the whole simulation in real-time. (S)he can enter any settings and may load or save a configuration file. Once the simulation is started, the main GUI is visible and the user can manipulate the sim in various ways - see the graph above and the next chapter.
\subitem Of course, when the simulation ended, the online user may view the statistical output of the simulation too.
\end{itemize}


\chapter{GUI Description}

In this chapter, we explain how the program is controlled and how it outputs the information. We use a \textbf{G}raphical \textbf{U}ser \textbf{I}nterface for input and output.

\section{Configuration Window}

The program starts with the configuration window, where all parameters relevant for the simulation are adjusted.\\
With the \texttt{OK} button the user accepts the adjustment; the Simulation window opens.\\
With the \texttt{Quit} button the user may abort the program\\
When the button \texttt{Save} is clicked, a dialog asking for a filename pops up. The current configuration is saved to this file\\
All saved configuration files with the appendix .asf are shown when the user clicks the dropdown list. When one of the filenames is selected, the configuration is loaded from this file.
\\
There are four tabstrips in the configuration window:
\begin{enumerate}
	\item Simulation
	\item Algaes
	\item Sensors
	\item Actions
\end{enumerate}

\subsection{Simulation}

\begin{center}
\includegraphics[width=15.0cm, height=10.0cm]{simsettings.eps}
\end{center}

\begin{itemize}
	\item The text field labeled \texttt{Duration} determines the duration $d$ of the simulation. If the entered time is exceeded, the user may enter any number of additional timesteps, and the simulation is resumed; otherwise, the simulation finally stops.
	\item The text fields labeled \texttt{Width, $worldx$} and \texttt{Height, $worldy$} determine the size of the aquarium.
	\item The four text fields on the bottom determine:
		\subitem the amount of substrate $a_S$ at the beginning of the simulation.  \texttt{(Substrate amount)}
		\subitem after how many time-steps $ren_S$ the substrate particles are renewed on bottom of the aquarium\texttt{(Substrate renewal rate)}
		\subitem after how many steps $dec_P$ a pheromone disapears \texttt{(Pheromone decrease rate)} 
		\subitem the \texttt{random seed} that the program uses. To eliminate any differences based on coincidence, the user can enter the same random seed for every simulation.


	\item In the frame \texttt{Light settings, $state_L$} there are
	\begin{itemize}
		\item radio buttons labeled \texttt{Enabled} with the following possibilities:
		\subitem \texttt{All the time}, which means the light shines the whole simulation 
		\subitem \texttt{Never}, which means the light doesn't shine at any time of the simulation
		\subitem \texttt{Function}, the light intensity is determined by a function.
\textit{Remark: this is not fully implemented yet. At this stage, the light always shines based on a function.}

		\item a text field labeled \texttt{Intensity}, which determines the light intensity $i_L$ on the top of the aquarium.
		\item a button labeled \texttt{Select distribution function}, where the user can select one function $d_S$ of several light distribution functions 
\textit{Remark: Not implemented, the distribution uses a fixed function at this stage.}
		\item a button \texttt{Select light cycle function}, which determines how the light intensity changes over time.
\textit{Remark: Now, this is always a sinus function to simulate a day/night cycle.}
	\end{itemize}
 
\end{itemize}

\subsection{Algaes}

\begin{center}
\includegraphics[width=15.0cm, height=10.0cm]{algaesettings.eps}
\end{center}

In this tabstrip there are two textfieldes.
\begin{itemize}
	\item The first field labeled \texttt{\# of initial Algaes} determines the number of algae $ini_a$ the simulation should begin with..
	\item The second textfield labeled \texttt{Initial Energylevel} determines the energylevel $ini_e$ which all algaes have at the beginning of the simulation.
\end{itemize}

\subsection{Sensors}

\begin{center}
\includegraphics[width=15.0cm, height=10.0cm]{sensorsettings.eps}
\end{center}

In this tabstrip the user determines the adjustment of the four sensors \texttt{(Pheromone $P$, Substrate $S$,Light $L$,Bumper $B$)}
\begin{itemize}
	\item \texttt{FOV} Field of View $f$ , this is the angle that the sensor field covers in degrees. Note that the bumper sensor always has a $f$ of 1. It only detects obstacles in a straight line.
	\item \texttt{Range} the range $r$ of the sensor in world units

\end{itemize}

\subsection{Actions}

\begin{center}
\includegraphics[width=15.0cm, height=10.0cm]{actionsettings.eps}
\end{center}

In this tabstrip, there are two frames:
\begin{itemize}
	\item In the first frame labeled \texttt{Energy consumption} the user can determine
	\subitem How much energy $e_M$ an agent needs to move around \texttt{(Movement)}.
	\subitem How much energy $e_I$ an agent needs to reproduce via mitoses \texttt{(Mitoses)}.
	\subitem How much energy $e_E$ an agent uses to reproduce via meiose \texttt{(Meioses)}.
	\subitem How much energy $e_P$ an agent uses to discharge one pheromone prticle \texttt{(Peromone output)}.
	\item in the second frame labeled \texttt{(Energy collecting)} the user determines
	\subitem how much energy $e_S$ an agent gets by consuming one \texttt{(Substrate)} particle
	\subitem and how much energy $e_L$ can an agent can take from \texttt{(Light) (this is a relative value, because the amount of energy is also based on the light intensity)}
\end{itemize}

\newpage

\section{Main GUI}

\begin{center}
\includegraphics[width=16.0cm, height=16.0cm]{simshot.eps}
\end{center}

\subsection{Aquarium}
This is the world where our simulation takes place. It shows the agents, pheromon tracks and substrate parts.\\
\begin{itemize}
	\item Agents are shwon in black
	\item Selected agents are red
	\item Pheromone tracks are blue and cover substrate particles on the same position
	\item Substrate is green
\end{itemize}
	
If an agent is selected via a click of the left mouse button, it changes its color and information about this agent is shown in the \textbf{Agent Info Window}(see below) in the case it is visible.

\subsection{MenuBar}

\subsubsection{File}
\begin{itemize}
\item \texttt{Quit} Ends the application after a safety query
\end{itemize}

\subsubsection{Windows}
\begin{itemize}
\item \texttt{Show/hide agent info window} (see below)
\end{itemize}

\subsubsection{Help}
\begin{itemize}
\item \texttt{Topics} (shows the online help)
\item \texttt{About ALGAE} (displays the program's credits)
\end{itemize}


\subsection{ToolBar}
The most important controls of the program art contained in  the toolbar.\\
\subsubsection{Buttons}
\begin{itemize}
	\item The first button starts or resumes the simulation
	\item The second button pauses the simulation
	\item The third button is used to proceed one step
	\item The fourth button restarts the simulation, using the current parameters
	\item With the sixth button it is possible to raise the zoom factor of the aquarium so the details can be watched more easiely.
	\item The ninth button is used to lower the zoom factor to improve the overview over the sim
		\subitem (The possible zoom factors reach from 1 pixel for each algae to a 10*10-pixel-per-agent view.)\\
	\item \texttt{Set stepping}: If a number $s$ is entered into the text field besides this button and \texttt{Set Stepping} is clicked, the output of the aquarium is updated every $s$ steps instead of after every step (default)
\end{itemize}

\subsubsection{Slider}
There is one slider in the program window:
\begin{itemize}
	\item The speed $sp_Sim$ of the simulation, e.g. the delay is controlled by the second slider\\
		(from \texttt{Fast} to \texttt{Slow}).
\end{itemize}

\subsubsection{Check buttons \texttt{(Options)}}
\begin{itemize}
	\item \texttt{Draw algaes/pheromone/substrate/grid}: The visible objects in the aquarium may be shown or hidden using this four check buttons
\end{itemize}

\subsection{StatusBar}
By default, it shows the following information (from left to right):
\begin{itemize}
	\item The simulation status (running, stopped, etc)
	\item The light intensity on top of the aquarium
	\item The current agent count
	\item The current and total number of timesteps
\end{itemize}
If the mouse pointer resides at a specific top in the aquarium, the second line of the statusbar shows the following information:
\begin{itemize}
	\item The vertical and horizontal positions
	\item Light intensity at this place
	\item Is there substrat at this place? 
	\item How many phermomon particles, if any, reside at this place?
	\item If an agent is at the position, what's its number?
\end{itemize}
 
\section{Agent Information Window}

\begin{center}
\includegraphics{infowin.eps}
\end{center}

If the menu point \texttt{Windows/Info Window} is chosen in the Main GUI, this window opens. It can be closed with the \texttt{Okay} button.
The following information about the selected agent is given:

\begin{itemize}
\item Current energy level $e$
\item Moving direction of the agent
\item Sensor values of all four sensors
\end{itemize}


\begin{appendix}
\chapter{Session logs}

\section{March 15, 1999}

\textbf{Time:} 17:00 - 17:30\\
\textbf{Place:} Room 202.2, Institute for Computer Sciences, University of
Salzburg\\ \textbf{Present persons:} R. Schwaiger, C. Bauer, P. Eisenmann,
T. Frommwald, M. Liedlgruber and D. Kadir\\

\textbf{Treated points:}

\begin{itemize}
\item Formalities   
\item General introduction to the problem
\end{itemize}

\textbf{Tasks to perform until March 22,2000}
\begin{itemize}
\item Get photos for the project-homepage
\item Have a careful look at the document
\item Have a look on JAVA
\end{itemize}


\section{March 22, 2000}

\textbf{Time:} 17:00 - 17:30\\
\textbf{Place:} Room 202.2, Institute for Computer Science, University of
Salzburg\\ \textbf{Present persons:} R. Schwaiger, C. Bauer, P.
Eisenmann, T. Frommwald, M. Liedlgruber and D. Kadir\\

\textbf{Treated points:}

\begin{itemize}

\item We have a concret matrix where the simulation should take place


\item Substrate
	\subitem Distribution of substrate is based on a mathematical function 
	\subitem There is a specific amount of the substrate at every point in our matrix
	\subitem The regeneration of the substrate depends on the distribution function and a basic time period (determined by some parameters) 

\item Sensors
	\subitem The sensors of our agents have a specific range and an angle of 'sight'. These things are variabel.
            \subitem We got a new sensor that can detect contact (with the wall or other agents)

\item Pheromons disintegrate after a while

\item Possible agent actions: Power consumption, movement, pheromon output, reproduction
 	\subitem All actions consume different amounts of energy

\item Energy consumption through photosynthesis or substrat accomondation

\item Movement
		\subitem Speed ?
		\subitem Agents may move one unit in one time unit

\item Reproduction
	\subitem Meiose / Mitose
	\subitem If the agent wants to reproduce through meiose he has to have a certain amount of energy. 
		 The agent follows the pheromon tracks of other agents and puts out pheromons himself.

\item Pheromon output
 	\subitem During movement 
	\subitem The agent should not follow his own pheromon track

\item Simulation steps
	\subitem The current status of the sim is displayed after each simulation step  
	\subitem During one step the agents may perform an arbitrary amount of actions (exception: movement !)

\end{itemize}

\textbf{Tasks to fullfill until March 29, 2000}
\begin{itemize}
\item Prepare further questions
\end{itemize}

\newpage
\section{March 29, 2000}

\textbf{Time:} 17:00 - 17:30\\
\textbf{Place:} Room 202.2, Institute for Computer Science, University of
Salzburg\\ \textbf{Present persons:} R. Schwaiger, C. Bauer, P.
Eisenmann, T. Frommwald and D. Kadir\\

\textbf{Treated points:}

\begin{itemize}

\item Agent input
	\subitem We need another input for our neural network: the current energy level of the agent
 	\subitem It is probably necessary that agents know whether the detected pheromon is their own or not


\item The neural network
	\subitem There are units in the ANN which are connected through weighted lines
	\subitem The more important the connection of two unit becomes, the thicker the connecting line.
	\subitem Output consists of the movement direction and everything concerning reproduction


\item The light
	\subitem Probably there will be some sort of 'fight' for the positions that are near the light
	\subitem Agents that are not on top level will get less light (shadows) 
	\subitem For this reason they may try to consume more of the substrate - the according connecting line of the ANN gets thicker

\item How could the agent learn that sexual reproduction is better than the mitose ?
	

\end{itemize}

\textbf{Tasks to fullfill until April 12, 2000:}

\begin{itemize}

\item Revise the paper:
	\subitem Exact problem definition
	\subitem Session logs
	\subitem Discussions

\end{itemize}


\section{April 12, 2000}
 
\textbf{Time:} 17:00 - 17:30\\
\textbf{Location:} Room 202.2, Institute for Computer Sciences,
University of Salzburg\\  \textbf{Present persons:} R. Schwaiger, P.
Eisenmann, T. Frommwald, M. Liedlgruber and D. Kadir\\
   
\textbf{Treated points: \\
        (document revised:)} 
 
\begin{itemize} 
 
\item Light/Substrate: 
	\subitem Diffusion: Substrate regenerates faster at the bottom than above.
	\subitem Agent has transparency factor.
\item Pheromon, Mitose, Meiose:
	\subitem Pheromon is placed only at the point, were agent is situated;
	\subitem time-delayed pheromon reduction.
	\subitem 4 various ways to
consider meiosis \ - we choose the 3rd one: forced reproduction.

\item World(object):
	\subitem Output over all partial aspects.
\\

\item ANN: 
	\subitem Processing of signals with 'Cubic Splines-Methode'(set points
to calculate a function)
 	\subitem In the ANN 'the winner takes all' \ - the maximum evaluated
response is selected
	 
\end{itemize} 
 
\textbf{Tasks until Mai 2, 2000} 
\begin{itemize}
\item first GUI (/World)-prototype
\item create UML-model
\item ev. other questions 
\end{itemize}

\section{May 2, 2000}
\textbf{Time:} 17:00 - 17:30\\
\textbf{Location:} Room 202.2, Institute for Computer Science, University of Salzburg\\ 
\textbf{Present persons:} R. Schwaiger, C. Bauer, P. Einsenmann, T. Frommwald and D. Kadir\\ 

\textbf{Treated points:}\\

\textbf{GUI Interface}
\begin{itemize}
	\item Saving
		\subitem Possibility of saving from intermediate stages
		\subitem To draft on a particular step of the simulation
	\item Buttons, menu bar and tabstrip
		\subitem "Settings" in the menu bar is problematic
		\subitem Button for gradual running
		\subitem Rename "Main" by "Aquarium"
		\subitem New tabstrip which shows a list of all algae and the possibility to select one of them
		\subitem Move the "ANN Sensors" tabstrip into the algae tab writer
		\subitem A new menu point "Windows" which shows the details of the agents.
	\item{others}
		\subitem Show light and substrate in the aquarium.
		\subitem Possibility to hold back indication for a certain amount of steps
\end{itemize}
\textbf{Tasks until May 24, 2000}  
\begin{itemize}
	\item Description of the GUI Interface
	\item Some agents should move in the aquarium
	\item Think about in which information we would be interested
	\item Make treated changes of the GUI
\end{itemize}

\section{May 24, 2000}
\textbf{Time:} 17:00 - 17:30\\
\textbf{Location:} Room 202.2, Institute for Computer Science, University of Salzburg\\ 
\textbf{Present persons:} R. Schwaiger, C. Bauer, P. Einsenmann, T. Frommwald and D. Kadir\\ 

\textbf{Treated points:}\\

\begin{itemize}
	\item Document
		\subitem The document has to contain the class diagrams and use cases
		\subitem The source code should not be included
	\item GUI
		\subitem We will include the agent selection list discussed in a former session	
	\item ANN
		\subitem The ANN is initialized randomly
		\subitem Visualization of the ANN is done by another project group, so we can omit that part

	\item We should use the same random seed for each start
	\item The maximum number of neurons may be entered
 	\item Our agents ``learn through reproduction''
	\item We save information using the XML format
	
\end{itemize}
\textbf{Tasks until June 6, 2000}  
\begin{itemize}
	\item Revise the paper, insert case diagrams and use cases
	\item Finish the GUI
	\item Make multiple agents move around in the world
\end{itemize}


\section{June 6, 2000}
\textbf{Time:} 17:00 - 17:30\\
\textbf{Location:} Room 0.09, Institute for Computer Science, University of
Salzburg\\    
\textbf{Present persons:} R. Schwaiger, C. Bauer, P.
Einsenmann, T. Frommwald and D. Kadir\\ 

\textbf{Treated points:} \\

\begin{itemize}
	\item GUI - Settingsdialog
		\subitem Simulation: change substrate-settings to be similar to
light-settings (with function)
		\subitem Sensors: add bumper-sensor
		\subitem add button to save settings
	\item Simulation:
		\subitem output the sim state only every x-steps (definable)
		\subitem make the duration of simulation (number of timesteps)
changeable during runtime
		\subitem Statistics: protocol the simulation state on harddisk and make sure functionality can be added later easily
  	\item There should also be  a slider to change the amount of substrate (similar to light)
	\item Colored agents: color depends on their amount of energy \\
	
\end{itemize}
\textbf{Next meeting: June 21, 2000}  

\section{June 21, 2000}
\textbf{Time:} 17:00 -17:30\\
\textbf{Location:} Room 0.09, Institute for Computer Science, University of Salzburg\\
\textbf{Present persons:} R. Schwaiger, C. Bauer, P. Eisenmann, T. Frommwald and D. Kadir\\

\textbf{Treated points:}\\

\begin{itemize}
	\item Progress of implementation
	\item Improvement of paper
		\subitem Write the section "abstract" (150 words)
		\subitem Extend and revise the Introduction
		\subitem Add new (latest) screenshots to the paper
		\subitem Formalize and generalize the whole paper.
\end{itemize}
\textbf{Next meeting: July 5, 2000 14:15 (Presentation)} %danach auf ein oder zwei Bier gehen!!!!!


\end{appendix}

\end{document}
