public TechFactoryParams(Dictionary <string, List <TestTech> > inst, List <int> levels, string techName, double timeProduction, TestStats baseStats, TestPriceBase basePrice) { Inst = inst; Levels = levels; TechName = techName; TimeProduction = timeProduction; BaseStats = baseStats; BasePrice = basePrice; }
public static double CalculatePerplexity(ILanguageModel model, CorpusParsingResult trainingCorpus, StringParsingResult testCorpus, out TestStats testStats) { testStats = new TestStats { UniqueUnksFound = new HashSet<string>(), UniqueWordsFound = new HashSet<string>() }; double logSumOfCorpus = 0; for (int k = 0; k < testCorpus.Sentences.Count; k++) { Sentence sentence = testCorpus.Sentences[k]; double logOfSentence = 0; string previousWord = Constants.Start; string previousPreviousWord = Constants.Start; testStats.TotalSentencesFound++; for (int i = 0; i < sentence.Words.Length; i++) { string calculatedWord = sentence.Words[i]; if (!trainingCorpus.UniqueWords.ContainsKey(sentence.Words[i])) { calculatedWord = Constants.Unknown; testStats.TotalUnksFound++; testStats.UniqueUnksFound.Add(sentence.Words[i]); } testStats.TotalWordsFound++; testStats.UniqueWordsFound.Add(calculatedWord); double modelP = model.P(previousPreviousWord, previousWord, calculatedWord); double logModelP = Math.Log(modelP, 2); logOfSentence += logModelP; previousPreviousWord = previousWord; previousWord = calculatedWord; } if (Double.IsInfinity(logOfSentence)) { throw new InvalidOperationException(); } logSumOfCorpus += logOfSentence; if (Double.IsInfinity(logSumOfCorpus)) { throw new InvalidOperationException(); } if (model is Problem1Model && k % 100 == 0) { Console.WriteLine("Now at sentence {0}/{1}", k, testCorpus.Sentences.Count); } } double sum = logSumOfCorpus / testCorpus.TotalWordCount; return Math.Pow(2, -1*sum); }
public LucPacScripted() : base("LucPacScripted") { _currentAgentState = FiniteState.Wander; _previousAgentState = _currentAgentState; _testStats = new TestStats(); #region State Initialization _states.Add(FiniteState.Wander, new State() { Action = this.Wander, OnSuspend = this.Wander_OnSuspend, OnBegin = this.Wander_OnBegin }); _states.Add(FiniteState.Ambush, new State() { Action = this.Ambush, OnSuspend = this.Ambush_OnSuspend, OnBegin = this.Ambush_OnBegin }); _states.Add(FiniteState.EndGame, new State() { Action = EndGame, OnSuspend = EndGame_OnSuspend, OnBegin = EndGame_OnBegin }); _states.Add(FiniteState.Hunt, new State() { Action = Hunt, OnSuspend = Hunt_OnSuspend, OnBegin = Hunt_OnBegin }); _states.Add(FiniteState.Flee, new State() { Action = Flee, OnSuspend = Flee_OnSuspend, OnBegin = Flee_OnBegin }); #endregion // Create the session ID that will be used for testing this._testSessionId = GenerateSessionID(); this._testStats.SessionID = _testSessionId; // Create the directory that the data is going to be stored in _testDataFolder = Directory.CreateDirectory(Environment.CurrentDirectory + string.Format("/{0}", _testSessionId)); _testImagesFolder = _testDataFolder.CreateSubdirectory("images"); _testLogFolder = _testDataFolder.CreateSubdirectory("logs"); instance = this; _roundDuration.Start(); _stopWatch.Start(); }
public LucPacScripted() : base("LucPacScripted") { m_CurrentState = FiniteState.Wander; m_PreviousFSMState = m_CurrentState; // Initiate a new object of the test stats. m_TestStats = new TestStats(); #region State Initialization /// States that are involved. m_States.Add(FiniteState.Wander, new State() { Action = this.Wander, OnSuspend = this.Wander_OnSuspend, OnBegin = this.Wander_OnBegin }); m_States.Add(FiniteState.Ambush, new State() { Action = this.Ambush, OnSuspend = this.Ambush_OnSuspend, OnBegin = this.Ambush_OnBegin }); m_States.Add(FiniteState.EndGame, new State() { Action = EndGame, OnSuspend = EndGame_OnSuspend, OnBegin = EndGame_OnBegin }); m_States.Add(FiniteState.Hunt, new State() { Action = Hunt, OnSuspend = Hunt_OnSuspend, OnBegin = Hunt_OnBegin }); m_States.Add(FiniteState.Flee, new State() { Action = Flee, OnSuspend = Flee_OnSuspend, OnBegin = Flee_OnBegin }); #endregion // Create the session ID that will be used for testing this.m_TestSessionID = GenerateSessionID(); this.m_TestStats.SessionID = m_TestSessionID; instance = this; m_RoundDuration.Start(); m_Stopwatch.Start(); }
// Use this for initialization void Start() { m_Text = GetComponentInChildren <Text> (); Button exit = GetComponentInChildren <Button> (); exit.onClick.AddListener(OnButtonClicked); s_instance = this; m_ErrorCount = new int[(int)MapType.MapCount]; m_TestDone = new bool[(int)MapType.MapCount]; ShowMessageBox(false); // hide itself after initialization that must be done when active. }
//Create OneDayStats public bool CreateTestStats(TestStatsCreate model) { var ctx = new ApplicationDbContext(); var Cricketer = ctx.Cricketerss.Find(model.CricketerId); if (Cricketer != null) { var entity = new TestStats() { UserId = _userId, DoubleCenturyTest = model.DoubleCenturyTest, HalfCenturyTest = model.HalfCenturyTest, CricketerId = Cricketer.CricketerId }; using (ctx) { ctx.TestStatss.Add(entity); return(ctx.SaveChanges() == 1); } } return(false); }
public override void PreSendServer() { base.PreSendServer(); _msgSeq = TestStats.GetNextClientTimedSeq(); TestStats.ClientMissingTimedSeqs.Add(_msgSeq); }
public override void PreSendClient() { base.PreSendClient(); _msgSeq = TestStats.GetNextClientSeq(); TestStats.ServerMissingSeqs.Add(_msgSeq); }
private string WriteSummaryTables(List<TestResult> testResults) { testResults.Sort(); TestStats GlobalStats = new TestStats(); TestStats tmpStats; List<TestStats> AssemblyStats = new List<TestStats>(); // Calculate Statistics testResults.Sort(); var testgroups = from test in testResults group test by test.ClassName into groups select new { ClassName = groups.Key, tests = groups }; foreach (var groups in testgroups) { tmpStats = new TestStats(); tmpStats.Name = groups.ClassName; foreach (var n in groups.tests) { tmpStats.TotalTime = tmpStats.TotalTime.Add(n.Duration); GlobalStats.TotalTime = GlobalStats.TotalTime.Add(n.Duration); switch (n.TestOutcome.ToLower()) { case "passed": case "pass": GlobalStats.TotalPassed++; tmpStats.TotalPassed++; break; case "failed": case "fail": GlobalStats.TotalFailed++; tmpStats.TotalFailed++; break; case "inconclusive": case "ingnored": case "aborted": GlobalStats.TotalInconclusive++; tmpStats.TotalInconclusive++; break; } } tmpStats.TotalTests = tmpStats.TotalFailed + tmpStats.TotalPassed + tmpStats.TotalInconclusive; AssemblyStats.Add(tmpStats); } GlobalStats.TotalTests = GlobalStats.TotalPassed + GlobalStats.TotalInconclusive + GlobalStats.TotalFailed; // Write out global Statistics StringBuilder bob = new StringBuilder(); bob.AppendLine(string.Format(" <h3>Summary</h3>")); bob.AppendLine(" <table class=details cellSpacing=2 cellPadding=5 width='95%' border=0>"); bob.AppendLine(" <tbody>"); bob.AppendLine(" <tr vAlign=top>"); bob.AppendLine(" <th>Tests</th>"); bob.AppendLine(" <th>Passed</th>"); bob.AppendLine(" <th>Inconclusive or Ingored</th>"); bob.AppendLine(" <th>Failed</th>"); bob.AppendLine(" <th>Success Rate</th>"); bob.AppendLine(" <th>Time</th>"); bob.AppendLine(" </tr>"); bob.AppendLine(" <tr vAlign=top>"); bob.AppendLine(string.Format(" <td >{0}</td>", GlobalStats.TotalTests)); bob.AppendLine(string.Format(" <td >{0}</td>", GlobalStats.TotalPassed)); bob.AppendLine(string.Format(" <td >{0}</td>", GlobalStats.TotalInconclusive)); bob.AppendLine(string.Format(" <td >{0}</td>", GlobalStats.TotalFailed)); int SuccessfulGlobalTests = GlobalStats.TotalTests - (GlobalStats.TotalInconclusive + GlobalStats.TotalFailed); bob.AppendLine(string.Format(" <td >{0} ({1}%)</td>", SuccessfulGlobalTests, GetPercentage(SuccessfulGlobalTests, GlobalStats.TotalTests, 1))); bob.AppendLine(string.Format(" <td >{0}</td>", GlobalStats.TotalTime)); bob.AppendLine(" </tr>"); bob.AppendLine(" </tbody>"); bob.AppendLine(" </table>"); bob.AppendLine(" <a href='#top'>Back to top</a>"); bob.AppendLine(" <br/><br/>"); bob.AppendLine(string.Format(" <h3>Summary</h3>")); bob.AppendLine(" <table class=details cellSpacing=2 cellPadding=5 width='95%' border=0>"); bob.AppendLine(" <tbody>"); bob.AppendLine(" <tr vAlign=top>"); bob.AppendLine(" <th width='80%'>Name</th>"); bob.AppendLine(" <th>Tests</th>"); bob.AppendLine(" <th>Passed</th>"); bob.AppendLine(" <th>Inconclusive</th>"); bob.AppendLine(" <th>Failed</th>"); bob.AppendLine(" <th>Success Rate</th>"); bob.AppendLine(" <th>Time</th>"); bob.AppendLine(" </tr>"); foreach (var item in AssemblyStats) { bob.AppendLine(" <tr vAlign=top>"); bob.AppendLine(string.Format(" <td ><a href='#{0}' >{0}</a></td>", item.Name)); bob.AppendLine(string.Format(" <td >{0}</td>", item.TotalTests)); bob.AppendLine(string.Format(" <td >{0}</td>", item.TotalPassed)); bob.AppendLine(string.Format(" <td >{0}</td>", item.TotalInconclusive)); bob.AppendLine(string.Format(" <td >{0}</td>", item.TotalFailed)); int SuccessfulTests = item.TotalTests - (item.TotalInconclusive + item.TotalFailed); bob.AppendLine(string.Format(" <td >{0} ({1}%)</td>", SuccessfulTests, GetPercentage(SuccessfulTests, item.TotalTests,1))); bob.AppendLine(string.Format(" <td >{0}</td>", item.TotalTime)); bob.AppendLine(" </tr>"); } bob.AppendLine(" </tbody>"); bob.AppendLine(" </table>"); bob.AppendLine(" <a href='#top'>Back to top</a>"); bob.AppendLine(" <br/><br/>"); return bob.ToString(); }