• Register

We're an indie team developing a series of dark-themed mystery games and light novels, set in a world called Kikai.

Post news Report RSS Kai's bravery

Kai learns how to react to enemies from the way the player reacts. He could either be brave, always confronts the enemies without fear or could simply be a coward, just runs away all the time. This bravery of his depends on how the player plays the game.

Posted by on

Summary

Kai learns how to react to enemies from the way the player reacts. He could either be brave, always confronts the enemies without fear or could simply be a coward, just runs away all the time. This bravery of his depends on how the player plays the game.

Prototype

At the beginning, Kai is coward in general. His coward level is randomly generated though. For some players, he just runs away all the time. For others, he might actually choose to confront the enemies when in real danger.

(a rather brave newborn Kai)

(a not so brave newborn Kai)

The bravery level B varies from 0 to 1. Kai is bolder when B is closer to 1 and tends to run away when B is closer to 0.
The cool thing is that this bravery level B differs with situations. Kai won’t just either run away or confront the enemies all the time, he might run in one situation (the enemy is still very far) and confront in another (the enemy has already come close).

Now let’s see how Kai grows!
- With an aggressive player, Kai's bravery might change like this:

>>>



- With a rather shy player, Kai's bravery might change like this:

>>>>



A more balanced player will help Kai grow the bravery level B to around 0.5 for different situations.

We could also easily expand Kai's observations to base his decision on, not only how far the enemy is or has it detected Kai or not, but also what kind of weapon the enemy’s holding, how threatening it is, is there a closet nearby... The number of decisions could also be easily expanded, adding the options to hide in a nearby closet, setting up traps, etc.

Note that this model is only for Kai's bravery, not Kai's aggressiveness, since Kai can either knock the enemy off, put it to sleep or kill it when confronted. Kai's willingness to kill is then another model, influenced by the player and different situations. These models can link with each other and by designing different models like these, we could develop really deep and realistic AIs.

These models also have a learning rate and a momentum used to define how fast the AI learns. So we can control how fast Kai grows or is influenced. For example, killing the first person will make killing a second one easier, while sparing a life or two won’t really make one less likely to kill. A few runaways also won’t immediately turn someone into a coward.

Programming

Use a simple Neural Network with Stochastic Gradient Descent.
Implemented using classic OOP classes without matrix multiplication, since importing libraries into UE could be heavy, buggy and anti cross-platform. Also, implementing my own Neural Network helps boost my understanding of it, which is still quite low.
To do: Optimize the Neural Network code, make sure SGD works well with data gathered real time in game. Learn more Neural Network, Gradient Descent & Machine Learning techniques.

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: