34 #include "../Utils_LIB/UTypes.h"
39 namespace OpenSkyNet {
79 virtual bool equals(
const Premise& rhs_,
unsigned int numParamsToCheck_)
const;
107 virtual int serialize(std::ofstream& fout_)
const;
114 virtual int assemble(std::ifstream& fin_);
155 int stateIdAtCreation_=-1) :
_n(n_),
160 float badGoodScaleValue_=0.0f,
int stateIdAtCreation_=-1) :
Premise(params_),
193 int serialize(std::ofstream& fout_,
const std::vector<T>& vector_) {
194 static const unsigned int sizeOfType =
sizeof(T);
195 unsigned int bytesWritten = 0;
196 unsigned int vectorSize =
static_cast<unsigned int>(vector_.size());
198 fout_.write(reinterpret_cast<char*>(&vectorSize),
sizeof(vectorSize));
199 bytesWritten +=
sizeof(vectorSize);
202 for (
unsigned int i = 0; i < vectorSize; i++) {
203 element = vector_[i];
204 fout_.write(reinterpret_cast<char*>(&element),sizeOfType);
206 bytesWritten += vectorSize*sizeOfType;
218 int assemble(std::ifstream& fin_, std::vector<T>& vector_) {
219 static const unsigned int sizeOfType =
sizeof(T);
220 unsigned int bytesRead = 0;
221 unsigned int vectorSize = 0;
224 fin_.read(reinterpret_cast<char*>(&vectorSize),
sizeof(vectorSize));
225 bytesRead +=
sizeof(vectorSize);
227 vector_.resize(vectorSize);
229 for (
unsigned int i = 0; i < vectorSize; i++) {
230 fin_.read(reinterpret_cast<char*>(&element),sizeOfType);
231 vector_[i] = element;
233 bytesRead += vectorSize*sizeOfType;
245 int serialize(std::ofstream& fout_,
const std::vector<Premise>& premVector_);
254 int assemble(std::ifstream& fin_, std::vector<Premise>& premVector_);
263 int serialize(std::ofstream& fout_,
const std::vector<Action>& actVector_);
272 int assemble(std::ifstream& fin_, std::vector<Action>& actVector_);
virtual bool operator==(const Premise &rhs_) const
Definition: AIBase.cpp:19
Record & operator+=(int param_)
Definition: AIBase.h:175
float _entryTime
of secs elapsed from time program started to time entered in a KB
Definition: AIBase.h:55
Action & operator=(int param_)
Definition: AIBase.h:128
virtual ~Record()
empty destructor
Definition: AIBase.h:180
bool _negated
look for absence of this premise in a KB
Definition: AIBase.h:56
Record(OpenSkyNet::AI::Wrapper *n_=0, float badGoodScaleValue_=0.0f, int stateIdAtCreation_=-1)
Definition: AIBase.h:154
virtual int serialize(std::ofstream &fout_) const
Definition: AIBase.cpp:37
Premise(const std::vector< int > ¶ms_)
Definition: AIBase.h:67
int serialize(std::ofstream &fout_, const std::vector< T > &vector_)
Definition: AIBase.h:193
virtual bool equals(const Premise &rhs_, unsigned int numParamsToCheck_) const
Definition: AIBase.cpp:23
Premise & operator=(int param_)
Definition: AIBase.h:85
Premise & operator+=(int param_)
Definition: AIBase.h:97
int assemble(std::ifstream &fin_, std::vector< T > &vector_)
Definition: AIBase.h:218
float _badGoodScaleValue
ranking of the record for the target on a bad/good axis
Definition: AIBase.h:151
OpenSkyNet::Utils::PrecisionTimer g_timer
Definition: AIBase.cpp:11
int _stateIdAtCreation
state ID of target when record is created
Definition: AIBase.h:152
Definition: AIWrapper.h:40
std::vector< int > _params
_params[0] must be the premise ID
Definition: AIBase.h:54
Record & operator=(int param_)
Definition: AIBase.h:170
OpenSkyNet::AI::Wrapper * _n
the target of the record (if any)
Definition: AIBase.h:150
virtual ~Action()
empty destructor
Definition: AIBase.h:138
Record(const Premise &premise_)
Definition: AIBase.h:164
virtual ~Premise()
empty destructor
Definition: AIBase.h:116
Action & operator+=(int param_)
Definition: AIBase.h:133
Definition: UPrecisionTimer.h:58
Premise()
Definition: AIBase.h:61
Action(const std::vector< int > ¶ms_)
Definition: AIBase.h:126
virtual int assemble(std::ifstream &fin_)
Definition: AIBase.cpp:51
Action()
Definition: AIBase.h:124
Record(const std::vector< int > ¶ms_, OpenSkyNet::AI::Wrapper *n_=0, float badGoodScaleValue_=0.0f, int stateIdAtCreation_=-1)
Definition: AIBase.h:159