Tactics: Western Philosophers Vs. Musicians  0.12
A turn-based tactical game combining rules and gameplay elements inspired by Final Fantasy Tactics and the Mayfair Exponential Game System. Unlike most games of this type, motion is in full, grid-less 3D.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | List of all members
OpenSkyNet::AI::Logic Class Reference

#include <AILogic.h>


struct  Rule

Public Member Functions

 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 > &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_)
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_)

Detailed Description

Logic implements state transitions for AI::Wrapper objects. Specifically, it maps Records from a KB into state inputs according to predefined rules.

Constructor & Destructor Documentation

Logic::Logic ( LOGIC_IDS  logicId_,
const int  maxRules_ = -1 

parameterized constructor

logicId_the unique identifier for this logic processor
maxRules_-1 means an unlimited # of rules are allowed

Member Function Documentation

int Logic::assemble ( std::ifstream &  fin_)

assigns this object to one read from a binary file and returns the number of bytes read

fin_the file stream to read from (opened for binary input)
See Also
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)

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

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

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

fout_the file stream to write to (opened for binary output)
See Also

The documentation for this class was generated from the following files: