Please help to understand the algorithm

Hi everybody!) Please help to understand an algorithm of behaviour.
That’s my idea - i have a characters, which should move to closest actors in yhe world.

But they should check closed or not their target (by boolean i mean) and if thir target becomes closed, char should change his target to another closest actor.

Boolean change it type from false (it’s mean actor is opened for coming) to true when one of char overlaps collision of actor.

I break my mind when find a dicision, help to understand!

P.S. Sorry for my English and grammar errors)

Try something like this: