예제 #1
0
        public static Genome LoadGenome(string path)
        {
            var json = !File.Exists(path)
                ? ""
                : File.ReadAllText(path);

            return(json == "" ? null : StringSerializationAPI.Deserialize(typeof(Genome), json) as Genome);
        }
예제 #2
0
        public static NeuralNetwork LoadNetwork(string path)
        {
            var json = !File.Exists(path)
                ? ""
                : File.ReadAllText(path);

            return(json == "" ? null : StringSerializationAPI.Deserialize(typeof(NeuralNetwork), json) as NeuralNetwork);
        }
예제 #3
0
        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);
                }
            }
        }