Context & general principles

  • September 10, 2017 at 23:32 #21932
    Moodie Younis

    First off I wanna say that despite some reviews / comments on the lack of documentation for APEX, that i’m pretty pleased by the level of documentation and support provided on this forum. I am by no means a developer, and I am diving into APEX out of pure interest and as a challenge to myself as an indie game designer / developer.

    I have some general questions on approach. Again I am not a master coder but i’ve been intently pouring over the survival shooter demo and other tutorials… I just want to confirm some assumptions I have as a result.

    My game will have multiple characters running the same AIs (move, action…), I will probably cap the number of AI’s at 20…. they will essentially be clones (i will instantiate them), but they will have hardcoded variables attached to them that will evolve over time… or based on the players action… such as age… happiness ect…. all of which are variables the AIs will draw upon to score / determine behavior. Since they are all running the same AIs, I’m concerned about duplication and confusion on the engine in that respect… I guess this is taken care of though since each AI will have its own separate instance of the context provider and ALSO that the AIs (move, act) operate as separate instances on that specific character object (instances of the same class). Am I on the right track here?

    Also, this might seem obvious but its normal for the Context to be called upon everytime an Action is executed or a scorer is calculated, the information in the context is repopulated as such… correct?

    The scorers on the otherhand just refer to the existing context to evaluate something… and then (always) return a value… or nothing.

    Sorry if some of this seems obvious, just want to confirm / get a grasp on this. Would really appreciate some help, thanks!

    September 11, 2017 at 09:14 #21948

    Hi Moodie,

    Thanks for your post.

    As long as each AI game object has its own UtilityAIComponent and Context Provider, they will be individual agents. There will be no mixup from the engine in that regard, of course.

    Technically, the AI is stateless. This means that each AI action, scorer, qualifier, selector, etc. only exists as one instance across the whole project. That one AI entity instance is shared among all AI agents that use it as a part of their Utility AI.

    Thus, it is very important to not attempt to store data in the AI entity itself (action, scorer, etc.). Instead, the Context is the individualized “storage” or “memory” for an AI agent.

    The Context is always provided to all AI entities (actions, scorers, etc.). So yes, it is very normal for the AI entities to operate/evaluate based on the accessible data in the Context. In fact, it is not only ‘normal’, but the actual intended usage.

    The Context is not really ‘populated’ each time it is passed. In fact, it is never really ‘populated’ in the traditional sense by itself. That part is up to you. You need to make sure that you pass the Context whatever data it needs and update it as appropriate for your game. So how often data is updated in the Context, what data is there and where it comes from is all up to you.

    There is no difference in how actions and scorers treat the context. They get passed a reference to it, and you decide what to do with it. In some cases, you may not make use of the Context at all in a particular scorer or action, e.g. if the data is accessible statically or you just need to output a random number.

    September 12, 2017 at 05:36 #21952
    Moodie Younis

    Rami, Thanks very much for the rundown. Very helpful

    After much careful and patient work, i’ve got my AI up and running with an object pooling framework and the rest. Quite easy to build basic behaviors once you grasp the concepts.

You must be logged in to reply to this topic.