コード例 #1
0
ファイル: Motor.cs プロジェクト: Cycli/Cycli
 public Motor Duplicate()
 {
     Motor m = new Motor();
     m.RecoverPower = this.RecoverPower;
     foreach (MotorUnit mu in _MotorUnits)
     {
         m._MotorUnits.Add(mu.Duplicate());
     }
     return m;
 }
コード例 #2
0
ファイル: Tactic.cs プロジェクト: Cycli/Cycli
        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 });
        }
コード例 #3
0
ファイル: Tactic.cs プロジェクト: Cycli/Cycli
 public WheelsuckTactic(string userId, Motor m, double aggression, Race r)
     : base(userId, m, aggression, r)
 {
     TacticName = @"Wheelsucking";
 }
コード例 #4
0
ファイル: Tactic.cs プロジェクト: Cycli/Cycli
 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 });
 }
コード例 #5
0
ファイル: Tactic.cs プロジェクト: Cycli/Cycli
 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";
 }
コード例 #6
0
ファイル: Tactic.cs プロジェクト: Cycli/Cycli
 public RecoverTactic(string userId, Motor m, double aggression, Race r)
     : base(userId, m, aggression, r)
 {
     TacticName = @"Recovering";
 }
コード例 #7
0
ファイル: Tactic.cs プロジェクト: Cycli/Cycli
 public CooperateTactic(string userId, Motor m, double aggression, Race r)
     : base(userId, m, aggression, r)
 {
     TacticName = @"Cooperating";
 }
コード例 #8
0
ファイル: Tactic.cs プロジェクト: Cycli/Cycli
        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 });
        }
コード例 #9
0
ファイル: Rider.cs プロジェクト: 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);
        }