public MatchSimulator(ILogger <MatchSimulator> logger, IMatchEventService matchEventService) { _logger = logger; _matchEventService = matchEventService; //ok, normally we shouldn't do heavy stuff in the constructor _eventsRandomizer = GetEvents(); }
protected void FillWithDefaultGunActions() { DefaultAction = DefaultGrazeWound; HeadActions = new StaticWeightedRandomizer <Action <int> > { { HeadCase1, GrazeWoundWeight }, { HeadCase2, FleshWoundWeight }, { HeadCase3, PenetratingWoundWeight }, { HeadCase4, PerforatingWoundWeight }, { HeadCase5, AvulsiveWoundWeight }, }; NeckActions = new StaticWeightedRandomizer <Action <int> > { { NeckCase1, GrazeWoundWeight }, { NeckCase2, FleshWoundWeight }, { NeckCase3, PenetratingWoundWeight }, { NeckCase4, PerforatingWoundWeight }, { NeckCase5, AvulsiveWoundWeight }, }; UpperBodyActions = new StaticWeightedRandomizer <Action <int> > { { UpperBodyCase1, GrazeWoundWeight }, { UpperBodyCase2, FleshWoundWeight }, { UpperBodyCase3, PenetratingWoundWeight }, { UpperBodyCase4, PerforatingWoundWeight }, { UpperBodyCase5, AvulsiveWoundWeight }, }; LowerBodyActions = new StaticWeightedRandomizer <Action <int> > { { LowerBodyCase1, GrazeWoundWeight }, { LowerBodyCase2, FleshWoundWeight }, { LowerBodyCase3, PenetratingWoundWeight }, { LowerBodyCase4, PerforatingWoundWeight }, { LowerBodyCase5, AvulsiveWoundWeight }, }; ArmActions = new StaticWeightedRandomizer <Action <int> > { { ArmCase1, GrazeWoundWeight }, { ArmCase2, FleshWoundWeight }, { ArmCase3, PenetratingWoundWeight }, { ArmCase4, PerforatingWoundWeight }, { ArmCase5, AvulsiveWoundWeight }, }; LegActions = new StaticWeightedRandomizer <Action <int> > { { LegCase1, GrazeWoundWeight }, { LegCase2, FleshWoundWeight }, { LegCase3, PenetratingWoundWeight }, { LegCase4, PerforatingWoundWeight }, { LegCase5, AvulsiveWoundWeight }, }; }
public override void Initialize() { WeaponClass = "HeavyImpact"; HelmetSafeChance = 0.8f; ArmorDamage = 0; CanPenetrateArmor = false; CritChance = 0.7f; DefaultAction = DefaultGrazeWound; HeadActions = new StaticWeightedRandomizer <Action <int> > { { HeadCase1, 3 }, { HeadCase2, 3 }, { HeadCase3, 1 }, { HeadCase4, 1 }, }; NeckActions = new StaticWeightedRandomizer <Action <int> > { { NeckCase1, 3 }, { NeckCase2, 2 }, { NeckCase3, 1 }, }; UpperBodyActions = new StaticWeightedRandomizer <Action <int> > { { UpperCase1, 3 }, { UpperCase2, 2 }, { UpperCase3, 1 }, }; LowerBodyActions = new StaticWeightedRandomizer <Action <int> > { { LowerCase1, 3 }, { LowerCase2, 2 }, { LowerCase3, 1 }, }; ArmActions = new StaticWeightedRandomizer <Action <int> > { { ArmCase1, 3 }, { ArmCase2, 2 }, { ArmCase3, 1 }, }; LegActions = new StaticWeightedRandomizer <Action <int> > { { LegCase1, 3 }, { LegCase2, 2 }, { LegCase3, 1 }, }; LoadMultsFromConfig(); }
private static StaticWeightedRandomizer <Team> GetTeamStrengths(Match match) { var teamStrengthRandomizer = new StaticWeightedRandomizer <Team> { { match.HomeTeam, match.HomeTeam.Strength }, { match.AwayTeam, match.AwayTeam.Strength } }; return(teamStrengthRandomizer); }
private static StaticWeightedRandomizer <Team> GetTeamAggression(Match match) { var teamAggressionRandomizer = new StaticWeightedRandomizer <Team> { { match.HomeTeam, match.HomeTeam.Aggression }, { match.AwayTeam, match.AwayTeam.Aggression } }; return(teamAggressionRandomizer); }
private StaticWeightedRandomizer <Event> GetEvents() { var eventRandomizer = new StaticWeightedRandomizer <Event>(); foreach (var @event in _matchEventService.GetEvents()) { eventRandomizer.Add(@event, @event.Probability); } return(eventRandomizer); }
public override void Initialize() { WeaponClass = "LightImpact"; HelmetSafeChance = 0.9f; ArmorDamage = 0; CritChance = 0.3f; DefaultAction = DefaultGrazeWound; HeadActions = new StaticWeightedRandomizer <Action <int> > { { HeadCase1, 1 }, { HeadCase2, 1 }, { HeadCase3, 1 }, }; NeckActions = new StaticWeightedRandomizer <Action <int> > { { NeckCase1, 8 }, { NeckCase2, 5 }, { NeckCase3, 1 }, }; UpperBodyActions = new StaticWeightedRandomizer <Action <int> > { { UpperCase1, 8 }, { UpperCase2, 5 }, { UpperCase3, 1 }, }; LowerBodyActions = new StaticWeightedRandomizer <Action <int> > { { LowerCase1, 8 }, { LowerCase2, 5 }, { LowerCase3, 1 }, }; ArmActions = new StaticWeightedRandomizer <Action <int> > { { ArmCase1, 8 }, { ArmCase2, 5 }, { ArmCase3, 1 }, }; LegActions = new StaticWeightedRandomizer <Action <int> > { { LegCase1, 8 }, { LegCase2, 5 }, { LegCase3, 1 }, }; LoadMultsFromConfig(); }
public static void LoadMapCapsuleItemInfo() { ConcurrentDictionary <int, List <MapCapsuleItemInfo> > dbmapiteminfos = new ConcurrentDictionary <int, List <MapCapsuleItemInfo> >(); using (var con = new MySqlConnection(Conf.Connstr)) { con.Open(); using (var cmd = new MySqlCommand(string.Empty, con)) { cmd.Parameters.Clear(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "usp_loadCapsuleItemInfo"; using (MySqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { MapCapsuleItemInfo item = new MapCapsuleItemInfo { PresentRuleType = Convert.ToInt32(reader["fdPresentRuleType"]), Argument = Convert.ToInt32(reader["fdArgument"]), GameItemNum = Convert.ToInt32(reader["fdGameItemNum"]), Rate = Convert.ToInt32(reader["fdRate"]) }; int GroupNum = Convert.ToInt32(reader["fdGroupNum"]); dbmapiteminfos.AddOrUpdate(GroupNum, new List <MapCapsuleItemInfo> { item }, (k, v) => { v.Add(item); return(v); }); } } } } //Log.Info("Load dbmapiteminfos Count: {0}", dbmapiteminfos.Count()); foreach (var i in dbmapiteminfos) { IWeightedRandomizer <MapCapsuleItemInfo> randomizer = new StaticWeightedRandomizer <MapCapsuleItemInfo>(); foreach (var j in i.Value) { randomizer.Add(j, j.Rate); } MapCapsuleItems.TryAdd(i.Key, randomizer); //Log.Info("i.Key: {0}", i.Key); } Log.Info("Load MapCapsuleItems Count: {0}", MapCapsuleItems.Count()); }
public override void Initialize() { WeaponClass = "Explosive"; HelmetSafeChance = 0; ArmorDamage = 200; CanPenetrateArmor = true; CritChance = 1f; DefaultAction = DefaultGrazeWound; HeadActions = new StaticWeightedRandomizer <Action <int> > { { HeadCase1, 1 }, }; NeckActions = new StaticWeightedRandomizer <Action <int> > { { NeckCase1, 1 }, }; UpperBodyActions = new StaticWeightedRandomizer <Action <int> > { { UpperCase1, 1 }, }; LowerBodyActions = new StaticWeightedRandomizer <Action <int> > { { LowerCase1, 1 }, }; ArmActions = new StaticWeightedRandomizer <Action <int> > { { ArmCase1, 1 }, }; LegActions = new StaticWeightedRandomizer <Action <int> > { { LegCase1, 1 }, }; }
/*public static void LoadMapCardInfo() * { * string fileName = @"iteminfo\\tblalchemist_mapcardinfo.txt"; * var lines = File.ReadLines(fileName); * int Count = 0; * foreach (var line in lines) * { * Count++; * string[] mapcard = line.Split(','); * MapCardInfo mapCardInfo = new MapCardInfo * { * MapNum = Convert.ToInt32(mapcard[1]), * CardNum = Convert.ToInt32(mapcard[2]) * }; * MapCardInfos.Add(Count, mapCardInfo); * } * Log.Info("Load MapCardInfo Count: {0}", MapCardInfos.Count()); * }*/ public static void LoadMapCardRateInfo() { ConcurrentDictionary <int, List <MapCardRateInfo> > _mapCardRateInfos = new ConcurrentDictionary <int, List <MapCardRateInfo> >(); using (var con = new MySqlConnection(Conf.Connstr)) { con.Open(); using (var cmd = new MySqlCommand(string.Empty, con)) { cmd.Parameters.Clear(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "usp_alchemist_getCardRateKindMapInfo"; using (MySqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { MapCardRateInfo mapCardInfo = new MapCardRateInfo { CardNum = Convert.ToInt32(reader["carditemdesc"]), RateKind = Convert.ToInt32(reader["getratekind"]) }; _mapCardRateInfos.AddOrUpdate(Convert.ToInt32(reader["mapnum"]), new List <MapCardRateInfo> { mapCardInfo }, (k, v) => { v.Add(mapCardInfo); return(v); }); } } } } //Log.Info("Load MapCardRateInfo Count: {0}", _mapCardRateInfos.Count()); foreach (var i in _mapCardRateInfos) { IWeightedRandomizer <int> randomizer = new StaticWeightedRandomizer <int>(); foreach (var j in i.Value) { int rate = GetWeight(j.RateKind); randomizer.Add(j.CardNum, rate); } MapCardRateInfos.TryAdd(i.Key, randomizer); } Log.Info("Load MapCardRateInfo Count: {0}", MapCardRateInfos.Count()); }
public List <Match> CreateMatchSchedule(Competition competition) { _logger.LogInformation("Create match schedule"); var teams = competition.Teams.OrderBy(t => t.TeamId).ToList(); var opponents = competition.Teams.OrderBy(t => t.TeamId).ToList(); foreach (var team in teams) { opponents.Remove(team); //don't play against yourself foreach (var opponent in opponents) { //randomizer to decide who's the home team var matchTeams = new StaticWeightedRandomizer <Team> { team, opponent }; competition.Matches.Add(new Match { HomeTeam = matchTeams.NextWithRemoval(), AwayTeam = matchTeams.NextWithRemoval() }); } } return(competition.Matches); }