Search Unity

Creating transitive interactions for utility AI

Discussion in 'Scripting' started by Sendatsu_Yoshimitsu, Mar 13, 2019.

  1. Sendatsu_Yoshimitsu

    Sendatsu_Yoshimitsu

    Joined:
    May 19, 2014
    Posts:
    691
    I've been looking at http://www.gameaipro.com/GameAIPro/GameAIPro_Chapter09_An_Introduction_to_Utility_Theory.pdf as a general guideline to build a sims-style Utility AI where objects in the world advertise actions to fulfill needs. Part of why that system is so clean and scalable in games is because of how generic it is: actions and needs have no external information, they simply advertise what they can personally accomplish.

    Where I'm running into a bit of trouble is in extending that logic to make interactions transitive, so instead of a weight bench allowing a given actor to work out, for example, that same bench also provides a "help <third party> exercise" interaction for every character in the area. The only way I can figure out to accomplish that is by giving each smart object the ability to build and maintain a list of everyone in the area, but that violates compartmentalization pretty badly.

    So am I missing something obvious? The object advertising interactions must have some way of querying for third parties, and it must be doing those checks in advance so it can accurately advertise its capabilities, but that completely undercuts the simplicity of making each object self-contained.
     
  2. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,336
    Having a list of the people in the area seems strange. I think that when you start using the bench, you set a flag that's factored into the utility function of the bench.

    You can't both have the bench not have any information about the surrounding world, and know if it's being used. If you try to do that to keep things "pure", your code will probably be a lot uglier than if you just allow for writing some data to the bench.
     
  3. Sendatsu_Yoshimitsu

    Sendatsu_Yoshimitsu

    Joined:
    May 19, 2014
    Posts:
    691
    I agree, although to be clear it has that knowledge before it's used, which is what was throwing me for a bit of a loop. (This specific example is from sims 3, since that's the most essentialized implementation of this pattern I can think of in games.) You ask it for a list of advertised interactions, and it pops out the individual stuff that it always has, plus a list of 2-person interactions (e.g. 'A trains B with <object>') specific to the individuals in the scene.

    Assuming it really is as straightforward as giving every object some kind of external context, do you see any issues with passing it a generic container with references to every other agent in the area, and simply offloading the task of figuring out which combinations of invoking agent and nearby agents satisfy which interaction preconditions to each individual interaction? I could see that being a bit twitchy in the long term, but as long as the search space is reasonably limited and well-formatted, I can't see many structural drawbacks beyond vaguely ugly architecture.
     
  4. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,336
    Oh, so the 'A trains B with <object>' action takes place before B is interacting with <object>? That makes things harder - I was imagining that if somebody was already using a thing, you got a different action. Not played Sims since the first one over a decade ago, so I'm not that familiar.

    My instinct then is that I'd model these kinds of thing as compound action of some sort. If a thing has the ability to be used by two Sims together, each pair of such a thing and Sim gets an associated action generated. So if you have a weight bench, Tom and Pete, you'd have both a (Tom/bench) and (Pete/bench) action that could be used.

    That will cause a multiplicative amount of actions to consider, but I think you want to prune the search space anyway, so that shouldn't be an issue. Your decision engine could eg. ignore compound actions if either part has a too low score. So don't search all of the bench/person pairs if just training on the bench scores less than eg. 0.3

    Does that sound sensible?
     
  5. Sendatsu_Yoshimitsu

    Sendatsu_Yoshimitsu

    Joined:
    May 19, 2014
    Posts:
    691
    Sorry for not being clearer! I think your proposal definitely works though- it's much cleaner than passing in a huge chunk of stuff in advance, and something that can be accomplished without any additions to the existing framework; thank you for the consideration! :)