public void CalculateResuilts(int maxNumberOfRecords, IScoring scoringMethod) { int playedDeals = GetPlayedDeals(); for (int i = 0; i < deals.Count; i++) { if (deals[i].HasResult()) { short res = deals[i].result; double ns = 0; double ew = 0; for (int k = 0; k < deals.Count; k++) { if (i != k && deals[k].HasResult()) { short res2 = deals[k].result; ns += scoringMethod.GetDiff(res, res2); ew += scoringMethod.GetDiff(res2, res); } } ns = scoringMethod.ResultReduction(ns, playedDeals, maxNumberOfRecords); ew = scoringMethod.ResultReduction(ew, playedDeals, maxNumberOfRecords); deals[i].SetResults(ns, ew); } } }
public Tournament(Id <Tournament> id, IScoring scoring, IRuleSet ruleSet) { Id = id ?? throw new ArgumentNullException(nameof(id)); Scoring = scoring ?? throw new ArgumentNullException(nameof(scoring)); RuleSet = ruleSet ?? throw new ArgumentNullException(nameof(ruleSet)); }
public static ICollection <ScoringItemModel> ToModel(this IScoring scoring) { return(scoring.Select( (x, index) => new ScoringItemModel { Name = x.Key, Weighting = x.Value, Order = index }) .ToList()); }
public MapField <string, float> Convert(IScoring scoring, ResolutionContext context) { var response = new MapField <string, float>(); foreach (var(statName, statWeighting) in scoring) { response.Add(statName, statWeighting); } return(response); }
public MatchFaker(IScoring scoring, DateTime synchronizedAt) { this.CustomInstantiator( faker => { var match = new Match( faker.Game().Uuid(), new UtcNowDateTimeProvider(), TimeSpan.FromHours(1), scoring.Map(faker.Game().Stats()), new DateTimeProvider(synchronizedAt)); match.SetEntityId(faker.Match().Id()); return(match); }); }
public Challenge( ChallengeId id, ChallengeName name, Game game, BestOf bestOf, Entries entries, ChallengeTimeline timeline, IScoring scoring ) { this.SetEntityId(id); Name = name; Game = game; BestOf = bestOf; Entries = entries; Timeline = timeline; Scoring = scoring; this.AddDomainEvent(new ChallengeCreatedDomainEvent(this)); }
public JackSpadeHighScoring(IScoring next) => _next = next;
public virtual bool Parse(XmlDbRow myRow, XmlDbTable table) { mName = myRow.GetString("Name"); string error = null; if (!Parse(myRow, ref error)) { BooterLogger.AddError(Name + " : " + error); return(false); } if ((table == null) || (table.Rows == null) || (table.Rows.Count == 0)) { BooterLogger.AddError(Name + ": Missing Table"); return(false); } else { List <IScoring <T, SubSP> > rawScoring = new List <IScoring <T, SubSP> >(); int index = 1; foreach (XmlDbRow row in table.Rows) { Type classType = row.GetClassType("FullClassName"); if (classType == null) { BooterLogger.AddError(Name + ": Unknown FullClassName " + row.GetString("FullClassName")); continue; } IScoring <T, SubSP> scoring = null; try { scoring = classType.GetConstructor(new Type[0]).Invoke(new object[0]) as IScoring <T, SubSP>; } catch { } if (scoring == null) { BooterLogger.AddError(Name + " (" + index + "): Constructor Fail " + row.GetString("FullClassName") + " as " + typeof(IScoring <T, SubSP>)); } else { error = null; if (scoring.Parse(row, ref error)) { rawScoring.Add(scoring); } else { if (!string.IsNullOrEmpty(error)) { BooterLogger.AddError(Name + " index " + index + " : " + error); } else { BooterLogger.AddTrace(Name + " index " + index + " : <Warning>"); } } } index++; } List <ICombinedScoring <T, SubSP> > combinedList = Common.DerivativeSearch.Find <ICombinedScoring <T, SubSP> >(Common.DerivativeSearch.Caching.NoCache); foreach (ICombinedScoring <T, SubSP> combined in combinedList) { IScoring <T, SubSP> scoring = combined as IScoring <T, SubSP>; if (scoring == null) { continue; } if (combined.Combine(rawScoring)) { rawScoring.Add(scoring); } } List <IScoring <T, SubSP> > scoringList = new List <IScoring <T, SubSP> >(rawScoring); rawScoring.Clear(); foreach (IScoring <T, SubSP> scoring in scoringList) { if (scoring.IsConsumed) { continue; } rawScoring.Add(scoring); } if (rawScoring.Count > 0) { mHelper.SetRawScoring(rawScoring); return(true); } else { BooterLogger.AddError(Name + ": No valid scoring"); return(false); } } }
public JackDiamondHighScoring(IScoring next) => _next = next;
public TenDiamondHighScoring(IScoring next) => _next = next;
public EightHeartHighScoring(IScoring next) => _next = next;
public NineClubHighScoring(IScoring next) => _next = next;
private void Write(String dirName, DatabaseLint dblint) { this.scoring = new IScoringImpl(); this.scoring.CalculateScores(dblint); if (DBLint.Settings.IsNormalContext) { //Save run for incremental viewing //File name is a timestamp DateTime now = DateTime.Now; String fileName = String.Format("{0}{1}{2}{3}{4}{5}.xml", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second); //Folder, i.e.: runs/dbname/ String folder = Settings.INCREMENTAL_FOLDER + "testtest"; // dblint.DatabaseModel.DatabaseName; String filePath = folder + "/" + fileName; if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } //Create run DBLint.IncrementalRuns.Run run = new IncrementalRuns.Run(dblint.DatabaseModel, dblint.IssueCollector, scoring.GetScores()); //Write run using (FileStream writer = new FileStream(filePath, FileMode.Create)) { DataContractSerializer ser = new DataContractSerializer(typeof(DBLint.IncrementalRuns.Run)); ser.WriteObject(writer, run); writer.Flush(); } } DirectoryInfo dir = new DirectoryInfo(dirName); int tableNameCounter = 1; foreach (Table table in dblint.DatabaseModel.Tables) { String tName = "table" + tableNameCounter.ToString(); this.tableNames.Add(table, tName); this.tableFiles.Add(table, "tables/" + tName + ".html"); tableNameCounter++; } this.dblint = dblint; this.formatter = new HTMLDescriptionFormatter(this.tableFiles); IssueCollector issues = dblint.IssueCollector; //Create result directory if it does not exist if (!dir.Exists) { dir.Create(); } VelocityContext context = new VelocityContext(); context.Put("db", dblint.DatabaseModel); context.Put("totalScore", this.scoring.GetScore()); context.Put("issuesTotal", issues.Count()); context.Put("rulesExecuted", this.getRulesExecuted()); context.Put("ruleTypes", this.getRuleTypes()); context.Put("formatter", this.formatter); context.Put("HTMLBuilder", this); context.Put("summaries", this.dblint.ExecutionSummary); context.Put("executionTime", this.formatTimeSpan(this.dblint.ExecutionSummary.ExecutionTime)); //Pagerank IProviderCollection providers = dblint.RuleController.ProviderCollection; var rank = providers.GetProvider <DBLint.Rules.SchemaProviders.ImportanceProvider>(); //List all tables var tables = (from t in dblint.DatabaseModel.Tables select new { Table = t, Name = t.TableName, IssueCount = issues.GetIssues(t).Count(), Score = this.scoring.GetScore(t), Importance = Math.Round(rank[t], 1) }).ToList(); context.Put("tables", tables); //Bottom tables var bottom = tables.OrderBy(t => t.Score).Take(5).ToList(); context.Put("bottomTables", bottom); int groupId = 0; //Used in the template to identify a group of issues //Group issues by name var issueGroups = (from i in issues group i by i.Name into g orderby g.First().Severity select new { Name = g.Key, Count = g.Count(), Issues = g, GroupID = ++groupId, Severity = g.First().Severity }).ToList(); context.Put("issueGroups", issueGroups); //Put issueGroups into severity groups var severityGroups = (from issueGroup in issueGroups group issueGroup by issueGroup.Severity into g orderby g.First().Severity select new { Severity = g.First().Severity, IssueGroups = g } ); context.Put("severityGroups", severityGroups); //Incremental runs list var diffs = new List <DBLint.IncrementalRuns.Diff>(); if (DBLint.Settings.IsNormalContext) { //Incremental runs try { var runs = DBLint.IncrementalRuns.Run.GetRuns(dblint.DatabaseModel.DatabaseName, 5).ToList(); for (int i = 1; i < runs.Count; i++) { var diff = new DBLint.IncrementalRuns.Diff(); diff.Compare(runs[i], runs[i - 1]); diffs.Add(diff); } } catch { } context.Put("diffs", diffs); } //Create template for the main html page Template template = Velocity.GetTemplate("mainpage.vm"); //Create outputstream for the main page TextWriter htmlOut = new StreamWriter(Path.Combine(dir.FullName, "mainpage.html")); //Write template template.Merge(context, htmlOut); htmlOut.Close(); //Write issue groups String issuePath = Path.Combine(dir.FullName, "issues"); if (!Directory.Exists(issuePath)) { Directory.CreateDirectory(issuePath); } Template issueGroupTemplate = Velocity.GetTemplate("issuegroup.vm"); formatter.PathPrefix = "../"; foreach (var g in issueGroups) { context.Put("groupIssues", g.Issues); TextWriter issueOut = new StreamWriter(Path.Combine(issuePath, g.GroupID.ToString() + ".html")); issueGroupTemplate.Merge(context, issueOut); issueOut.Close(); } if (DBLint.Settings.IsNormalContext) { //Write diffs/increments to files: String incPath = Path.Combine(dir.FullName, "increments"); if (!Directory.Exists(incPath)) { Directory.CreateDirectory(incPath); } Template incrementTemplate = Velocity.GetTemplate("increment.vm"); int diffId = 0; foreach (var diff in diffs) { diffId++; context.Put("diff", diff); TextWriter incOut = new StreamWriter(Path.Combine(incPath, diffId.ToString() + ".html")); incrementTemplate.Merge(context, incOut); incOut.Close(); } } formatter.PathPrefix = ""; writeTableViews(dirName); }
public SevenClubHighScoring(IScoring next) => _next = next;
public TenHeartHighScoring(IScoring next) => _next = next;
public QueenSpadeHighScoring(IScoring next) => _next = next;
public KingClubHighScoring(IScoring next) => _next = next;
public SevenSpadeHighScoring(IScoring next) => _next = next;
public KingDiamondHighScoring(IScoring next) => _next = next;
public ConstructAlgorithim(IScoring func) { _score = func; }
public JackClubHighScoring(IScoring next) => _next = next;
public QueenClubHighScoring(IScoring next) => _next = next;
public EightClubHighScoring(IScoring next) => _next = next;
public JackHeartHighScoring(IScoring next) => _next = next;
public KingHeartHighScoring(IScoring next) => _next = next;
public NineHeartHighScoring(IScoring next) => _next = next;
public EightDiamondHighScoring(IScoring next) => _next = next;
public NineDiamondHighScoring(IScoring next) => _next = next;
public NineSpadeHighScoring(IScoring next) => _next = next;
public KingSpadeHighScoring(IScoring next) => _next = next;