|
@@ -1,14 +1,16 @@
|
1
|
1
|
Aspirobot
|
2
|
2
|
=========
|
3
|
|
-Aspirobot is a simple(r) AI agent that vaccums dust in your rooms but leaves your jewels.
|
|
3
|
+Aspirobot is a simple(r) AI agent that vaccums dust in your rooms but pick up your jewels.
|
4
|
4
|
|
5
|
5
|
Build
|
6
|
6
|
-----
|
7
|
7
|
- Command line
|
8
|
|
-`cd uqac-ia-aspirobot
|
|
8
|
+```shell
|
|
9
|
+cd uqac-ia-aspirobot
|
9
|
10
|
dotnet restore
|
10
|
11
|
dotnet build
|
11
|
|
-dotnet run`
|
|
12
|
+dotnet run
|
|
13
|
+```
|
12
|
14
|
|
13
|
15
|
- Visual Studio
|
14
|
16
|
Run VS, open solution, wait for package restore, click run (F5)
|
|
@@ -19,21 +21,59 @@ Run Rider, open solution, wait for package restore, click run (Shift + F10)
|
19
|
21
|
Configuration
|
20
|
22
|
-------------
|
21
|
23
|
Some behaviors can be configured in Program.cs file:
|
22
|
|
-- EnvConfig (Environment configuration)
|
23
|
|
- - Height: Map height
|
24
|
|
- - Width: Map width
|
25
|
|
- - ActionPropability: Probability that an action occurs in the enviromnent, once per SleepTime (>=0, <=100)
|
26
|
|
- - AddDustProbability: Probability that a dust is added on the map, only when an action is to be taken (>=0, <=100)
|
27
|
|
- - AddJewelProbability: Probability that a jewel is added on the map, only when an action is to be taken, and AddDustProbability does not occur (>=0, <=100)
|
28
|
|
- - RemoveJewelProbability: Probability that a jewel is removed from the map, only when an action is to be taken, and neither AddDustProbability nor AddJewelProbability occur (>=0, <=100)
|
29
|
|
- - SleepTime: Time between each iteration in ms (>=0)
|
|
24
|
+- `EnvConfig` (Environment configuration)
|
|
25
|
+ - `Height`: Map height
|
|
26
|
+ - `Width`: Map width
|
|
27
|
+ - `ActionPropability`: Probability that an action occurs in the enviromnent, once per `EnvConfig.SleepTime` (>=0, <=100)
|
|
28
|
+ - `AddDustProbability`: Probability that a dust is added on the map, only when an action is to be taken (>=0, <=100)
|
|
29
|
+ - `AddJewelProbability`: Probability that a jewel is added on the map, only when an action is to be taken,
|
|
30
|
+ and `AddDustProbability` does not occur (>=0, <=100)
|
|
31
|
+ - `RemoveJewelProbability`: Probability that a jewel is removed from the map, only when an action is to be taken,
|
|
32
|
+ and neither `EnvConfig.AddDustProbability` nor `EnvConfig.AddJewelProbability` occur (>=0, <=100)
|
|
33
|
+ - `SleepTime`: Time between each iteration in ms (>=0)
|
30
|
34
|
|
31
|
|
-- AgConfig (Agent configuration)
|
32
|
|
- - SleepTime: Time between each iteration in ms (>=0)
|
33
|
|
- - StartX: Agent start X position (>=0, <EnvConfig.Width)
|
34
|
|
- - StartY: Agent start Y position (>=0, <EnvConfig.Height)
|
35
|
|
- - AutoAdjustThinkTimeInterval: Indicate if agent should try to auto adjust think time interval
|
36
|
|
- - ThinkTimeInterval: Default think time interval in ms (>=0). This variable controls how often the agent will re-evaluate the situation
|
|
35
|
+- `AgConfig` (Agent configuration)
|
|
36
|
+ - `SleepTime`: Time between each iteration in ms (>=0)
|
|
37
|
+ - `StartX`: Agent start X position (>=0, <`EnvConfig.Width`)
|
|
38
|
+ - `StartY`: Agent start Y position (>=0, <`EnvConfig.Height`)
|
|
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
|
37
|
41
|
|
38
|
42
|
How it works
|
39
|
43
|
------------
|
|
44
|
+Agent will loop forever (until killed) peforming the following operations:
|
|
45
|
+- Environment update: this action will force all sensors to update their data, so that the environment can be updated.
|
|
46
|
+ - In the FakeEnv implementation, the environment update itself from remote virtual environment, so the sensors updates do nothing.
|
|
47
|
+ - In a real robot implementation, the update methods of sensors would gather data and push them to the environment.
|
|
48
|
+- UI update: this will update the user interface.
|
|
49
|
+ - In the FakeEnv implementation, it draw in the standard output.
|
|
50
|
+ - In a real robot implementation, it would either do nothing, or update a web interface (for example)
|
|
51
|
+- Internal state update: Prepare internal state to be able to choose an action to do.
|
|
52
|
+- Choose an action: Choose the most appropriate action to do by analysing the gathered data and current internal state.
|
|
53
|
+- Act: Execute choosen action (go to room, vaccum, pick)
|
|
54
|
+- Sleep: Sleep for `AgConfig.SleepTime`ms
|
|
55
|
+
|
|
56
|
+FakeEnv implementation will loop forever (until killed) peforming the following operations:
|
|
57
|
+- Sleep: Sleep for `EnvConfig.SleepTime`ms
|
|
58
|
+- May do something: Randomly choose to do something or not using `EnvConfig.ActionPropability`
|
|
59
|
+ - May add dust on a random location: Randomly choose to do it or not using `EnvConfig.AddDustProbability`
|
|
60
|
+ - May add a jewel on a random location: Randomly choose to do it or not using `EnvConfig.AddJewelProbability`.
|
|
61
|
+ Can only happen if no previous action has been done.
|
|
62
|
+ - May remove a jewel from the first room that contains a jewel: Randomly choose to do it or not using `EnvConfig.RemoveJewelProbability`.
|
|
63
|
+ Can only happen if no previous action has been done.
|
|
64
|
+
|
|
65
|
+Code
|
|
66
|
+----
|
|
67
|
+This agent is coded in .NET Core (C#) using DI (Dependency Injection) and interfaces to abstract implementation
|
|
68
|
+and allow to run a virtual environment or a real one without changing anything in the agent implementation
|
|
69
|
+
|
|
70
|
+FakeEnv implementation starts one thread for the environment and another one for the agent.
|
|
71
|
+
|
|
72
|
+Agent logic is in `Agent/*.cs`
|
|
73
|
+Agent sensors and effectors interfaces are in `Agent/Interfaces/*`
|
|
74
|
+Agent FakeEnv client implementation is in `Agent/FakeEnv/*`
|
|
75
|
+FakeEnv client, server, protocol and configuration are defined in `Common/*.cs`
|
|
76
|
+FakeEnv server implementation is in `Environment/*.cs`
|
|
77
|
+Some helper methods are defined in `Extensions/Extensions.cs`
|
|
78
|
+Shared interfaces are in `Interfaces/*.cs`
|
|
79
|
+Console user interface is in `UI/UiConsole.cs`
|