Wednesday, April 8, 2015

Alibi Generation

In one of my classes I took on using an AI application that would create Alibis at run time. When looking into the process itself is seem to use mostly statistic Algorithm to choose which alibi to create. So for this it mean saving a lot of numbers. The equation itself is Y = { 1/[ σ * sqrt(2π) ] } * e-(x - μ)2/2σ2 . Y is the percent chance at X and the sigma (o looking) is the standard deviation from the mean which is the  where μ is the mean, and σ is the standard deviation. The standard deviation is a normal amount above and below the mean value it would be alright with. So with this we see that we get a single Y value at X. Which means to get a true probability we need to do it many more times. For my generation I go up til I hit the Mean + Deviation. So 25 Characters with 5 deviation I go from 0 - 30 to calculate the first chance of creation. From that point You do from current to that max. So if 5 people were already alive to check the percentage of any number of people between 5 and 30. You would check for 6 - 30. Adding each one would give you a proper percent.

    public const float e = 2.71828f;
    //cumlative probabilty of ans < randVariable based on the mean and standDev
    //so if you wanted to know how long a light bulb would last for 1200 hours or less
    //the mean would be 1000 and dev would be 100
    // you would use CumlativeNormalDis(1200,1000,100) the percentage would be 97
    static public float NormalDis(float randVariable, float mean, float standDev)
    {
        float y = (float)1.0f / (standDev * (float)Math.Sqrt(2.0f * Math.PI));
        float z = -1 * (((randVariable - mean) * (randVariable - mean)) / (2.0f * standDev * standDev));
        float x = e;
        x = (float)Math.Pow(x, z);
        y = y * x;
     
        return y;
    }

    //--------------------------------------------------------------------------------------------
    static public float CumlativeNormalDis(float randVariable, float mean, float standDev)
    {
        float ans = 0;
        for(int i = 0; i < randVariable;i++)
        {
            ans += NormalDis(i, mean, standDev);
        }
        return ans * 100;
    }

This is specifically my two function in order to create the percentage from 0 - 100 cumulatively. As well I leave a comment above on how to use it. You can see how this would be time consuming. Running this equation over and over just to get a percent between 0 - 1. Now imagine with everything on top of this creating full alibis for a character would take time. Luckily you would be doing a sector or even just a current location. You would want to keep the alibis to a smaller amount. Never try to create 1000 full alibis for all character.

I chose full alibi above, when I use full I mean not only are we deciding how this certain character would look like, but some background some likes dislikes, this way if we allow communication between the player and say this NPC, he would actually know why he was standing where he was. He choose lets say to grab a coffee from place X over place Y and the player watched him walk from right next to the other place all the way to X. With just random pathing there is no reason for him other than looking good to make him walk. However if he has an alibi that states he loves the scones from this place and hates the coffee from the other he actually has a reason(an alibi) to go through the extra walking.

Now if I was to put this into a full game I envision, some would need to be created live like why they are pathing to a location. However some of the background looks, and some likes and dislikes could be created before and left in groups. This way you have a couple option to put in an area. So each say grid space you would create at once has 3-4 variations saved. This way they were run before the game was even shipped and this would save a lot of time and allow that to be used in the game. However the use during is still feasible and the ability to take these alibis later and populate an area to a reasonable amount not having too many or too few people at one time can help trick a player.

As well very detailed alibis help create this layer of confusion, was this character built, have a seen him/her before, Or is this a new character, the player wouldn't be able to tell unless he remember and talked to every player he has ever met. This also allows a proper flow of character that look like they belong somewhere in the game. It keeps characters that don't look like they belong in lets say a library from a library and those who would be there go there. It adds a nice level of belief to the player when he walks through an open world. Overall I believe using these alibis is extremely helpful to a player, to fully immerse in the world. When they talk to anyone and they have the alibis and background on their life it looks like the world is real. If you walked up and got a generic hello for hundredth time it can break the immersion. You as a developer can go as deep into the alibi pool as possible even giving details on work, and personal history of the character in the world. You can go as little as a suit or tee-shirt.

No comments:

Post a Comment