I'm new to C++ programming and have been studying the Behavior Tree Starter Kit to build a new AI framework. I'm having a hard time understanding the Behavior Tree Starter Kit code. Given this C++ code for a Game AI behavior Tree, what does the part of the code at the top (that seems to be setting the intial status or something) mean? And what is the virtual piece?
Behavior()
: m_eStatus(BH_INVALID)
{
}
virtual ~Behavior()
{
}
Here is the full code, also what does virtual Status update() = 0;
mean:
class Behavior
/**
* Base class for actions, conditions and composites.
*/
{
public:
virtual Status update() = 0;
virtual void onInitialize() {}
virtual void onTerminate(Status) {}
Behavior()
: m_eStatus(BH_INVALID)
{
}
virtual ~Behavior()
{
}
Status tick()
{
if (m_eStatus != BH_RUNNING)
{
onInitialize();
}
m_eStatus = update();
if (m_eStatus != BH_RUNNING)
{
onTerminate(m_eStatus);
}
return m_eStatus;
}
void reset()
{
m_eStatus = BH_INVALID;
}
void abort()
{
onTerminate(BH_ABORTED);
m_eStatus = BH_ABORTED;
}
bool isTerminated() const
{
return m_eStatus == BH_SUCCESS || m_eStatus == BH_FAILURE;
}
bool isRunning() const
{
return m_eStatus == BH_RUNNING;
}
Status getStatus() const
{
return m_eStatus;
}
private:
Status m_eStatus;
};