diff options
author | Davide Morelli <morellid@users.sourceforge.net> | 2005-12-15 12:03:36 +0000 |
---|---|---|
committer | Davide Morelli <morellid@users.sourceforge.net> | 2005-12-15 12:03:36 +0000 |
commit | 975f9ac06a04a0b1528f1fbf9ac7482febc957c2 (patch) | |
tree | a63177a41ff869e5dca64feded29f24f900f0d30 | |
parent | 145fa412f1306ae7cc15b18358c97aeb2b1b8582 (diff) |
fixed a never-ending while in fitness4
svn path=/trunk/externals/frankenstein/; revision=4222
-rwxr-xr-x | GArhythm.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -172,11 +172,14 @@ static double GArhythm_evaluate_fitness1(char *woman, char *man) int res=0;
int max = BUFFER_LENGHT*2;
int i;
+ /*
+ // commenting here I allow beat swapped rhythms to be considered as identical
for (i=0; i<BUFFER_LENGHT; i++)
{
if (woman[i] == man[i])
res++;
}
+ */
for (i=0; i<BUFFER_LENGHT; i++)
{
if ((woman[i]!= 0) && (man[i] != 0))
@@ -208,6 +211,7 @@ static double GArhythm_evaluate_fitness2(char *woman, char *man) // similarities TODO
static double GArhythm_evaluate_fitness3(char *woman, char *man)
{
+ // TODO: DUMMY, not working!
int i;
short int global1[BUFFER_LENGHT];
short int global2[BUFFER_LENGHT];
@@ -227,7 +231,7 @@ static double GArhythm_evaluate_fitness3(char *woman, char *man) return 0;
}
-// svaforisce troppi colpi consecutivi
+// penalyze too many consecutive beats
static double GArhythm_evaluate_fitness4(char *woman, char *man)
{
int i, j, max, curr_consecutivi, max_consecutivi, tot_consecutivi;
@@ -240,7 +244,7 @@ static double GArhythm_evaluate_fitness4(char *woman, char *man) curr_consecutivi = 0;
while(i<BUFFER_LENGHT)
{
- if (man[i] & (0x01<<j))
+ if ((man[i] & (0x01<<j)) && (man[i-1] & (0x01<<j)))
{
// here is an event
//is it the first?
@@ -252,6 +256,7 @@ static double GArhythm_evaluate_fitness4(char *woman, char *man) tot_consecutivi += curr_consecutivi;
curr_consecutivi = 0;
}
+ i++;
}
}
ris = (float) (((float) ris) / ((float) max));
|