

#include "individual.h"

boolean Individual::operator ==(Individual other)
                    {  
                      return equal(other);
                     }


boolean Individual::equal(Individual other)
                 {
                   int i;
                   boolean eq = TRUE;
                   for(i=0;i<=CHROMLENGTH;i++)
                       if(chromosome[i] != other.chromosome[i])
                          eq = FALSE;
                   count++;
                   return(eq);
                  };

boolean Individual::greater(Individual other)  // Compare ourself to other, bit by bit.
                 {
                   int i = 0;
                   if(equal(other))             // If equal, then "greater" is false.
                     return(FALSE);
                     else                       // At least on bit must be different.
                      {                         // Go to most significant bit position
                                                // that is different between the two.
                        while(chromosome[i] == other.chromosome[i]) i++;
                        if(chromosome[i] == TRUE)   // If our bit is one and other's is zero,
                          return(TRUE);             //  then we are greater, otherwise not.
                          else return(FALSE);
                      };
                  };

void Individual::printchrom()
    {
      int i;
      for(i=0;i<CHROMLENGTH;i++)                //  Print each bit on same line.  No newlines.
         if(chromosome[i]==TRUE)
           cout << "1";
           else cout << "0";
    };

