It's super inefficient haha. Every frame I mark the positions of the player and snakes in a grid. Then at fixed intervals each snake head checks:
- Is the player in the next tile I'm headed toward -> keep going
- Otherwise if the next tile turning (left/right/straight) toward the player is safe -> turn in that direction
- Else pick the safest direction available (measured in # of empty tiles in a straight line)
It's not the smartest or the most efficient, but it's what I came up with and it kinda felt interesting to play against haha. I think it's good that it's not too smart. I had an even simpler version initially and I'm still not sure if making it smarter made it more fun 😆