Enemies Movement... How ? #TerrariaExample

I was playing terraria and i kept thinking… how some monsters behave!
For instance, the boss “Eye of cthulhu” and the small eyes which keep trying to follow you but are so DUMB* that they keep smashing into walls and bouncing.

Question : How did they code it? Its hard to imagine how they coded a “dumb” eye and that Chtulu movement.

Anyone have a light on this? Its just me or everyone have some difficulty on it

Starts at 8:00
PS : ITS NOT MY VIDEO