It should be possible to lock or unlock exits based on certain conditions:
The number of unique rooms the player has visited. Maybe keep a track of the IDs of all rooms the player has visited? The length could be extrapolated from that.
Whether or not a player has visited a particular room.
Whether the player is carrying a particular object.
Whether a player is carrying an object of a particular type? This would rely upon #4.
It should be possible to lock or unlock exits based on certain conditions: