Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Averaging: Distribution vs. Categorical

Okay, so I got roped into programming a fashion designer game (don't ask, the story of how is as tedious as it is humiliating) but I've hit a problem in designing the characters...

We want the player's decisions to affect fashion trends in the society as they handle clients. So, to cut down on the complexity of explaining the problem, here's a cut down example
$femMallTemplate = {
name: "The average female mall-goer",
gender: 1,
hairLength: 1.2,
hairColor: -1

hairLength goes from 0-4, 0 is bald, 1 is short, then medium, long, and extra-long. In the template, it's a decimal because I average the length of the average female with the finished client, weighted with the player character's reputation as a trendsetter. The mall status passage effectively rounds to the nearest integer when processing, this is just to reflect that one client does not a trend make.

Hair color is negative because I want negative numbers to represent families of colors. not everyone's blond. -1 is represents natural colors like blond, black, or brown. -2 would be unnatural dyed colors, and -3 would be something exotic, like zebra stripes.

So, when fed to the description passage, it would say that the women in the mall, on average have short hair in natural colors

When I spin off a client character for the player to interact with, the client created, after randomization, looks like this:
$client = {
name: Victoria,
gender: 1,
hairLength: 2
hairColor: 3

This code might say that Victoria has shoulder-length brunette hair, at least at the start. When the player is done with Ms. Victoria, the data that represents her is now
$client = {
name: Victoria,
gender: 1,
hairLength: 4
hairColor: 13
Poor Ms. Victoria now sports a veritable curtain of cheeta-patterned hair. That's what she gets for visiting a mad barber I guess.

Still, the player character is renowned for setting bold new trends, so instead of being a social pariah Victoria gets invited to all the parties and shows off her new 'do, prompting imitators and shifting the local social landscape. This is reflected by averaging the client and template together, with no weighting since the PC holds the beating heard of fashion in their clenched fist

Gender is 1, so we average with the femaleTemplate,
hairlength =( 1.2+4)/2 = 2.6... I suppose most people aren't brave enough to go as long as Ms. Victoria, but the math was relatively painless
hairColor = (-1 +13) / 2 = 7... Huh. Now most everybody's wearing lime-green hair because the woman enjoying her 15 minutes of fame sports animal patterns? This does not follow. What should happen is either a) the hairColor stayed the same because the PC didn't influence it enough or b) switch to -3 to show that the trend is now animal styles

I need another scheme to better reflect this kind of feedback. Is it possible to store objects as parameters for other objects in Twine, or will I need to spin off a separate object entirely? I would liketo make this as condensed as possible, because there's a lot more than one "categorical" traitfor each template, and more scenes than the mall for the player to try to influence. I don't mind the work when it comes to processing all these traits, but if I have to reference and modify 5 values for each categorical trait this will get our of hand rather quickly.


  • I think your problem lies in choosing averaging as your combination method. What would you expect to see as a result of the influence of Ms. Victoria's new haircut?

    Everyone with identical hair cuts? (in that case you want to copy her style to the template, not average it).

    A general pull towards longer hair (which you get from averaging the length) and towards more wild colors (in which case you need to classify her hair style on the scale you use for the template (-3) and then find a way of combining it with the template value - bearing in mind that you've not got a linear scale to work with).

    Some people wearing 'similar' hair styles, with the others being unchanged? In this case you probably need to store a array of popular hair styles and replace one or two instances in it with her new hair style. People then pick their hair styles from the popular styles, maybe with a little variation (length 3 or 4, color 12,13 or 14 etc...).

    Fashion is all about setting the mode - the most commonly occurring type - not about shifting the average.
  • edited March 2016
    Well, the problem is that I want to do two different things, but with the tools available to me in twine I feel somewhat limited. With things on a spectrum, like hair length, A gradual pull via averaging captures what I want to do nicely, but with things like hair color, that aren't on a spectrum but fall into distinct categories, I can't think of a scheme to remember what the player has done and still pull out what should reflect the result of the player's work easily.

    I've asked about, and I think I'll have to do something like this:

    Store a number of the order -10^(n*2) where n is the number of categories. For example, lets say the number currently stored in hairColor is -203050. Break it into three distinct numbers:

    // for the sake of readability, I've replaced -($femMallTemplate.haircolor) with the intended return of 203050
    <<set $normal = (203050 % (10^2) = 50>>
    <<set $dyed = ((203050/ 10^2) % (10^2) = 30>>
    <<$exotic = ((203050/ 10^4) = 20>>

    So, in one variable, I've stored three distinct values. These values, by design, add up to 100, representing the share of each family of colors in the whole. From there, I can tweak the values to represent the changes from the player's debuting of Victoria, and build the number again. Using arbirtary values:

    $normal = 20
    $dyed =10
    $exotic = 70

    $femMallTemplate.hairColor = -1* (($exotic * 10000) + ($dyed * 100) + ($normal)) = 701030

    when called, the display function will take apart the number again to determine the most common person to describe.

    At least, if there is such a thing as a function in twine

    The half-pseudocode above reflects what I think would happen if twine behaved like c++. I know sugarcube supports a limited amount of Javascript, so in theory I might be able to make this work with functions, but from what I've seen objects in twine don't always behave the way they do in c++ and the Javascript, from what I hear, is limited to a single passage, which cramps my coding style but is workable in the end.

    Question, does twine even support the % operator, or will I have to somehow build that myself?

    another question: how can I make twine ignore remainders when performing division?

    Another question: what kind of algorithm would work best to reflect these changes? everything else leading up to this is immaterial to this question. if I give you:

    $hairColor = {normal: 50 dyed: 30 exotic: 20}

    where the values represent percentage shares

    And I tell you that $client.hairColor = 13 is a color in the exotic family, what kind of math should I use to represent a realistic change and still wind up with three numbers that add up to 100 in the end? Do I borrow from the most popular? somehow borrow from both of the other two? And I need to keep in mind the the PC's reputation will weight this whole process. I've sketched out some ideas, but none satisfy me enough to even put up here.

    Sorry about the rambling questions, I'm tired and this project is becoming rather daunting, and I haven't even started yet, not really.

  • mykael wrote: »
    I think your problem lies in choosing averaging as your combination method.


    Fashion is all about setting the mode - the most commonly occurring type - not about shifting the average.

    You know what I hate? When somebody else is right and I'm not. Still, the next time this situation comes about, I'll be the one in the right.

    The solution is painfully simple:

    roll against the PC's reputation.

    If it succeeds, the family the client's hairColor belongs to replaces the template's.

    Otherwise, the fashion stays the same

    I'm keeping averaging for the spectrum values. We don't want the player to have total control over fashions until the endgame.
  • Sounds good. Simple solutions are almost always the best... ;-)
Sign In or Register to comment.