Exemplo n.º 1
0
 void SaveData()
 {
     BinaryFormatter formatter=new BinaryFormatter();
     string path=Application.persistentDataPath+"/playerAI.txt";
     FileStream stream;
     if(File.Exists(path))
     {
         stream=new FileStream(path,FileMode.Open);
     }
     else
     {
         stream=new FileStream(path,FileMode.Create);
     }
     storeddata data=new storeddata(numpopulation,currentGeneration,bestAgentSelection);
     formatter.Serialize(stream,data);
     stream.Close();
 }
Exemplo n.º 2
0
 void LoadData()
 {
     string path=Application.persistentDataPath+"/playerAI.txt";
     if(File.Exists(path))
     {
         fileexist=true;
         BinaryFormatter formatter=new BinaryFormatter();
         FileStream stream=new FileStream (path,FileMode.Open);
         data=formatter.Deserialize(stream) as storeddata;
         stream.Close();
         
         
         
     }
     
     
 }