Запуск млагентов Unity без терминала в сценарии C#C#

Место общения программистов C#
Anonymous
Запуск млагентов Unity без терминала в сценарии C#

Сообщение Anonymous »

Я работаю над проектом mlagents и пытаюсь запустить оболочку Python при нажатии кнопки «Воспроизвести», а не вводить команду в терминале. Я работаю на Mac, и мы планируем портировать это на Raspberry Pi. Вот что у меня есть на данный момент. Ошибки нет, но агенты ничего не делают.

Код: Выделить всё

using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;

public class Bootstrap : MonoBehaviour
{
public GameObject environment;
// Start is called before the first frame update
void Start()
{

var command = "/Library/Frameworks/Python.framework/Versions/3.10/bin/mlagents-learn";
var scriptFile = "/Users/brennanmoores/Documents/results/configuration.yaml";
var arguments = "";
if (FighterAgent.episode == 0) {
arguments = "--run-id=fighterTest --time-scale=1 --capture-frame-rate=0 --force";
} else {
arguments = "--run-id=fighterTest --time-scale=1 --capture-frame-rate=0 --resume";
}

ProcessStartInfo startInfo = new ProcessStartInfo {
FileName = command,
Arguments = $"{scriptFile} {arguments}",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = false
};

using (Process process = new Process()) {
process.StartInfo = startInfo;
process.Start();

while (!process.StandardOutput.EndOfStream) {
string output = process.StandardOutput.ReadLine();
UnityEngine.Debug.Log(output);
}

}

var env = Instantiate(environment, new Vector2(0, 0), Quaternion.identity);
var processes = Process.GetProcesses();
foreach (var p in processes) {
try {
if (p.ProcessName == "Python") {
UnityEngine.Debug.Log(p.ProcessName);
}
} catch {

}
}
}

// Update is called once per frame
void Update()
{

}
}
Я пытался обойти некоторые команды, включая удаление WaitforExit() и изменение каталогов огня, но ИИ остается неподвижным.

Подробнее здесь: https://stackoverflow.com/questions/787 ... arp-script

Вернуться в «C#»