public static NeuralNetwork LoadNetwork(string path) { var json = !File.Exists(path) ? "" : File.ReadAllText(path); return(json == "" ? null : StringSerializationAPI.Deserialize(typeof(NeuralNetwork), json) as NeuralNetwork); }
public static Genome LoadGenome(string path) { var json = !File.Exists(path) ? "" : File.ReadAllText(path); return(json == "" ? null : StringSerializationAPI.Deserialize(typeof(Genome), json) as Genome); }
public static void SaveNetwork(NeuralNetwork save, string path) { var json = StringSerializationAPI.Serialize(typeof(NetworkSave), save); var file = new FileInfo($"{Application.persistentDataPath}/networkSaves/{path}"); file.Directory?.Create(); File.WriteAllText(file.FullName, json); }
private static IEnumerator DownloadGenomeCoroutine(string url, Action <Genome> callback, Action <string> fallback) { using (var request = UnityWebRequest.Get(url)) { yield return(request.SendWebRequest()); if (request.isNetworkError || request.isHttpError) { fallback(request.error); } else { callback(StringSerializationAPI.Deserialize(typeof(Genome), request.downloadHandler.text) as Genome); } } }