AI code for a Bot to Chase and flee from the player

This video shows code to make a Bot move towards the player and move away from the player when close.
The circle around the Bot acts as a sensor.
When the player is touching the circle, a counter is set to 2.
When the counter is greater than 0, the Bot moves away from the player.
When the counter is less than 1, the Bot moves towards the player.
The counter forever lowers by 1 every second.