UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4 IP: 198.54.202.226 URI: http://wesnoth.slack.it/?RandomTraitUnit - - - - - Index: RandomTraitUnit =================================================================== RCS file: /home/wesnoth/cvsroot/wikiroot/RandomTraitUnit,v retrieving revision 1.6 diff -u -r1.6 RandomTraitUnit --- RandomTraitUnit 4 Jul 2005 02:39:10 -0000 1.6 +++ RandomTraitUnit 4 Jul 2005 08:18:55 -0000 @@ -12,6 +12,12 @@ make the game generate names for you (v0.9 and later). (Added an entry for [resilient, quick]. For those two, order does produce different results - scott) +Also note that these macros will have a skewed distribution of traits. +To mimic the distribution of traits used by the game, there must +be exactly n*(n-1) equally likely random pairs of n traits. +Even though strong,resilient may end up with the same stats as +resilient,strong these both need to be catered for. + #define TRAIT_IF NUMBER DESC TRAIT1 TRAIT2 STATS [if] [variable] @@ -42,6 +48,12 @@ {TRAIT_IF 7 resilient,quick ({TRAIT_RESILIENT}) ({TRAIT_QUICK}) ({STATS})} #enddef +Note that this macro will create a unit that is resilient +with probability 4/7, strong with probability 3/7, intelligent with +probability 3/7, and quick with probability 4/7. To fix it, it should +actually have 12 possible pairs, so that each trait has probability +6/12 = 1/2. + Warning: In multiplayer, as of 0.8.7, you must use PseudoRandom, not {RANDOM}: #define RANDOM_TRAIT_UNIT STATS {PSEUDORANDOM 7} @@ -54,26 +66,10 @@ {TRAIT_IF 7 resilient,quick ({TRAIT_RESILIENT}) ({TRAIT_QUICK}) ({STATS})} #enddef -A special version for elves, taking into account the elf-specific dextrous trait +The same caveat applies to this macro as the previous one. - #define TRAIT_IF NUMBER DESC TRAIT1 TRAIT2 STATS - [if] - [variable] - name=random - equals={NUMBER} - [/variable] - [then] - [unit] - {STATS} - traits_description= _ "{DESC}" - [modifications] - {TRAIT1} - {TRAIT2} - [/modifications] - [/unit] - [/then] - [/if] - #enddef +A special version for elves, taking into account the elf-specific +dextrous trait, using the same TRAIT_IF macro as above: #define RANDOM_TRAIT_UNIT_ELF STATS {RANDOM 1..10} @@ -89,6 +85,9 @@ {TRAIT_IF 10 quick,intelligent ({TRAIT_QUICK}) ({TRAIT_INTELLIGENT}) ({STATS})} #enddef +This macro has the correct distribution of individual traits, but will never +produce resilient,quick units (which may have slightly different hitpoints +to quick,resilient units). ||See Also||
_______________________________________________ Wesnoth-wiki-changes mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/wesnoth-wiki-changes
