Skip to content

Commit ce163e7

Browse files
committed
Improved Thing::Say; Improved A::Mind API
1 parent 72e7994 commit ce163e7

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

include/Langulus/AI.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ namespace Langulus::A
3636
struct Mind : virtual AIUnit {
3737
LANGULUS_BASES(AIUnit);
3838
Mind() : Resolvable {this} {}
39+
40+
virtual Many Interpret(const Langulus::Text&) = 0;
3941
};
4042

4143
} // namespace Langulus::A

source/Thing-Verbs.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "Thing.hpp"
99
#include "Thing.inl"
1010
#include <Flow/Verbs/Conjunct.hpp>
11+
#include <Langulus/AI.hpp>
1112

1213

1314
namespace Langulus::Entity
@@ -21,14 +22,29 @@ namespace Langulus::Entity
2122
if (not text)
2223
return {};
2324

24-
// Push and execute in the active flow
25+
// Get minds from the current context
26+
auto minds = GatherUnits<A::Mind, Seek::HereAndAbove>();
27+
if (not minds) {
28+
Logger::Error(this, ": No minds - can't interpret message: ", text);
29+
return {};
30+
}
31+
32+
// Get a flow for executing the interpreted messages
2533
auto flow = GetFlow();
2634
if (not flow) {
2735
Logger::Error(this, ": No flow - can't execute message: ", text);
2836
return {};
2937
}
3038

31-
return flow->Push(Verbs::Do::In(this, text));
39+
// Interpret by each mind and then execute in flow
40+
Many results;
41+
for (auto& mind : minds) {
42+
auto interpretation = mind->Interpret(text);
43+
if (interpretation)
44+
results << flow->Push(interpretation);
45+
}
46+
47+
return Abandon(results);
3248
}
3349

3450
/// Executes a piece of code in the current context

0 commit comments

Comments
 (0)