public Motor Duplicate() { Motor m = new Motor(); m.RecoverPower = this.RecoverPower; foreach (MotorUnit mu in _MotorUnits) { m._MotorUnits.Add(mu.Duplicate()); } return m; }
public BreakTactic(string userId, Motor m, double aggression, Race r) : base(userId, m, aggression, r) { TacticName = @"Breaking"; _Rnd = new Random(); // An aggressive rider =1 will always fancy a break // A weedy rider =0 won't try any break _LikelihoodPoints.Add(new TacticPoint { PercentCompleted = 0, Value = 0.01 * aggression }); _LikelihoodPoints.Add(new TacticPoint { PercentCompleted = 80, Value = 0.01 * aggression }); _LikelihoodPoints.Add(new TacticPoint { PercentCompleted = 90, Value = 0 }); _LikelihoodPoints.Add(new TacticPoint { PercentCompleted = 100, Value = 0 }); }
public WheelsuckTactic(string userId, Motor m, double aggression, Race r) : base(userId, m, aggression, r) { TacticName = @"Wheelsucking"; }
public TimetrialTactic(string userId, Motor m, double aggression, Race r) : base(userId, m, aggression, r) { TacticName = @"Time-trialling"; // A less agreesive rider will be happy to timetrial _LikelihoodPoints.Add(new TacticPoint { PercentCompleted = 0, Value = 1.0 - 0.01 * aggression }); // We will always consider chasing at the end _LikelihoodPoints.Add(new TacticPoint { PercentCompleted = 100, Value = 1 }); }
public Tactic(string userId, Motor m, double aggression, Race r) { _UserId = userId; _Motor = m; _Race = r; _Aggression = 0.01 * aggression; // scale between 0 and 1 _LikelihoodPoints = new List<TacticPoint>(); TacticName = @"Undefined"; }
public RecoverTactic(string userId, Motor m, double aggression, Race r) : base(userId, m, aggression, r) { TacticName = @"Recovering"; }
public CooperateTactic(string userId, Motor m, double aggression, Race r) : base(userId, m, aggression, r) { TacticName = @"Cooperating"; }
public ChaseTactic(string userId, Motor m, double aggression, Race r) : base(userId, m, aggression, r) { TacticName = @"Chasing"; // Depending on aggression - don't chase at the start put always // chase at the end of the race // An aggressive rider =1 will always try to chase down at the start // A weedy rider =0 won't try at all at the start _LikelihoodPoints.Add(new TacticPoint { PercentCompleted = 0, Value = 0.01 * aggression }); // We will always consider chasing at the end _LikelihoodPoints.Add(new TacticPoint { PercentCompleted = 90, Value = 1 }); _LikelihoodPoints.Add(new TacticPoint { PercentCompleted = 100, Value = 1 }); }
public void StartRiding(Race race, RaceProcessor rp) { _CurrentTacticIdx = -1; _messageCounter = 0; _ReviewTacticsTime = DateTime.MinValue; // Force full tactics review on first update int seed = (this.UserId + DateTime.UtcNow.Ticks.ToString()).GetHashCode(); Random rnd = new Random(seed); _RaceProcessor = rp; _Race = race; _Motor = new Motor(); double[] powerBands = new double[]{this.Power1Hr, this.Power5Min,this.Power1Min, this.Power5Sec}; double[] alphaBands = new double[]{3600, 300, 60, 5}; _Motor.Initialise(this.PowerMin, powerBands, alphaBands); // Initialise the spot _lastMessageTime = (ulong)DateTime.UtcNow.Subtract(new DateTime(1970,1,1)).TotalMilliseconds-1000; // Load up the tactics _TacticsCompendium.Clear(); // If more than one tactic has the highest score, then they'll be chosen in the order // added to the compendium // Recover is really the last thing we want to consider _TacticsCompendium.Add(new ChaseTactic(UserId, _Motor, Aggression, race)); _TacticsCompendium.Add(new WheelsuckTactic(UserId, _Motor, Aggression, race)); _TacticsCompendium.Add(new BreakTactic(UserId, _Motor, Aggression, race)); _TacticsCompendium.Add(new TimetrialTactic(UserId, _Motor, Aggression, race)); _TacticsCompendium.Add(new RecoverTactic(UserId, _Motor, Aggression, race)); _MessageTimer = new Timer(UpdateSpotData, null, 0, UPDATE_SPOT_INTERVAL_MS); }