public void LogLearn(string session, string playSession, MiniGameCode miniGameCode, List <LearnResultParameters> resultsList) { var learnRules = GetLearnRules(miniGameCode); foreach (var result in resultsList) { float score = 0f; float successRatio = result.nCorrect * 1f / (result.nCorrect + result.nWrong); switch (learnRules.voteLogic) { case MiniGameLearnRules.VoteLogic.Threshold: // Uses a binary threshold float threshold = learnRules.logicParameter; score = successRatio > threshold ? 1f : -1f; break; case MiniGameLearnRules.VoteLogic.SuccessRatio: // Uses directly the success ratio to drive the vote score = Mathf.InverseLerp(-1f, 1f, successRatio); break; } score *= learnRules.minigameImportanceWeight; score += learnRules.minigameVoteSkewOffset; var data = new LogLearnData(session, playSession, miniGameCode, result.table, result.elementId, score); db.Insert(data); // We also update the score for that data element UpdateScoreDataWithMovingAverage(result.table, result.elementId, score, 5); } }
public void TestInsertLogLearnData() { var newData = new LogLearnData(); newData.Session = UnityEngine.Random.Range(0, 10).ToString(); newData.Timestamp = GenericUtilities.GetTimestampForNow(); newData.PlaySession = "1.1.1"; newData.MiniGame = MiniGameCode.Assessment_LetterShape; bool useLetter = RND.value > 0.5f; newData.TableName = useLetter ? "LetterData" : "WordData"; newData.ElementId = useLetter ? RandomHelper.GetRandom(dbManager.GetAllLetterData()).GetId() : RandomHelper.GetRandom(dbManager.GetAllWordData()).GetId(); newData.Score = RND.Range(-1f, 1f); this.dbManager.Insert(newData); PrintOutput("Inserted new LogLearnData: " + newData.ToString()); }