I'm writing a genetic algorithm program where "cells" have to make their way to a point that is located behind an obstacle that they have to get to. The structure looks something like this
target
---------------------
cell pool
where the cells come from the pool and have to get around the obstacle and make their way to the target. My question is how I should go about calculating the distance from a cell to the target? I need this because I am going to dynamically color the closest cell each frame. My guess would be to essentially find the closest edge of the obstacle (left or right side) and draw a line to that, then bee line it to the target, and add the lengths of those two lines together, but I was wondering if there was a more optimal way.
Thank you for your help!