Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Here are two possible ideas for a solution.

The first is that rather than target a "weight range", have some tunable parameters that are correlated with the likely weight of the result. Then insert values for those parameters, and pick your combination of items, pluses, etc.

The second is to go through an iterative generative process. Make it look like this. On each iteration you randomly pick a trait to modify out of (prefix, prefix2, plus, weapon_type, suffix). If you pick a prefix2 and you have one, you randomly decide whether to regenerate the existing or generate a new one. (If you have 2 already you repeat this decision making process with the third.) Then you make a random choice of that component. (For a prefix2 make a valid choice be "none".) If adding (replacing if need be) that characteristic makes your weapon closer to the target weight, do so.

Continue this process until the target weight is reached, or until a fixed number of rounds has passed.

In essence this is a genetic algorithm, where you're trying to evolve a random weapon that fits your target weight.


In reply to Re: Algorithm Help by tilly
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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (7)
    As of 2014-08-23 16:21 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The best computer themed movie is:











      Results (174 votes), past polls