In my game, I would like to spawn N items, not necessarily at the same time. Some of the items are dependent on what was spawned before (Markov chain-esque), so the probability of spawning two rocket launchers in a row is low, but there's a reasonable probability of spawning a rocket launcher followed by rockets. What would be the most efficient way of doing this? The method will be called very often, so I'm trying to keep calculations to a minimum.
An idea I came up with could be to create an N x N array which acts as a lookup table of the probabilities (Item previously spawned VS Item to spawn). However, in this process, I would need some way of generating a random number with the probability acting as a bias. I am not sure what the best way of doing that is. Things also get slightly tricker when an inventory comes into play, as rockets cannot be generated if Y amount have already spawned. I could create a 3D array and store the inventory number in there, but I'm not sure how efficient it would be to keep updating an array lookup table based on inventory.
That's just an idea I came up with, but there's probably another, better, way of doing this. Are there any data structures that would be more efficient than a 3D array, or algorithms I should read up on?