浏览代码

added sensors & controls UI

/hh-develop-fps_game_project
HH 4 年前
当前提交
281e0be1
共有 8 个文件被更改,包括 2029 次插入8 次删除
  1. 999
      Project/Assets/ML-Agents/Examples/Crawler/Prefabs/DynamicPlatform.prefab
  2. 956
      Project/Assets/ML-Agents/Examples/FPS_Game/Scenes/FPS_Game.unity
  3. 10
      Project/Assets/ML-Agents/Examples/FPS_Game/Scripts/FPSAgent.cs
  4. 8
      Project/Assets/ML-Agents/Examples/FPS_Game/Scripts/UI.meta
  5. 26
      config/ppo/FPSAgent.yaml
  6. 27
      Project/Assets/ML-Agents/Examples/FPS_Game/Scripts/UI/UIShowControls.cs
  7. 11
      Project/Assets/ML-Agents/Examples/FPS_Game/Scripts/UI/UIShowControls.cs.meta

999
Project/Assets/ML-Agents/Examples/Crawler/Prefabs/DynamicPlatform.prefab
文件差异内容过多而无法显示
查看文件

956
Project/Assets/ML-Agents/Examples/FPS_Game/Scenes/FPS_Game.unity
文件差异内容过多而无法显示
查看文件

10
Project/Assets/ML-Agents/Examples/FPS_Game/Scripts/FPSAgent.cs


public override void Heuristic(in ActionBuffers actionsOut)
{
var discreteActionsOut = actionsOut.ContinuousActions;
discreteActionsOut[0] = Input.GetKey(KeyCode.W) ? 1 : Input.GetKey(KeyCode.S) ? -1 : 0; //inputV
discreteActionsOut[1] = Input.GetKey(KeyCode.E) ? 1 : Input.GetKey(KeyCode.Q) ? -1 : 0; //inputH
discreteActionsOut[2] = Input.GetKey(KeyCode.D) ? 1 : Input.GetKey(KeyCode.A) ? -1 : 0; //rotate
discreteActionsOut[3] = Input.GetKey(KeyCode.Space) ? 1 : 0; //shoot
var contActionsOut = actionsOut.ContinuousActions;
contActionsOut[0] = Input.GetKey(KeyCode.W) ? 1 : Input.GetKey(KeyCode.S) ? -1 : 0; //inputV
contActionsOut[1] = Input.GetKey(KeyCode.E) ? 1 : Input.GetKey(KeyCode.Q) ? -1 : 0; //inputH
contActionsOut[2] = Input.GetKey(KeyCode.D) ? 1 : Input.GetKey(KeyCode.A) ? -1 : 0; //rotate
contActionsOut[3] = Input.GetKey(KeyCode.Space) ? 1 : 0; //shoot
}

8
Project/Assets/ML-Agents/Examples/FPS_Game/Scripts/UI.meta


fileFormatVersion: 2
guid: 1496d9c0eec614bf8ac019ee7f1fb745
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

26
config/ppo/FPSAgent.yaml


behaviors:
FPSAgent:
trainer_type: ppo
hyperparameters:
batch_size: 128
buffer_size: 2048
learning_rate: 0.0003
beta: 0.01
epsilon: 0.2
lambd: 0.95
num_epoch: 3
learning_rate_schedule: linear
network_settings:
normalize: false
hidden_units: 256
num_layers: 2
vis_encode_type: simple
reward_signals:
extrinsic:
gamma: 0.99
strength: 1.0
keep_checkpoints: 5
max_steps: 2000000
time_horizon: 64
summary_freq: 60000
threaded: true

27
Project/Assets/ML-Agents/Examples/FPS_Game/Scripts/UI/UIShowControls.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class UIShowControls : MonoBehaviour
{
public GameObject controlsCanvas;
// Start is called before the first frame update
void Awake()
{
controlsCanvas.SetActive(false);
}
public void ToggleControlsUI()
{
controlsCanvas.SetActive(!controlsCanvas.activeInHierarchy);
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.C))
{
ToggleControlsUI();
}
}
}

11
Project/Assets/ML-Agents/Examples/FPS_Game/Scripts/UI/UIShowControls.cs.meta


fileFormatVersion: 2
guid: 249c3453371f54c59b8354c7f95b3f35
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存