Example #1
0
File: Rider.cs Project: Cycli/Cycli
        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);
        }