#include <AILogic.h>
|
| Logic (LOGIC_IDS logicId_, const int maxRules_=-1) |
|
LOGIC_IDS | getLogicId () const |
|
bool | createDerivationRule (const std::vector< Premise > &antecedents_, const std::vector< int > &numOfParamsInAntecsToCheck_, int consequentStateInput_, const std::vector< int > ×Found_, const std::vector< bool > &acceptOnlyNewSinceStateChange_, const std::vector< float > &secondsOld_, const std::vector< Premise > &conseKBPrems_, const std::vector< Premise > &remKBPrems_, const std::vector< bool > &remAll_) |
|
bool | performLogic (State *&state_, KB *&kB_, float &timeStamp_, bool includeGlobalKB_=false) |
| returns true if state_ changed, false otherwise More...
|
|
int | serialize (std::ofstream &fout_) const |
|
int | assemble (std::ifstream &fin_) |
|
Logic implements state transitions for AI::Wrapper objects. Specifically, it maps Records from a KB into state inputs according to predefined rules.
Logic::Logic |
( |
LOGIC_IDS |
logicId_, |
|
|
const int |
maxRules_ = -1 |
|
) |
| |
parameterized constructor
- Parameters
-
logicId_ | the unique identifier for this logic processor |
maxRules_ | -1 means an unlimited # of rules are allowed |
int Logic::assemble |
( |
std::ifstream & |
fin_ | ) |
|
assigns this object to one read from a binary file and returns the number of bytes read
- Parameters
-
fin_ | the file stream to read from (opened for binary input) |
- See Also
- serialize()
bool Logic::createDerivationRule |
( |
const std::vector< Premise > & |
antecedents_, |
|
|
const std::vector< int > & |
numOfParamsInAntecsToCheck_, |
|
|
int |
consequentStateInput_, |
|
|
const std::vector< int > & |
timesFound_, |
|
|
const std::vector< bool > & |
acceptOnlyNewSinceStateChange_, |
|
|
const std::vector< float > & |
secondsOld_, |
|
|
const std::vector< Premise > & |
conseKBPrems_, |
|
|
const std::vector< Premise > & |
remKBPrems_, |
|
|
const std::vector< bool > & |
remAll_ |
|
) |
| |
a rule has this format: IF (antecedent1 AND antecedent2 AND ...), THEN (return the consequent state input, possibly add premises to the object's knowledge base, and possibly remove premises from the object's knowledge base)
- Parameters
-
antecedents_ | an antecedent is defined as a Premise plus other parameters such as allowing for the premise to expire |
numOfParamsInAntecsToCheck_ | the premise ID (params[0]) counts toward this number |
consequentStateInput_ | the input to send to the finite state machine if all antecedents are true |
timesFound_ | check for AT LEAST this many instances of the premise for the antecedent to be true (default will be once/prem) |
acceptOnlyNewSinceStateChange_ | if true, premises inserted into the KB before the last state change are ignored |
secondsOld_ | premises in the KB older than this are ignored (-1 means that none expire) |
conseKBPrems_ | premises added to an object's knowledge base if all antecedents are true |
remKBPrems_ | premises removed from an object's knowledge base if all antecedents are true |
remAll_ | remove all instances of the remKBPrems_ if they are found? |
LOGIC_IDS OpenSkyNet::AI::Logic::getLogicId |
( |
| ) |
const |
|
inline |
returns the _logicId for this logic processor
bool Logic::performLogic |
( |
State *& |
state_, |
|
|
KB *& |
kB_, |
|
|
float & |
timeStamp_, |
|
|
bool |
includeGlobalKB_ = false |
|
) |
| |
returns true if state_ changed, false otherwise
changes a state according to Rules
- Parameters
-
state_ | the current state |
kB_ | the KB to use for finding Records |
timeStamp_ | timestamp of last state change (updated if state is changed in this function) |
includeGlobalKB_ | use the global KB? |
int Logic::serialize |
( |
std::ofstream & |
fout_ | ) |
const |
writes this object to a binary file and returns the number of bytes written
- Parameters
-
fout_ | the file stream to write to (opened for binary output) |
- See Also
- assemble()
The documentation for this class was generated from the following files: