GhPython : Agents influenced by field

Hello,
I need help on a part of a GHpython code that allows agents to move in a urban plot, depending on cohesion, alignement and separation vectors. I want to add another influence to control them, a field in xy plane.

I have used an inital code from +GENEATCG (https://www.geneatcg.com/2014/06/25/swarm-python-component/ and have modified it to adapt it to my project.
I was triyng to write a new function in the “class runner”, called fieldInfluence, but i got errors.

I am asking your help to develop this short part, allowing the agent to take into account a new vector given by the closest vector in the field vectors list, with a given number for the FieldInfluence_intensity.

Thanks a lot to anyone who can help me, it is always a good way to learn new things for python beginners!
Ilona

AgentsInfluencedByField.gh (4.9 MB)