Question Wrote:Can you make it generate lairs randomly instead?
It really depends on what you want the program to do. Are you asking for regeneration of the defeated lairs or all the lairs, including undefeated. I'm also assuming you want the treasure change accordingly. Also remember that the regeneration process is affected by the game difficulty level. What you are asking is doable yet difficult implement with exact algorithm. Lair generation would go about like this:
Loop through lair data array and for each (defeated) lair produce new data as follows:
1. Randomly pick
suitable,
unoccupied land tile on the map. Save the coordinates.
(may be time-consuming to implement)
2. Randomly pick lair type, restricted by terrain type, as guided in
Official Strategy Guide.
(straightforward to implement)
3. Randomly pick monster color (death, life, nature, sorcery or chaos). The lair type affects the probability of each color.
(straightforward to implement)
4. Repopulate the lair as guided in
OSG or alternatively implement better repopulation algorithm (for the sake of diversity).
(should be relatively easy to implement)
5. Generate appropriate treasure as guided in
OSG.
(should be straightforward to implement)
Overall the regeneration algorithm is not very simple.