/********************************************************************* * Copyright (c) mr-sk, 2008. * * Author: sk * Email: sk@mr-sk.com * Http: mr-sk.com * * Compile: gcc ff.c * * What: Implements a basic algorithm for obstacle avoidance with the * Khepera II robot. This just allows you to quickly calculate * fitness values. * ******************************************************************** * * Who: When: What: * ---- ----- ----- * sk 10-Jul-08 Created. * **********************************************************************/ #include #include int main() { int m1, m2, a, s[7], i, counter=0, fitness, s_total=0; a = 10; float b = 0.3; printf("m1="); scanf("%d", &m1); printf("\nm2="); scanf("%d", &m2); for (i=0; i<8; i++) { printf("\ns%d=",i); scanf("%d", &s[counter]); counter++; } printf("\nCalculating fitness..."); fitness = a * ( abs(m1) + abs(m2) - abs(m1-m2) ); for (i=0; i<8; i++) { s_total += b*s[i]; } fitness = fitness - s_total; printf("\n F = %i\n", fitness); }