Implement neighbors function for game logic