Код: Выделить всё
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()
{
}
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... arp-script