Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

sorry - but I think you're going about this all wrong!

Having played lots of games like this, I think it's dumb to generate random treasure in a way they will frequently give high-level players garbage items, and yet might give a low level player a game-breaking, super-powerful item.

I suggest the following: generate a table of all known weapons, and assign each a cost. For example, let's say a +1 sword costs 100gp, a +2 sword costs 400gp, a +3 sword costs 900gp, etc. Adding an energy-type bonus (flaming, frost, acid, etc.) counts the same as an extra plus, i.e., a "+2 flaming sword" costs the same as a "+3 sword".

Once all weapons and their costs are tabulated, bin them accordingly (the set of all 100gp weapons, the set of all 200gp weapons, etc.). Each area of the game should have a standard difficulty level used to determine appropriate treasure (level 1 of the dungeon has 100gp treasures, level 2 has 400gp, level 3 900gp, etc.). Then for a given treasure, randomly select an item from the appropriate bin. (the same metric would be used to determine which monsters to use in order to provide a good challenge)

An easy modification would be to generate a random number between 1 and 100, and do something like this:

1-5 use treasure for level-2
6-20 use treasure for level-1
21-80 use treasure appropriate for this level
81-95 use treasure for level+1
96-100 use treasure for level+2

So, on average, you get a level appropriate treasure, but you have a 15% chance of getting something better (and and equal change of getting something not quite so good).


In reply to Re: Algorithm Help by scorpio17
in thread Algorithm Help by dreadpiratepeter

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-20 00:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found