Main Page   Class Hierarchy   Compound List   File List   Compound Members  

portion Class Reference

A class implementing a portion. More...

#include <portion.h>

Inheritance diagram for portion:

colony land water List of all members.

Public Methods

 portion (double *coordinates, int index)
bool belongsPoint (double x, double y, double z)
 Checks wether a point belong to this portion.

virtual ~portion ()
virtual void update (long int updateStamp)=0
 The code that makes the world evolve to its next iteration.

void displayAnt (bool printNames)
 The OpenGL/Glut code that draws the ants located on the portion, if any. More...

void displayPlant ()
 The OpenGL/Glut code that draws the plant located on the portion, if any.

void setColor ()
 Resets the current OpenGL color. More...

virtual double getFood ()
 Returns how much food has been stored on the portion so far. More...

virtual double modifyFood (double modifier)
 Changes the amount of food which has been stored by ants on this portion. More...

virtual bool isColony ()=0
 Is this portion a colony ?

virtual void displayPheromones (char pheromoneType)
 The OpenGL/Glut code that displays the pheromones located on the portion, if any. More...

void move (ant *myAnt, portion *to)
 Moves the ant myAnt to the portion to, without cheking if the to portion is walkable.

portion * sensePheromones (char type, char antHemisphere, portion *previousPortion)
 Returns the portion that contains the most pheromone of type "type" laid by ants from the hemisphere antHemisphere. More...

portion * senseBasicInstinct (portion *previousPortion)
 Returns a random portion meeting the walkable condition. More...


Public Attributes

char hemisphere
 1 for North, 0 for South.

bool walkable
 Is the portion walkable ?

double coordinates [9]
 x,y,z coordinates for 3 points of the triangle.

int foundNeighbors
 used during the initiating sequence of the program to check the consistency of the list.

portion ** neighbors
 pointers array to the 3 neighbors.

int index
 Each portion is given a unique number.

plantthisPlant
 A pointer to the plant which could be located on the portion.

pheromonepheromones [2]
 Pointers to the north and south portions.


Protected Methods

void updateP (long int updateStamp)
 common update code to all portions.


Protected Attributes

GLfloat antColor [4]
 color of the ant when looking for food.

GLfloat antColorAlt [4]
 color of the ant when going back home.

GLfloat portionColor [4]
 color of the portion.

GLfloat treeColor [4]
 color of the trunk.

GLfloat leavesColor [4]
 color of the leaves of the tree.

GLfloat antRadius
 radius of the sphere representing the ant.

antListfirstAnt
 points to the first element of the local ant list.


Detailed Description

A class implementing a portion.


Constructor & Destructor Documentation

portion::portion double *    coordinates,
int    index
 

Parameters:
coordinates  A 9-double array containing the x1,y1,z1, ..., xk,yk,zk coordinates of the 3 points describing the portion triangle
index  The portion (unique) index


Member Function Documentation

void portion::displayAnt bool    printNames
 

The OpenGL/Glut code that draws the ants located on the portion, if any.

Parameters:
printNames  Determines wether the ants should be labeled or not.

void portion::displayPheromones char    pheromoneType [virtual]
 

The OpenGL/Glut code that displays the pheromones located on the portion, if any.

Parameters:
pheromoneType  Selects the pheromone type to display. 0 for none, 1 for departure, 2 for return.

Reimplemented in land.

double portion::getFood   [virtual]
 

Returns how much food has been stored on the portion so far.

0 if the portion is NOT a colony.

Reimplemented in colony.

double portion::modifyFood double    modifier [virtual]
 

Changes the amount of food which has been stored by ants on this portion.

Does nothing if the portion is not a colony.

Parameters:
modifier  the number that will be added to the current food store. Can be negative.

Reimplemented in colony.

portion * portion::senseBasicInstinct portion *    previousPortion
 

Returns a random portion meeting the walkable condition.

Parameters:
previousPortion  Indicates where the ant comes from. It will be given less chance to return to its previous portion.

portion * portion::sensePheromones char    type,
char    antHemisphere,
portion *    previousPortion
 

Returns the portion that contains the most pheromone of type "type" laid by ants from the hemisphere antHemisphere.

Parameters:
previousPortion  Indicates where the ant comes from. It will be given less chance to return to its previous portion.
type  'd' for departure-, 'r' for return-pheromones
antHemisphere  The kind of pheromones the ant can sense, ie 0 for South, 1 for North.

void portion::setColor  
 

Resets the current OpenGL color.

This method could be used before displaying the triangle for example


The documentation for this class was generated from the following files:
Generated on Mon Jun 14 09:29:38 2004 by doxygen1.2.15