api_key = os.environ.get("API_KEY")
# base_url = "https://treasure-hunt-test.herokuapp.com/api/adv"
base_url = "https://lambda-treasure-hunt.herokuapp.com/api/adv"
headers = {"Authorization": f"Token {api_key}"}

graph = Graph()
r = requests.get(f"{base_url}/init/", headers=headers).json()
print(r)
print(f"Starting room: {r['room_id']}")
time.sleep(15)

travels_log.write(json.dumps(r) + ",")

player = {}
player_current_room = graph.add_room(r)

# Seed for the pseudorandom number generator
seed = 386839

# Seed the random number generator for reproducible results
random.seed(seed)

# Will be filled with directions to walk
traversal_path = []

# Keep track of visited rooms so we know when we've visited them all
visited_rooms = set()
visited_rooms.add(player_current_room["room_id"])

backtracked = False  # Track whether player has returned from a dead end
    # Seed the random number generator for reproducible results
    random.seed(seed)

    # Start player in the first room
    player = Player(world.starting_room)

    # Will be filled with directions to walk
    traversal_path = []

    # Keep track of visited rooms so we know when we've visited them all
    visited_rooms = set()
    visited_rooms.add(player.current_room)

    # Initialize a graph to track rooms and connections between them
    graph = Graph()
    graph.add_room(player.current_room.id, player.current_room.get_exits())

    backtracked = False  # Track whether player has returned from a dead end

    # Loop until all rooms have been visited
    while len(visited_rooms) != len(room_graph):
        # Get a list of unvisited exits from the current location
        exits = graph.get_connected_rooms(player.current_room.id,
                                          visited=False)

        # If there are exits
        if exits:
            # Store current room for connecting to the next room
            current_room = player.current_room

            # If we didn't backtrack, bias toward making turns rather than going straight