The idea is to have a fitness that reacts relatively to segments along the path. It starts by 0. Then from that it goes segment by segment and calculates s1.magnitude and s2.magnitude where (s_i = ith segment, s_i.magnitude = (s_i.pos - destination).magnitude). Then it subtracts from current fitness (s1.magnitude - s2.magnitude). At the very end, it subtracts (last_pos - destination).magnitude (more favoring segments that end in destination). If (s_i - s_j).magnitude is negative (it goes away from destination), subtract the absolute value multiplied by some factor (e.g. 2). Also add some penalization if there is collision.
The idea is to have a fitness that reacts relatively to segments along the path. It starts by 0. Then from that it goes segment by segment and calculates s1.magnitude and s2.magnitude where (s_i = ith segment, s_i.magnitude = (s_i.pos - destination).magnitude). Then it subtracts from current fitness (s1.magnitude - s2.magnitude). At the very end, it subtracts (last_pos - destination).magnitude (more favoring segments that end in destination). If (s_i - s_j).magnitude is negative (it goes away from destination), subtract the absolute value multiplied by some factor (e.g. 2). Also add some penalization if there is collision.