Refactored get_random_opponent function