/// <summary> /// 計算學習領域成績 /// </summary> /// <param name="defaultRule"></param> public void CalculateLearningDomainScore(ScoreCalculator defaultRule) { foreach (StudentScore student in Students) { SemesterScore semsscore = student.SemestersScore[SemesterData.Empty]; SemesterDomainScoreCollection dscores = semsscore.Domain; ScoreCalculator rule = student.CalculationRule; if (rule == null) { rule = defaultRule; } #region 計算各領域加權平均。 //計算學習領域成績。 //decimal? result = CalcDomainWeightAvgScore(dscores, Util.VariableDomains); ScoreResult result = CalcDomainWeightAvgScore(dscores, Util.VariableDomains);; if (result.Score.HasValue) { semsscore.LearnDomainScore = rule.ParseLearnDomainScore(result.Score.Value); } if (result.ScoreOrigin.HasValue) { semsscore.LearnDomainScoreOrigin = rule.ParseLearnDomainScore(result.ScoreOrigin.Value); } #endregion } }
public void ScoreExample7Test() { string pFilePath = "test-golfing2.xml"; string modelname = "golfing"; string paramList = "outlook=\"sunny\""; Pmml pmml = Pmml.loadModels(pFilePath); Assert.NotNull(pmml); TreeModel tree = (TreeModel)pmml.getByName(modelname); Assert.NotNull(tree); // Modification for NullPrediction tree.MissingValueStrategy = MissingValueStrategy.NullPrediction; Dictionary <string, object> lDict = parseParams(paramList); ScoreResult result = tree.Score(lDict); Assert.NotNull(result); Assert.IsNull(result.Value); }
public async Task <List <ScheduledMatchDto> > GetMatches(RequestDto request) { //TODO: Refactor //Convert the list of selected list to the string of filter var codes = GetCompetitionsCodes(request.LeaguesChecked); var matchProvider = MatchProvider.Create().With(_httpClient).Build(); var matches = await matchProvider.GetAllMatches("competitions", codes, "dateFrom", request.StartingDate.ToString("yyyy-MM-dd"), "dateTo", request.EndingDate.ToString("yyyy-MM-dd")); var result = new List <ScheduledMatchDto>(); foreach (var match in matches) { Enum.TryParse(match.Status.ToUpper(), out Status state); ScoreResult scoreResult = new ScoreResult(match.Score.FullTime.HomeTeam, match.Score.FullTime.AwayTeam); result.Add(new ScheduledMatchDto( match.HomeTeam.Name, match.AwayTeam.Name, match.UtcDate, state, scoreResult, (int)match.Matchday, new LeagueDto(match.Competition.Name, match.Competition.Area.Name) )); } //Filter matches with selected status result = result.Where(m => request.StatusChecked.Contains(m.Status)).ToList(); return(result); }
private void SetScore(ScoreResult result, bool redWinner) { _playerCache[result.RedOffensive.Id].UpdateScore(result.RedOffensive.ScoreCount, result.Story, redWinner, true); _playerCache[result.RedDefensive.Id].UpdateScore(result.RedDefensive.ScoreCount, result.Story, redWinner, false); _playerCache[result.BlueOffensive.Id].UpdateScore(result.BlueOffensive.ScoreCount, result.Story, !redWinner, true); _playerCache[result.BlueDefensive.Id].UpdateScore(result.BlueDefensive.ScoreCount, result.Story, !redWinner, false); }
private void AddScoreResults(ScoreResult sr, long playerId) { ReplayMatchPlayerScoreResult playerScore = new ReplayMatchPlayerScoreResult { ReplayId = ReplayId, Assists = sr.Assists, PlayerId = playerId, CreepDamage = sr.CreepDamage, DamageTaken = sr.DamageTaken, Deaths = sr.Deaths, ExperienceContribution = sr.ExperienceContribution, Healing = sr.Healing, HeroDamage = sr.HeroDamage, MercCampCaptures = sr.MercCampCaptures, MetaExperience = sr.MetaExperience, MinionDamage = sr.MinionDamage, SelfHealing = sr.SelfHealing, SiegeDamage = sr.SiegeDamage, SoloKills = sr.SoloKills, StructureDamage = sr.StructureDamage, SummonDamage = sr.SummonDamage, TakeDowns = sr.Takedowns, TimeCCdEnemyHeroes = sr.TimeCCdEnemyHeroes.HasValue ? sr.TimeCCdEnemyHeroes.Value.Ticks : (long?)null, TimeSpentDead = sr.TimeSpentDead, TownKills = sr.TownKills, WatchTowerCaptures = sr.WatchTowerCaptures, }; ReplaysDb.MatchPlayerScoreResult.CreateRecord(ReplaysContext, playerScore); }
public AIAction Decide(AIInfo aiInfo) { float cutoff = float.MinValue; aiInfo.lastDecisionTime = GameTimer.Instance.GetFrameTimestamp(); ScoreResult bestResult = new ScoreResult(); List <Decision> decisions = aiInfo.decisions; for (int i = 0; i < decisions.Count; i++) { Decision decision = decisions[i]; ScoreResult result = decision.evaluator.Score(aiInfo.Entity, decision, cutoff); if (result.score > cutoff) { cutoff = result.score; bestResult = result; } } bestResult.action.SetContext(bestResult.context); aiInfo.action = bestResult.action; return(bestResult.action); }
// only called when we know for sure we have a double plus private void ScoreDoublePlus(ScoreResult originalPlus, ScoreResult doublePlus) { // error checking, just to be sure: if (originalPlus == ScoreResult.None || doublePlus == ScoreResult.None) { // we should never get here return; } // double same if (originalPlus == ScoreResult.Same && doublePlus == ScoreResult.Same) { score += sameDoublePlusPoints; } // double rainbow https://www.youtube.com/watch?v=OQSNhk5ICTI else if (originalPlus == ScoreResult.Rainbow && doublePlus == ScoreResult.Rainbow) { score += rainbowDoublePlusPoints; } // double mixed else { score += mixedDoublePlusPoints; } }
void LoadHighscores() { Func <List <ScoreboardCore.Data.ScoreResult>, bool, bool> callback = (results, success) => { if (success) { m_scoreboardTitleText.text = $"Leaderboard ({m_playerStats.Level})"; m_scoreboardText.text = ""; for (int i = 0; i < results.Count; ++i) { ScoreResult result = results[i]; m_scoreboardText.text += $"{i+1}. {result.Score.User} : {result.Score.ScoreValue} \n"; } m_scoreboardText.gameObject.SetActive(true); m_scoreboardTitleText.gameObject.SetActive(true); } else { } return(true); }; m_scoreboardComponent.GetHighscores(callback, m_playerStats.Level); }
"Recurrent", 0)] // confidence = 83.18% public void ScoreTest(string pFilePath, string modelname, string paramList, string res, decimal confidence) { Pmml pmml = Pmml.loadModels(pFilePath); Assert.NotNull(pmml); ModelElement model = pmml.getByName(modelname); Assert.NotNull(model); Assert.IsInstanceOf(typeof(TreeModel), model); TreeModel tree = (TreeModel)model; Dictionary <string, object> lDict = parseParams(paramList); ScoreResult result = tree.Score(lDict); Assert.NotNull(result); /*foreach(Node item in result.Nodes) * { * Console.WriteLine("Node {0} = score {1}", item.Id, item.Score); * * foreach(ScoreDistribution it2 in item.ScoreDistributions) * Console.WriteLine("\tScore Dist. {0} ({1}) = {2}", it2.Value, it2.RecordCount, it2.Confidence); * }*/ Assert.AreEqual(res, result.Value); Assert.AreEqual(confidence, result.Confidence); }
public void SimplePredicateIsNotMissingTest() { string pmmlStr = @"<?xml version=""1.0"" ?> <PMML version=""4.1"" xmlns=""http://www.dmg.org/PMML-4_1"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""> <Header copyright=""www.dmg.org"" description=""A very small tree model to test isNotMissing operator.""/> <DataDictionary numberOfFields=""2"" > <DataField name=""in"" optype=""continuous"" dataType=""double""/> <DataField name=""out"" optype=""continuous"" dataType=""double""/> </DataDictionary> <TreeModel modelName=""SimpleIsNotMissingTest"" functionName=""classification""> <MiningSchema> <MiningField name=""in""/> <MiningField name=""out"" usageType=""predicted""/> </MiningSchema> <Node score=""0""> <True/> <Node score=""1""> <SimplePredicate field=""in"" operator=""isNotMissing"" /> </Node> </Node> </TreeModel> </PMML> "; XmlDocument xml = new XmlDocument(); xml.LoadXml(pmmlStr); Pmml pmml = Pmml.loadModels(xml); ScoreResult res = pmml.getByName("SimpleIsNotMissingTest").Score(parseParams(" in=\"foo\" ")); Assert.AreEqual("1", res.Value); }
void Score() { List <ScoreResult> playerScores = new List <ScoreResult>(); foreach (int id in playerList) { BattlerData battlerData = battlers[id]; ScoreResult score = new ScoreResult(); foreach (int targetID in targetList) { if (battlerData.againstList.Contains(targetID)) { score.against += 1; } if (battlerData.counterList.Contains(targetID)) { score.counter += 1; } } playerScores.Add(score); } RefreshScoreLayout(playerScores); }
private void ScoreRequestCompleted(AsyncOperation obj) { UnityWebRequestAsyncOperation oper = obj as UnityWebRequestAsyncOperation; UnityWebRequest www = oper.webRequest; string unique_identifier = SystemInfo.deviceUniqueIdentifier; string[] segments = www.url.Split('/'); string code = ""; if (segments.Length > 0) { code = Decrypt(segments[segments.Length - 1], unique_identifier); } if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); bool should_add = hashes.Contains(sha256_hash(code)) && !Scores.ContainsKey(code); try { scoreResult(should_add, code); } finally { if (should_add) { Scores.Add(code, ReportingState.NONE); } www.Dispose(); } } else { // Show results as text //Debug.Log(www.downloadHandler.text); ScoreResult result = ScoreResult.CreateFromJSON(www.downloadHandler.text); try { scoreResult(result.success, code); } finally { if (!Scores.ContainsKey(code)) { Scores.Add(code, ReportingState.NONE); } if (result.success && Scores[code] != ReportingState.REPORTED) { Scores[code] = ReportingState.REPORTED; } www.Dispose(); } } }
public ScoreResult Eval(int[] dice) { var result = new ScoreResult(); result.DiceUsed = dice.Where(d => d == _dieValue).ToArray(); result.Score = result.DiceUsed.Count() * _score; result.RuleUsed = this; return(result); }
public ScoreResult CurrentFrameScore() { var result = new ScoreResult { ScoreType = IsFinalScore() ? ScoreStatus.Final : ScoreStatus.Temporary, Score = PinsDroppedOfAThrow.Sum() + PinsDroppedOfABonusBall.Sum() }; return(result); }
public void RandomTest(string pFilePath) { Pmml pmml = Pmml.loadModels(pFilePath); Assert.NotNull(pmml); ScoreResult res = pmml.Models[0].Score(new Dictionary <string, object>()); Assert.IsNotNull(res); }
/// <summary> /// 選択されているスコアデータを編集する。 /// </summary> private void ScoreDataEdit() { // Get selected item ScoreResult scoreResult = null; int selectedRow = 0; // Get selected row foreach (DataGridViewCell cell in ScoreDataGridView.SelectedCells) { selectedRow = cell.RowIndex; scoreResult = (ScoreResult)ScoreDataGridView.Rows[selectedRow].DataBoundItem; break; } // If can't selected, no action if (scoreResult == null) { return; } // Load id and open window int?musicId = GetTreeViewSelectedMusicId(); // If can't get music id, no action if (musicId == null) { return; } // Get music object from Music ID MusicDao musicDao = new MusicDao(databaseFilePath); Music music = musicDao.selectByMusicId(musicId); music.scoreResultList = new List <ScoreResult>(); music.scoreResultList.Add(scoreResult); using (RegistScoreConfirmForm registScoreConfirmForm = new RegistScoreConfirmForm(ref music, ref music)) { if (DialogResult.OK == registScoreConfirmForm.ShowDialog()) { // Regist data musicDao.InsertOrReplace(music); // Reflesh view RefreshScoreDataGridView(); MessageBox.Show("スコアデータの修正が完了しました。"); } else { // cancel return; } } }
public void CalculateElo_AdjustScoresWhenDifferent_PlayerTwoWin() { var playerOne = new ScoreResult("p1", 1700); var playerTwo = new ScoreResult("p2", 1300); ScoreResult[] scores = { playerOne, playerTwo }; var newScores = scoreCalculator.Calculate(scores, "p2"); Assert.IsTrue(newScores[0].Score == 1671 && newScores[1].Score == 1329, "Player One's score should correctly increase proportional to eloK."); }
public void CalculateElo_AdjustScoresWhenSame() { var playerOne = new ScoreResult("p1", 1500); var playerTwo = new ScoreResult("p2", 1500); ScoreResult[] scores = { playerOne, playerTwo }; var newScores = scoreCalculator.Calculate(scores, "p1"); Assert.IsTrue(newScores[0].Score == 1516 && newScores[1].Score == 1484, "Player One's score should correctly increase proportional to eloK."); }
public ScoreResult GetScoreResult(int[] diceRollValues) { var result = new ScoreResult(); if (diceRollValues.All(x => win.Contains(x))) { result.Multiplier = 2; } return(result); }
public ScoreResult GetCurrentScores() { var result = new ScoreResult(); foreach (var frame in Frames) { var frameScore = frame.CurrentFrameScore(); result.ScoreType = frameScore.ScoreType == ScoreStatus.Final ? ScoreStatus.Final : ScoreStatus.Temporary; result.Score += frameScore.Score; } return(result); }
/// <summary> /// 対象のスコアリザルトを削除する。 /// </summary> /// <param name="scoreResult">削除対象のスコアリザルト</param> /// <returns>true:登録成功、false:登録失敗</returns> public bool DeleteScoreResult(ScoreResult scoreResult) { // return value initialized with false bool result = false; logger.Info("Music dao insert or replace start."); logger.Info("Target score data id = " + scoreResult.id); // database access section using (SqliteConnection connection = new SqliteConnection(builder.ToString())) { // connection open connection.Open(); // enable transaction using (SqliteTransaction transaction = connection.BeginTransaction()) using (SqliteCommand command = connection.CreateCommand()) { // SQL command.CommandText = "DELETE FROM T_SCORE_RECORD WHERE @id = id;"; // query to log logger.Info(command.CommandText); // prepared statement command.Parameters.AddWithValue("id", scoreResult.id); // execute if (command.ExecuteNonQuery() == 1) { logger.Info("Delete result is ok."); } else { logger.Info("Delete result NG!"); throw new SqliteException("Delete count is ng, not 1.", 5000); } // clear parameters command.Parameters.Clear(); // commit transaction.Commit(); // successful all command result = true; } } return(result); }
public IRule BestRule(int[] dice) { ScoreResult bestResult = new ScoreResult(); foreach (var rule in _rules) { var result = rule.Eval(dice); if (result.Score > bestResult.Score) { bestResult = result; } } return(bestResult.RuleUsed); }
public void ScoreExample1Test() { string pFilePath = "test-ruleset1.xml"; string modelname = "NestedDrug"; string paramList = "BP='HIGH', K=0.0621, Age = 36, Na = 0.5023"; string res = "may play"; decimal confidence = 0.47M; Pmml pmml = Pmml.loadModels(pFilePath); Assert.NotNull(pmml); ModelElement model = pmml.getByName(modelname); Assert.NotNull(model); Assert.IsInstanceOf <RuleSetModel>(model); RuleSetModel rs = (RuleSetModel)model; // Check exemple 1 as 3 RuleSelectionMethod for first node Assert.IsNotNull(rs.RuleSet); Assert.IsNotNull(rs.RuleSet.RuleSelectionMethods); Assert.AreEqual(3, rs.RuleSet.RuleSelectionMethods.Count); // Check 3 Rule Assert.AreEqual(3, rs.RuleSet.Rules.Count); // Modification for aggregateNode //tree.MissingValueStrategy = MissingValueStrategy.AggregateNodes; Dictionary <string, object> lDict = parseParams(paramList); ScoreResult result = rs.Score(lDict); Assert.NotNull(result); /*foreach(Node item in result.Nodes) * { * Console.WriteLine("Node {0} = score {1}", item.Id, item.Score); * * foreach(ScoreDistribution it2 in item.ScoreDistributions) * Console.WriteLine("\tScore Dist. {0} ({1}) = {2}", it2.Value, it2.RecordCount, it2.Confidence); * }*/ Assert.AreEqual(res, result.Value); Assert.AreEqual(confidence, result.Confidence); }
public ScoreResult GetScoreResult(int[] diceRollValues) { var result = new ScoreResult(); for (int i = 1; i <= 6; i++) { if (diceRollValues.Count(x => x == i) == 3) { result.Multiplier = 3; break; } } return(result); }
public void ScoreCarfTest(string paramList, string res, decimal confidence) { string pFilePath = "models\\RuleSetCarrefour.xml"; string modelname = "CARF-20140124"; Pmml pmml = Pmml.loadModels(pFilePath); Assert.NotNull(pmml); ModelElement model = pmml.getByName(modelname); Assert.NotNull(model); Assert.IsInstanceOf <RuleSetModel>(model); RuleSetModel rs = (RuleSetModel)model; // Check CARF as 1 RuleSelectionMethod for first node Assert.IsNotNull(rs.RuleSet); Assert.IsNotNull(rs.RuleSet.RuleSelectionMethods); Assert.AreEqual(1, rs.RuleSet.RuleSelectionMethods.Count); Assert.AreEqual("firstHit", rs.RuleSet.RuleSelectionMethods[0].Criterion); // Check 11 Rule Assert.AreEqual(11, rs.RuleSet.Rules.Count); // Modification for aggregateNode //tree.MissingValueStrategy = MissingValueStrategy.AggregateNodes; Dictionary <string, object> lDict = parseParams(paramList); //for ScoreResult result = rs.Score(lDict); Assert.NotNull(result); /*foreach(Node item in result.Nodes) * { * Console.WriteLine("Node {0} = score {1}", item.Id, item.Score); * * foreach(ScoreDistribution it2 in item.ScoreDistributions) * Console.WriteLine("\tScore Dist. {0} ({1}) = {2}", it2.Value, it2.RecordCount, it2.Confidence); * }*/ Assert.AreEqual(res, result.Value); Assert.AreEqual(confidence, result.Confidence); }
private static ScoreResult CalcDomainWeightAvgScore(SemesterDomainScoreCollection dscores, UniqueSet <string> excludeItem) { decimal TotalScore = 0, TotalScoreOrigin = 0, TotalWeight = 0; foreach (string strDomain in dscores) { // 高雄語文只顯示不計算 if (Program.Mode == ModuleMode.KaoHsiung) { if (strDomain == "語文") { continue; } } if (excludeItem.Contains(strDomain.Trim())) { continue; } SemesterDomainScore dscore = dscores[strDomain]; if (dscore.Value.HasValue && dscore.Weight.HasValue) //dscore.Value 是原來的結構。 { TotalScore += (dscore.Value.Value * dscore.Weight.Value); //擇優成績。 if (dscore.ScoreOrigin.HasValue) { TotalScoreOrigin += (dscore.ScoreOrigin.Value * dscore.Weight.Value); //原始成績。 } else { TotalScoreOrigin += (dscore.Value.Value * dscore.Weight.Value); //將擇優當成原始。 } TotalWeight += dscore.Weight.Value; //比重不會因為哪種成績而不同。 } } if (TotalWeight <= 0) { return(new ScoreResult()); //沒有成績。 } ScoreResult sr = new ScoreResult(); sr.Score = TotalScore / TotalWeight; sr.ScoreOrigin = TotalScoreOrigin / TotalWeight; return(sr); }
public ScoreResult Validate(int[] diceRollValues) { var result = new ScoreResult(); foreach (var rule in scoreRules) { result = rule.Value.GetScoreResult(diceRollValues); if (result.IsFault || result.Multiplier > 0 || result.Score > 0) { break; } } return(result); }
public List <ScoreResult> GetScoreResultList() { var _scoreResults = new List <ScoreResult>(); var x = 0; foreach (Score _score in Players[0].Scorecard.ScoreList) { var _newResult = new ScoreResult { Name = _score.Name, }; try { if (Players[0] != null) { _newResult.PlayerOne = Players[0].Scorecard.ScoreList[x].Value; } if (Players[1] != null) { _newResult.PlayerTwo = Players[1].Scorecard.ScoreList[x].Value; } if (Players[2] != null) { _newResult.PlayerThree = Players[2].Scorecard.ScoreList[x].Value; } if (Players[3] != null) { _newResult.PlayerFour = Players[3].Scorecard.ScoreList[x].Value; } if (Players[4] != null) { _newResult.PlayerFive = Players[4].Scorecard.ScoreList[x].Value; } } catch (ArgumentOutOfRangeException) { } finally { _scoreResults.Add(_newResult); x++; } } AllPlayerScores = _scoreResults; return(_scoreResults); }
public void Evaluate(ScoringRules rules) { if (Status != CallForSpeechStatus.New) { throw new ApplicationException("Cannot accept application that isn't new"); } ScoreResult = rules.Evaluate(this); if (!ScoreResult.IsRed()) { Status = CallForSpeechStatus.EvaluatedByMachine; } else { Status = CallForSpeechStatus.Rejected; } }
public ExecutionStatus TryEvaluate(ScoringRules rules) { if (Status != CallForSpeechStatus.New) { return(ExecutionStatus.LogicError("Cannot accept application that isn't new")); } ScoreResult = rules.Evaluate(this); if (!ScoreResult.IsRed()) { Status = CallForSpeechStatus.EvaluatedByMachine; } else { Status = CallForSpeechStatus.Rejected; } return(ExecutionStatus.LogicOk()); }
// check the whole grid to see if there is a valid score private void CheckForScore() { // a helper variable to track score results ScoreResult[,] scoreResults = new ScoreResult[gridWidth, gridHeight]; // avoid checking the top or bottom rows, or left or right edges for (int x = 1; x < gridWidth - 1; x++) { for (int y = 1; y < gridHeight - 1; y++) { // check for a plus once, store the result, and then do game logic later. // This way, we avoid checking and rechecking the same cubes over and over. scoreResults[x,y] = CheckForPlus (x, y); } } // look at the results and see if we find any double pluses or regular pluses for (int x = 1; x < gridWidth - 1; x++) { for (int y = 1; y < gridHeight - 1; y++) { // if we don't have a score if (scoreResults[x,y] == ScoreResult.None) { continue; // this continues to the next iteration of the for() loop } // Otherwise, we have a valid plus of some sort, // so we turn this group of cubes gray CreateGrayPlus(x, y); // do we have a horizontal double plus, within the bounds of the grid? // NOTE: if the first comparison is false (x < gridWidth-3), the second comparison won't ever be checked. // Therefore, the order of these comparisons is important here, to avoid going outside the grid and getting an ArrayOutOfBounds exception if (x < gridWidth - 3 && scoreResults[x+2, y] != ScoreResult.None) { CreateGrayPlus(x+2, y); ScoreDoublePlus(scoreResults[x,y], scoreResults[x+2, y]); // change the double plus score result to none to avoid double counting it scoreResults[x+2, y] = ScoreResult.None; } // do we have a vertical double plus, within the bounds of the grid? // NOTE: if the first comparison is false (y < gridHeight-3), the second comparison won't ever be checked. // Therefore, the order of these comparisons is important here, to avoid going outside the grid and getting an ArrayOutOfBounds exception else if (y < gridHeight - 3 && scoreResults[x, y+2] != ScoreResult.None) { CreateGrayPlus(x, y+2); ScoreDoublePlus(scoreResults[x,y], scoreResults[x, y+2]); // change the double plus score result to none to avoid double counting it scoreResults[x, y+2] = ScoreResult.None; } // no double plus, just a normal plus result else { if (scoreResults[x,y] == ScoreResult.Same) { score += samePlusPoints; } else if (scoreResults[x,y] == ScoreResult.Rainbow) { score += rainbowPlusPoints; } } } } }