载入中...
搜索中...
未找到
EnvironmentQuery.h
浏览该文件的文档.
1#pragma once
2
3#include "common/Export.h"
4#include "common/Value.h"
5#include "sensing/Targeting.h"
6
7#include <memory>
8#include <span>
9
10namespace eve::sensing {
11
14 std::uint64_t id = 0;
16 std::optional<std::string> subjectKey;
17};
18
21 std::string name;
22 std::vector<TargetLocation> locations;
23};
24
27 std::vector<EnvironmentContext> contexts;
28 std::vector<EnvironmentItem> input;
29};
30
35
37enum class EnvironmentCost : std::uint8_t { Low, Medium, High };
39enum class EnvironmentPurpose : std::uint8_t { Filter, Score, FilterAndScore };
41enum class EnvironmentFilterOp : std::uint8_t { All, Any };
43enum class EnvironmentAggregate : std::uint8_t { Average, Minimum, Maximum };
47enum class EnvironmentCurve : std::uint8_t { Linear, Square, SquareRoot };
49enum class EnvironmentPreference : std::uint8_t { Higher, Lower, Reference };
51enum class EnvironmentRunMode : std::uint8_t { All, Best };
53enum class EnvironmentTraceLevel : std::uint8_t { None, Summary, Detailed };
55enum class EnvironmentGeneratorKind : std::uint8_t { Input, Ring, Grid };
57enum class EnvironmentMetricKind : std::uint8_t { Distance, LineOfSight, Custom };
58
70
78public:
80 virtual ~IEnvironmentMetric() = default;
82 [[nodiscard]] virtual EnvironmentMetricContract contract() const noexcept = 0;
84 [[nodiscard]] virtual Result<double> measure(const EnvironmentItem& item, const TargetLocation& reference,
85 const EnvironmentServices& services) const = 0;
86};
87
91 std::string context;
92 double radius = 10;
93 double spacing = 2;
94 std::uint32_t samples = 16;
95 std::uint32_t maxItems = 4096;
96};
97
100 std::string id;
101 std::string context;
102 EnvironmentMetricKind metric = EnvironmentMetricKind::Distance;
103 std::shared_ptr<const IEnvironmentMetric> custom;
104 EnvironmentPurpose purpose = EnvironmentPurpose::FilterAndScore;
105 EnvironmentFilterOp filterOp = EnvironmentFilterOp::All;
106 EnvironmentAggregate aggregate = EnvironmentAggregate::Average;
107 double minimum = 0;
108 double maximum = std::numeric_limits<double>::max();
109 EnvironmentNormalization normalization = EnvironmentNormalization::FixedRange;
110 double scoreMinimum = 0;
111 double scoreMaximum = 100;
112 EnvironmentPreference preference = EnvironmentPreference::Lower;
113 double referenceValue = 0;
114 EnvironmentCurve curve = EnvironmentCurve::Linear;
115 double weight = 1;
116};
117
120 std::string id;
122 std::vector<EnvironmentTest> tests;
123};
124
127 std::string id;
128 std::uint64_t revision = 1;
129 CoordinateSpace space = CoordinateSpace::World2D;
130 std::vector<std::string> contexts;
131 std::vector<EnvironmentOption> options;
132 EnvironmentRunMode mode = EnvironmentRunMode::All;
133 std::uint32_t maxResults = 8;
134 bool optimize = true;
135 EnvironmentTraceLevel trace = EnvironmentTraceLevel::Summary;
136 std::uint32_t maxTraceItems = 256;
137};
138
141 std::string test;
142 double raw = 0;
143 double lower = 0;
144 double upper = 0;
145 double normalized = 0;
146 double weighted = 0;
147 bool passed = true;
148};
149
152 std::string option;
153 std::string test;
154 std::size_t input = 0;
155 std::size_t output = 0;
156 std::size_t measured = 0;
157 bool deferred = false;
158};
159
162 std::string option;
163 std::uint64_t id = 0;
164 std::string rejectedBy;
165 std::vector<EnvironmentContribution> contributions;
166};
167
170 std::string query;
171 std::uint64_t revision = 0;
172 std::string state = "ready";
173 std::vector<EnvironmentStageTrace> stages;
174 std::vector<EnvironmentItemTrace> items;
175 bool truncated = false;
176 std::vector<Diagnostic> diagnostics;
178 [[nodiscard]] Value toValue() const;
179};
180
186
189 std::string option;
190 std::vector<EnvironmentRankedItem> ranked;
192 [[nodiscard]] Value toValue() const;
193};
194
197
203public:
207 [[nodiscard]] static Result<EnvironmentQueryPlan> compile(const EnvironmentQueryDefinition& definition);
211 [[nodiscard]] Result<EnvironmentQueryInstance> instantiate(EnvironmentRequest request) const;
212
213private:
215 explicit EnvironmentQueryPlan(std::shared_ptr<const EnvironmentPlanData> data) : data_(std::move(data)) {}
216 std::shared_ptr<const EnvironmentPlanData> data_;
217};
218
225public:
229 EnvironmentQueryInstance& operator=(EnvironmentQueryInstance&&) noexcept = default;
234 [[nodiscard]] Result<EnvironmentQueryResult> run(const EnvironmentServices& services);
236 [[nodiscard]] const EnvironmentTrace& trace() const noexcept { return trace_; }
237
238private:
240 EnvironmentQueryInstance(std::shared_ptr<const EnvironmentPlanData> plan, EnvironmentRequest request);
241 [[nodiscard]] Result<EnvironmentQueryResult> evaluate(const EnvironmentServices& services);
242 std::shared_ptr<const EnvironmentPlanData> plan_;
243 EnvironmentRequest request_;
244 EnvironmentTrace trace_;
245 bool started_ = false;
246};
247
248} // namespace eve::sensing
double score
Definition Agent.cpp:51
Trace trace
Definition Agent.cpp:50
std::string output
std::uint64_t revision
AuthorityStoreHandleRef reference
Definition Authority.cpp:24
bool passed
bool deferred
double raw
EnvironmentTest definition
EvpackChunkInput input
Definition Evpack.cpp:170
#define EVENGINE_API_PLATFORM
Definition Export.h:107
float maximum[3]
float minimum[3]
const GltfImportRequest & request
double radius
Definition MeleeHit.cpp:42
std::weak_ptr< Run > run
Definition OnnxGpgpu.cpp:25
std::string kind
Coordinate-safe targeting protocol shared by sensing and gameplay adapters.
Heightmap curve
int spacing
double weight
Owning, renderer-independent dynamic values.
Move-only operation result carrying either a value or Status.
Definition Result.h:176
The canonical owning dynamic value used by data-facing protocols.
Definition Value.h:31
One-shot synchronous execution state with query-local contexts and diagnostics. @thread Execute on th...
EnvironmentQueryInstance(EnvironmentQueryInstance &&) noexcept=default
EnvironmentQueryInstance(const EnvironmentQueryInstance &)=delete
EnvironmentQueryInstance & operator=(const EnvironmentQueryInstance &)=delete
Immutable resolved plan, safe to reuse after definitions are edited or destroyed. @ownership Shares i...
Immutable measurement extension; filtering, aggregation and scoring belong to the executor....
virtual Result< double > measure(const EnvironmentItem &item, const TargetLocation &reference, const EnvironmentServices &services) const =0
Returns one finite raw measurement, or a structured backend failure.
virtual ~IEnvironmentMetric()=default
Releases a measurement implementation.
virtual EnvironmentMetricContract contract() const noexcept=0
Declares supported space and optimization guarantees.
EnvironmentFilterOp
How repeated context measurements determine acceptance.
std::variant< WorldPoint, GridPoint > TargetLocation
Either a world point or a grid point, with the tag retained.
Definition Targeting.h:190
EnvironmentMetricKind
Built-in measurements and the typed extension point.
EnvironmentAggregate
How repeated context measurements form one raw metric.
EnvironmentRunMode
All retains ranked candidates; Best returns one candidate without assigning primary.
EnvironmentCurve
Utility curve applied after normalization and preference direction.
EnvironmentPreference
Ranking preference; reference uses distance from a target raw value.
CoordinateSpace
Coordinate spaces are not interchangeable, even when dimensions match.
EnvironmentPurpose
Independent hard constraint and utility purposes.
EnvironmentNormalization
Explicit scoring reference population.
EnvironmentCost
Cost tiers used only for explicitly reorderable tests.
EnvironmentTraceLevel
None, bounded stage counts, or bounded per-item explanations.
EnvironmentGeneratorKind
Input facts or generated points on a world-space XY plane.
std::optional< std::reference_wrapper< T > > OptionalRef
Optional borrowed reference; it does not extend T's lifetime.
Definition BorrowedRef.h:24
Owning context snapshot, resolved once at instance creation.
std::vector< TargetLocation > locations
Per-item score contribution with its exact normalization population bounds.
Generator parameters; maxItems is a hard resource bound, never silent truncation.
Bounded explanation for one option-local candidate.
std::vector< EnvironmentContribution > contributions
A query-local identity and typed location; subjectKey names a mirrored fact, not a UUID.
std::optional< std::string > subjectKey
Intrinsic metric guarantees; false reorderable preserves an ordering barrier.
Ordered alternative: advance only when this option has no valid items.
std::vector< EnvironmentTest > tests
Authoring value; compile validates and owns a copy. Not a persistent wire format.
std::vector< EnvironmentOption > options
Owning result; empty ranked is successful exhaustion, not a backend failure.
std::vector< EnvironmentRankedItem > ranked
One owning ranked candidate.
Per-execution values. No world pointers or callbacks are retained.
std::vector< EnvironmentItem > input
std::vector< EnvironmentContext > contexts
Borrowed providers for this synchronous execution only.
OptionalRef< const ILineOfSightQuery > lineOfSight
Stage counts include deferred tests and actual backend measurement calls.
One metric with independent filtering and scoring parameters.
std::shared_ptr< const IEnvironmentMetric > custom
Owning trace survives failed execution; untested is distinct from passed.
std::vector< EnvironmentItemTrace > items
std::vector< Diagnostic > diagnostics
std::vector< EnvironmentStageTrace > stages