Grail (C++)  1.3.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
SelectionResult.hh
1 // Copyright QED Software 2023.
2 
3 #ifndef GRAIL_SELECTION_RESULT_H
4 #define GRAIL_SELECTION_RESULT_H
5 
6 #include "../Blueprint.hh"
7 #include "../../GrailData/DebugInfo/UtilityReasonerSnapshot.h"
8 
9 #include <limits>
10 #include <random>
11 
12 namespace grail
13 {
14 namespace utility
15 {
20  {
25  SelectionResult(bool isDebugging = false)
26  {
27  if(isDebugging)
28  {
29  snapshot = std::make_unique<data::UtilityReasonerSnapshot>();
30  }
31  }
32 
39  data::UtilityEvaluatorSnapshot* FetchNextEvaluatorSnapshot(const std::string& evaluatedObjectName,
40  const std::string& evaluatedObjectMetadata,
41  int rank)
42  {
43  if(snapshot != nullptr)
44  {
45  snapshot->evaluatorSnapshots.emplace_back(evaluatedObjectName, evaluatedObjectMetadata, rank);
46  return &snapshot->evaluatorSnapshots.back();
47  }
48  return nullptr;
49  }
50 
55  bool IsValid() const
56  {
57  return optionIndex != std::numeric_limits<std::size_t>::max();
58  }
59 
63  std::unique_ptr<data::UtilityReasonerSnapshot> snapshot{nullptr};
67  std::size_t optionIndex = std::numeric_limits<std::size_t>::max();
68  };
69 }
70 }
71 
72 #endif //GRAIL_SELECTION_RESULT_H
grail::utility::SelectionResult::FetchNextEvaluatorSnapshot
data::UtilityEvaluatorSnapshot * FetchNextEvaluatorSnapshot(const std::string &evaluatedObjectName, const std::string &evaluatedObjectMetadata, int rank)
FetchNextEvaluatorSnapshot - If debugging mode was enabled in constructor, creates an empty snapshot ...
Definition: SelectionResult.hh:39
grail::utility::SelectionResult::optionIndex
std::size_t optionIndex
optionIndex - Index of option selected by Selector.
Definition: SelectionResult.hh:67
grail::utility::SelectionResult::IsValid
bool IsValid() const
IsValid - Checks whether Selector already finished it's calculations and encountered no errors.
Definition: SelectionResult.hh:55
grail::utility::SelectionResult
The SelectionResult struct - Structure containing results of operations done by Selector.
Definition: SelectionResult.hh:19
grail::data::UtilityEvaluatorSnapshot
The UtilityEvaluatorSnapshot class - debug snapshot of whole evaluator tree assigned to evaluated obj...
Definition: UtilityEvaluatorSnapshot.h:26
grail::utility::SelectionResult::SelectionResult
SelectionResult(bool isDebugging=false)
SelectionResult - Constructor.
Definition: SelectionResult.hh:25
grail::utility::SelectionResult::snapshot
std::unique_ptr< data::UtilityReasonerSnapshot > snapshot
snapshot - If debugging mode was enabled in constructor, contains debug snapshot of whole UtilityReas...
Definition: SelectionResult.hh:63