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 NeuralNetwork LoadNetwork(string path) { var json = !File.Exists(path) ? "" : File.ReadAllText(path); return(json == "" ? null : StringSerializationAPI.Deserialize(typeof(NeuralNetwork), json) as NeuralNetwork); }
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); } } }