瀏覽代碼

added low perfomance option

master
Robin Thoni 7 年之前
父節點
當前提交
d04a48fc45
共有 4 個檔案被更改,包括 10 行新增3 行删除
  1. 1
    0
      README.md
  2. 4
    2
      uqac-ia-aspirobot/Agent/AgAgent.cs
  3. 3
    0
      uqac-ia-aspirobot/Agent/AgConfig.cs
  4. 2
    1
      uqac-ia-aspirobot/Program.cs

+ 1
- 0
README.md 查看文件

38
   - `StartY`: Agent start Y position (>=0, <`EnvConfig.Height`)
38
   - `StartY`: Agent start Y position (>=0, <`EnvConfig.Height`)
39
   - `AutoAdjustThinkTimeInterval`: Indicate if agent should try to auto adjust think time interval (`AgConfig.ThinkTimeInterval`)
39
   - `AutoAdjustThinkTimeInterval`: Indicate if agent should try to auto adjust think time interval (`AgConfig.ThinkTimeInterval`)
40
   - `ThinkTimeInterval`: Default think time interval in ms (>=0). This variable controls how often the agent will re-evaluate the situation
40
   - `ThinkTimeInterval`: Default think time interval in ms (>=0). This variable controls how often the agent will re-evaluate the situation
41
+  - `LowPerfomance`: Value that indicate when the performance should be considered as too low. If current performance is less or equal, the agent will bypass `AgConfig.ThinkTimeInterval` and re-evaluate the situation anyway
41
   
42
   
42
 How it works
43
 How it works
43
 ------------
44
 ------------

+ 4
- 2
uqac-ia-aspirobot/Agent/AgAgent.cs 查看文件

30
 
30
 
31
         private readonly AgState _state;
31
         private readonly AgState _state;
32
         private readonly IUi _ui;
32
         private readonly IUi _ui;
33
+        private readonly IAgPerformanceSensor _agPerformanceSensor;
33
 
34
 
34
         private static Thread _thread;
35
         private static Thread _thread;
35
 
36
 
70
         }
71
         }
71
 
72
 
72
         public AgAgent(IOptions<AgConfig> options,
73
         public AgAgent(IOptions<AgConfig> options,
73
-            IEnvironment environment, AgState state, IUi ui,
74
+            IEnvironment environment, AgState state, IUi ui, IAgPerformanceSensor agPerformanceSensor,
74
             IAgEngineEffector engineEffector, IAgVaccumEffector vaccumEffector)
75
             IAgEngineEffector engineEffector, IAgVaccumEffector vaccumEffector)
75
         {
76
         {
76
             _engineEffector = engineEffector;
77
             _engineEffector = engineEffector;
79
             _environment = environment;
80
             _environment = environment;
80
             _state = state;
81
             _state = state;
81
             _ui = ui;
82
             _ui = ui;
83
+            _agPerformanceSensor = agPerformanceSensor;
82
 
84
 
83
             _options = options.Value;
85
             _options = options.Value;
84
             _state.LastThinkTime = DateTime.MinValue;
86
             _state.LastThinkTime = DateTime.MinValue;
130
         public void Think()
132
         public void Think()
131
         {
133
         {
132
             var now = DateTime.Now;
134
             var now = DateTime.Now;
133
-            if (_state.LastThinkTime.AddMilliseconds(_state.ThinkTimeInterval) <= now)
135
+            if (_state.LastThinkTime.AddMilliseconds(_state.ThinkTimeInterval) <= now || _agPerformanceSensor.Performance <= _options.LowPerformance)
134
             {
136
             {
135
                 if (_state.Destination == null && _state.DustyRooms.Any())
137
                 if (_state.Destination == null && _state.DustyRooms.Any())
136
                 {
138
                 {

+ 3
- 0
uqac-ia-aspirobot/Agent/AgConfig.cs 查看文件

8
 
8
 
9
         public int ThinkTimeInterval { get; set; }
9
         public int ThinkTimeInterval { get; set; }
10
 
10
 
11
+        public float LowPerformance { get; set; }
12
+
11
         public int StartX { get; set; }
13
         public int StartX { get; set; }
12
 
14
 
13
         public int StartY { get; set; }
15
         public int StartY { get; set; }
17
             other.AutoAdjustThinkTimeInterval = AutoAdjustThinkTimeInterval;
19
             other.AutoAdjustThinkTimeInterval = AutoAdjustThinkTimeInterval;
18
             other.SleepTime = SleepTime;
20
             other.SleepTime = SleepTime;
19
             other.ThinkTimeInterval = ThinkTimeInterval;
21
             other.ThinkTimeInterval = ThinkTimeInterval;
22
+            other.LowPerformance = LowPerformance;
20
             other.StartX = StartX;
23
             other.StartX = StartX;
21
             other.StartY = StartY;
24
             other.StartY = StartY;
22
         }
25
         }

+ 2
- 1
uqac-ia-aspirobot/Program.cs 查看文件

36
                 StartX = 0,
36
                 StartX = 0,
37
                 StartY = 0,
37
                 StartY = 0,
38
                 AutoAdjustThinkTimeInterval = true,
38
                 AutoAdjustThinkTimeInterval = true,
39
-                ThinkTimeInterval = 10000
39
+                ThinkTimeInterval = 10000,
40
+                LowPerformance = -1
40
             }, arConfig);
41
             }, arConfig);
41
 
42
 
42
             AgAgent.Join();
43
             AgAgent.Join();

Loading…
取消
儲存