Tuesday, April 28, 2015

Basic Java App with Android Studio

As the semester is coming to a close in console I chose to create a basic mobile application in Java. I have done some Java in the past however never for Mobile device. So looking at this I decided to try using Android Studio which had some reviews and go through the first tutorial. First looking at how easily the program linked with my nexus was great. Many applications I have used they have ran into some step where my computer and the nexus wouldn't connect and this walkthrough went through great.

From there I opened and created my first project. This is great between the XML and Java, they work so smooth together it is easy to define strings in the XML and than use them with your program using @ after defining it. I went through the basic Activity screen via the parent process so that one would call the other.

This took a bit and some steps on the walk through were left out or confusing, but the application went smooth and at the end got a basic app, that takes the text of the user and than outputs it into the other activity afterwards. Overall this was very fun and I see myself continuing the tutorial both for understanding Mobile development from something other than Unity and Action-script (All I have done in the past.) Also it will help me develop better Java skills, which I have written very little Java as a whole, and have heard many good things about the language.

Physics Rigid Body


Currently coming into the final Project, I ran into several problems and the largest one was time. Currently I have created the Rigid-Body, that knows a correct Update and has a gravity generator so the rigid-Sphere will fall. As well I have gone through multiple narrow checks in a collision detector class, that takes into sphere to plane all the way to box to box. However with my system as it currently can only take into an account for Sphere creation boxes in order to get textures I would have to create a whole graphics System. OpenGL has a nice sphere that allows easy texture adding in the basic functionality. My goal in the next few days is a hope of at least getting the collision detection and resolution for the ground. Currently there is Sphere to plane collision check. So I would need to give the Ground a CollisionPlane, and the Rigid-Sphere a CollisionSphere that it could check during frames to see when they collide. When they collide they create a collisionData. These Data's all get kept and than resolved every frame. This way if there are none, you do none, and if there are a 100 you do all 100. I also need to have a max and figure out per frame what are the most important and what can be put off til the next update. Doing 1k collisions per frame could hinder performance.

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.