nearest enemy another problem

How would you make it so enemies will move from one to the other of the nearest two cubes with a property of cow.Their would be ten cubes with the property of cow?Sorry for posting it solved.
Agoose77 that solution didnt work with the state actuator and when i moved the cubes and spheres in the blender game engine it wouldn’t do it anymore.

When do you “select” the two nearest cows? (Please keep in mind near changes over time)

When the player hides behind an obstacle such as a wall.This for a firstpersonshooter where the enemies hide behind walls and then come out constantly and do this until the player comes out with its back facing them walking away or until a certain amount of time has past and then the enemy will come and find the player.