Преглед изворни кода

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,6 +38,7 @@ Some behaviors can be configured in Program.cs file:
38 38
   - `StartY`: Agent start Y position (>=0, <`EnvConfig.Height`)
39 39
   - `AutoAdjustThinkTimeInterval`: Indicate if agent should try to auto adjust think time interval (`AgConfig.ThinkTimeInterval`)
40 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 43
 How it works
43 44
 ------------

+ 4
- 2
uqac-ia-aspirobot/Agent/AgAgent.cs Прегледај датотеку

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

+ 3
- 0
uqac-ia-aspirobot/Agent/AgConfig.cs Прегледај датотеку

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

+ 2
- 1
uqac-ia-aspirobot/Program.cs Прегледај датотеку

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

Loading…
Откажи
Сачувај