Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Chests in Random Dungeons


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 shadowgamesco   Members   -  Reputation: 326

Like
0Likes
Like

Posted 02 September 2011 - 04:43 AM

I've spent the last little while working on a random dungeon generator in python. Right now, it generates random dungeons, and places the "staircases" to go to a higher level in the dungeon (possibly exit the dungeon) or to descend deeper into the dungeon. The next thing I want to add is a way to add "chests" to it. I thought of just picking a random number of chests to add, then to just add them in random spots in the dungeon, but then I get the occasional time when 2 chests are right next to each other, or they are in the same rooms as the stair cases, etc. Just overall bad places for them to be if it where to be used in a game. So I came up with an idea to use path finding (specifically A*) to find the shortest path from the staircase leading up to the staircase leading down, then to place the chests (a random number of them) in the areas furthest away from the path. That way the player has to go more out of his way to find all the goodies. :) Which encourages the player to explore more (kill more demons!) instead of focusing on just going deeper into the dungeon.

I have the path finding working, and the path is generated. But I have no idea how to do the next part. Actually finding the areas furthest away from the path. Any ideas/suggestions are appreciated!
If you want to know more about how my dungeon generator works you can look at the guide I wrote on random map generation here, or if you want to see it in action, you can download the Python source code here.

Attached Thumbnails

  • Screen Shot 3.png


Sponsor:

#2 laztrezort   Members   -  Reputation: 972

Like
1Likes
Like

Posted 02 September 2011 - 07:04 AM

I have the path finding working, and the path is generated. But I have no idea how to do the next part. Actually finding the areas furthest away from the path. Any ideas/suggestions are appreciated!


My first intuition would tell me to experiment with Dijkstra maps - see here for a short article. Although this is not something I've experimented with, it seems like it might be suitable.

#3 Suspense   Members   -  Reputation: 449

Like
1Likes
Like

Posted 02 September 2011 - 08:46 AM

From looking over your algorithm, I think it would be useful to convert your list of rooms into a tree. Make the room with one staircase the root of the tree and mark the path from the root to the other staircase. Now you can traverse the tree from the root along any other branch and drop a chest somewhere on that branch. This will ensure that no chests are placed along the path from one staircase to the other. You can adjust things from there to get the kind of results you're after.

#4 Nice Try   Members   -  Reputation: 104

Like
1Likes
Like

Posted 06 September 2011 - 12:21 PM

Just want to say that you're my hero for posting this. I've been looking for an example of how to do this for a while in pygame and this is exactly what i need to help me create my own.

#5 Infernal-rk   Members   -  Reputation: 135

Like
1Likes
Like

Posted 06 September 2011 - 12:41 PM

if you implemented A* pathing, you already have a tree correct? can you travel your optimal path and then from each node of the path, branch out perpendicular to your A*s directional heuristic as far as you can or want and place chests in rooms without other chests prior (to avoid your double chest rooms)....You can make the farther pathed out chests have more valuable items to justify the larger detours to get to them.

might not work... who knows.

#6 Kian   Members   -  Reputation: 242

Like
1Likes
Like

Posted 06 September 2011 - 08:45 PM

I can think of a brute force approach. Something like, go room by room and measure the distance from the room to each stair. Store the location of the room where the sum of these two distances is maximum. That will guarantee that the player has to do the longest detour possible to find the chest.

I suppose if you modify the A* algorithm a bit so it caches instead of making a fresh search from each room it won't be so bad, you'll just need to map the whole level from each stair.

#7 px   Members   -  Reputation: 523

Like
1Likes
Like

Posted 06 September 2011 - 09:30 PM

This doesn't really do anything to help you with your problem, but...

How about having the quality of the items in the chest depend on the distance the chest is away from the shortest path. That way people who want to just rip through a dungeon fast will still have some chance of finding goodies and people who take their time and explore get a better chance.

Just a thought... :)
Humble people don't refer to themselves as humble (W.R.T. "IMHO".)

#8 shadowgamesco   Members   -  Reputation: 326

Like
0Likes
Like

Posted 06 September 2011 - 09:39 PM

My first intuition would tell me to experiment with Dijkstra maps - see here for a short article. Although this is not something I've experimented with, it seems like it might be suitable.


Thanks for your reply, I actually came up with my own algorithm very similar to 'Dijkstra Maps' described in that article. Turned out great! Thanks to everyone else who suggested a solution.

This doesn't really do anything to help you with your problem, but...

How about having the quality of the items in the chest depend on the distance the chest is away from the shortest path. That way people who want to just rip through a dungeon fast will still have some chance of finding goodies and people who take their time and explore get a better chance.

Just a thought... :)


Already done my friend. Thanks! :D
Now there is a small chance that a chest will be placed closer to the path, but most of them are placed far away from the path. And the quality of the items inside is random, but there is an increased chance of the items being of a higher quality the further they are from the path. I'll be uploading this version (1.7) to the google code project page sometime this week! Thanks again for all of you suggestions guys!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS