ML-Agents training smart AI skills

ML-Agents is a powerful tool for Unity to develop intelligent AI, but the learning curve is relatively steep, and it requires some understanding of machine learning algorithms. After using the training mode and curiosity mode, I summarize some usage skills for the reference of enthusiasts.
1. The training mode is a mode in which the teacher leads the students. The player operates the AI ​​and has the same parameters as the Agents AI, except that the control and judgment of the computer brain is replaced by humans, which is the decision-making choice of Actions. Manual operations can not only allow AI to learn movement and some operations, but AI can continue to use algorithms that enhance learning to conduct two-way brain training. The configuration process is relatively troublesome, you can refer to the official example.
2. For some complex environments and multiple operations, such as choosing to attack while evading, and optimizing search for items in the process of picking up props, attacking, and escaping, in this complicated situation, try to turn on the curiosity mode, in the trainer. Modify the curiosity parameter to true in the ymal configuration. This will try to prevent AI from spinning around in place, wasting training time, and completely failing to meet the goals and requirements of use.
3. Some simple training scenes are generally easy to achieve the goal, but like our normal game, AI has more operation actions, and the scene is also more complicated, such as the detection of collision objects such as various stones and walls, so in the basic After the training is satisfied, it is necessary to build complex real scenes for training scenes. Personally think this step is very important. Don't simply reduce the training environment to realize brain file generation. If this is the case, AI will easily get into some complex environments when it comes to real scenes. Unable to make intelligent judgments.
4. The camera mode cannot be used once and for all, and it freezes at the beginning. I don't know what the problem is. I personally feel that it has nothing to do with the graphics card because the mode I configured is CPU mode.
5. AI skill training does not use real skills as much as possible. You can use ray collision instead of ray skills. After training, adjust the real skill parameters to the parameters of ray collision, such as distance, effective radius, etc.
6. When rewriting the action control method, try to add some basic restrictions. For example, if the existence of the target is not detected within 22m, do not release the 20m range attack skills, which obviously cannot attack the enemy.
7. Code part
查找范围敌人并排序
public Transform ClosestEnemy(float viewRange) {
var cols = new List(Physics.OverlapSphere(transform.position, viewRange, enemyMask));
cols.Remove(m_collider);
var firstOrDefault = cols.OrderBy(x => Vector3.Distance(transform.position, x.transform.position)).FirstOrDefault();
return firstOrDefault != null ? firstOrDefault.transform : null;
}

Guess you like

Origin blog.csdn.net/qq_23158477/article/details/107625321