资源简介
Unity开发人工智能坦克大战项目源码
代码片段和文件信息
using System;
using UnityEngine;
using SPINACH.AI;
namespace ArtificialTankDriver_by_QI {
public class TankDriver : MonoBehaviour {
public Tank target;
public float viewRange;
public GeneticOptimizeableNerualNetwork network;
private void Awake() {
target = GetComponent();
network = new GeneticOptimizeableNerualNetwork(53);
var actvationFunction = new TanhFunction();
for (var i = 0; i < network.activateFunctions.Length; i++) {
network.SetActivationFunctionForlayer(i actvationFunction);
}
}
public double CalculateFitness() {
network.fitness = target.score;
return network.fitness;
}
//call per training update.
public void DoSomethingUseful() {
// calculate all input features
var inputs = new double[5];
var closestEnemy = target.ClosestEnemy(viewRange);
//assuming that closest one is always the one it trying to attack.
//distance between enemy.
inputs[0] = closestEnemy != null ? Vector3.Distance(transform.position closestEnemy.position) / viewRange : 1d;
//cos to enemy.
inputs[1] = closestEnemy != null ? Vector3.Dot(transform.right (closestEnemy.position - transform.position).normalized) : 1d;
//is weapon ready ?
inputs[2] = target.weaponReady ? 1d : 0d;
// current speed.
inputs[3] = target.rigidbody.velocity.magnitude / target.maxSpeed;
// current torque.
inputs[4] = target.rigidbody.angularVelocity.magnitude / target.maxTorque;
//feedforward
var output = network.Compute(inputs);
//drive
target.SetMove((float)output[0]);
target.SetRotate((float)output[1]);
if(output[2] > 0) target.Shoot();
}
private void OnDrawGizmosSelected() {
Gizmos.color = Color.blue;
Gizmos.DrawWireSphere(transform.positionviewRange);
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\
文件 6148 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\.DS_Store
文件 452 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\.gitignore
文件 11357 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\LICENSE
目录 0 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Package\
文件 6148 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Package\.DS_Store
目录 0 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\
文件 6148 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\.DS_Store
目录 0 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\ArtificialTankDriver by QI\
文件 6148 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\ArtificialTankDriver by QI\.DS_Store
目录 0 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\ArtificialTankDriver by QI\.idea\
目录 0 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\ArtificialTankDriver by QI\.idea\.idea.ArtificialTankDriver by QI\
目录 0 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\ArtificialTankDriver by QI\.idea\.idea.ArtificialTankDriver by QI\.idea\
文件 227 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\ArtificialTankDriver by QI\.idea\.idea.ArtificialTankDriver by QI\.idea\contentModel.xm
文件 340 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\ArtificialTankDriver by QI\.idea\.idea.ArtificialTankDriver by QI\.idea\modules.xm
文件 72341 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\ArtificialTankDriver by QI\.idea\.idea.ArtificialTankDriver by QI\.idea\workspace.xm
文件 654 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\ArtificialTankDriver by QI\.idea\.idea.ArtificialTankDriver by QI\riderModule.iml
目录 0 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\ArtificialTankDriver by QI\Assets\
文件 6148 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\ArtificialTankDriver by QI\Assets\.DS_Store
文件 191 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\ArtificialTankDriver by QI\Assets\ArtificialTankDriver by QI.me
目录 0 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\ArtificialTankDriver by QI\Assets\ArtificialTankDriver by QI\
文件 6148 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\ArtificialTankDriver by QI\Assets\ArtificialTankDriver by QI\.DS_Store
文件 191 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\ArtificialTankDriver by QI\Assets\ArtificialTankDriver by QI\Music.me
目录 0 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\ArtificialTankDriver by QI\Assets\ArtificialTankDriver by QI\Music\
文件 2092325 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\ArtificialTankDriver by QI\Assets\ArtificialTankDriver by QI\Music\A Flight in Dark v0.1.2.mp3
文件 477 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\ArtificialTankDriver by QI\Assets\ArtificialTankDriver by QI\Music\A Flight in Dark v0.1.2.mp3.me
文件 191 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\ArtificialTankDriver by QI\Assets\ArtificialTankDriver by QI\Prefabs.me
目录 0 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\ArtificialTankDriver by QI\Assets\ArtificialTankDriver by QI\Prefabs\
文件 3253 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\ArtificialTankDriver by QI\Assets\ArtificialTankDriver by QI\Prefabs\Shell.prefab
文件 209 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\ArtificialTankDriver by QI\Assets\ArtificialTankDriver by QI\Prefabs\Shell.prefab.me
文件 13053 2017-11-09 09:45 Unity-Neural-Network-Tanks-AI-master\Project\ArtificialTankDriver by QI\Assets\ArtificialTankDriver by QI\Prefabs\Tank.prefab
............此处省略778个文件信息
相关资源
- 哈尔滨工业大学-人工智能课件part1
- 人工智能导论+人工智能基础扫描电子
- 华工2017年人工智能备考资料
- 《人工智能产品经理AI:时代PM修炼手
- 全球人工智能发展报告2018
- DCGAN人脸生成项目
- 《分布式机器学习:算法、理论与实
- 多智能体机器学习 强化学习方法
- 不确定性人工智能
- yolov3-tiny.conv.15
- 西交大王永庆《人工智能原理与方法
- Pattern Classification by Richard O. Duda Davi
- 香港科技大学Tensorflow三天速成课件
- 概率机器人课件
- PRML的大牛解读注释版,提供更清晰的
- 人工智能问答百度、图灵接口+flask框
- 腾讯2017全球人工智能人才白皮书
- 游戏开发中的人工智能 中文 pdf
- 中国象棋源码+论文人工智能,搜索算
- 广东工业大学人工智能往年试题
- 北京大学-曹建-人工智能实践TensorFl
- 人工智能软件 - Visual Prolog 7.1 CE版附注
- 2018携程技术报告
- 王万良编著,人工智能及其应用第三
- 自然场景OCR(YOLOv3+CRNN)
- 清华大学、中国人工智能学会重磅发
- 王万良人工智能及其应用3版ppt
- 人工智能 李开复谈AI如何重塑个人 商
- The Elements of Statistical Learning(2nd)详
- PRML模式识别与机器学习_马春鹏译版(
评论
共有 条评论