Q-learning in gridworld with random board
From your linked description of the game, we can see it has a key property when used normally in AI teaching:


Partially observable: The Wumpus world is partially observable because the agent can only perceive the close environment such as an adjacent room.


This makes sense, the problem of avoiding hazards would be trivial if the full map was revealed to the agent. The problem is also not about learning a specific map.
You could use the agent's perception to construct a simple state table based on current observations:

Current location
Current facing
Boolean flags for stench, breeze, glitter, bump, scream

This would be relatively easy to build into a Q table, and might have some success. However, it would likely perform a lot worse than the propositional logic and planning suggested suggested at https://www.javatpoint.com/the-wumpus-world-in-artificial-intelligence for two reasons:

Agent will not take account of knowledge specific to the current map that it has gathered. This is critical, because the stench and breeze sensors only tell you that at least one of the adjacent rooms has a hazard. In theory you know that this will not be any of the rooms that the agent has already visited, but a simple state representation based on current observations will not capture this.

Agent will not plan using the deterministic rules of the game that you know and could code for.


There are a few different approaches you could take to improve on these issues. Sticking with Q learning and trying to solve this by improving the state representation, you could look at the suggested knowledge-building structure from the java T point site, and replicate something like it as input features:

Current facing
Whether or not the last move forward resulted in a bump
Whether or not there has been a scream
For each allowed room, a binary flag set to true if the room has been visited by the agent
For each allowed room, a set of binary variables covering the three observations that are about the room: stench, breeze, glitter
Either the current location separately, or another binary variable added to each grid square set to true for the one room that the agent is in

When multiplied by 16 to cover each room, you will end up with ~84 binary flags. Although many combinations will not be possible, this is still going to be far too large a state space to use with a Q table. You would probably use a simple neural network and DQN agent to solve this problem using Q learning.