public static void SaveBandit(Bandit bandit) { BinaryFormatter formatter = new BinaryFormatter(); //string path = Application.persistentDataPath + "/bandit.txt"; string path = Application.streamingAssetsPath + "/bandit.txt"; FileStream stream = new FileStream(path, FileMode.Create); BandidData data = new BandidData(bandit); formatter.Serialize(stream, data); stream.Close(); }
public bool LoadBandid() { BandidData data = SaveSystem.LoadBandid(); if (data != null) { init = data.init; totalActions = data.totalActions; count = data.count; score = data.score; UCB1scores = data.UCB1scores; numActions = data.numActions; LoadedFromfile = true; return(true); } LoadedFromfile = false; return(false); }
public static BandidData LoadBandid() { //string path = Application.persistentDataPath + "/bandit.txt"; string path = Application.streamingAssetsPath + "/bandit.txt"; Debug.Log(path); if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); BandidData data = formatter.Deserialize(stream) as BandidData; stream.Close(); return(data); } else { Debug.Log("No BanditData in " + path); return(null); } }