Controller.h

00001 // ----------------------------------------------------------------------------
00002 //
00003 // tagGame - Example code from the book:
00004 //
00005 //           Artficial Intelligence for Computer Games: An Introduction
00006 //           by John David Funge
00007 //
00008 //           www.ai4games.org
00009 //
00010 // Source code distributed under the Copyright (c) 2003-2007, John David Funge
00011 // Original author: John David Funge (www.jfunge.com)
00012 //
00013 // Licensed under the Academic Free License version 3.0 
00014 // (for details see LICENSE.txt in this directory).
00015 //
00016 // ----------------------------------------------------------------------------
00017 
00018 #ifndef TG_CONTROLLER_H
00019 #define TG_CONTROLLER_H
00020 
00021 #include "Action.h"
00022 
00023 namespace tagGame
00024 {
00025    class Perception;
00026    class Action;
00027    class Controller;
00028 
00029    typedef SharedPtr<Perception>::type PerceptionPtr;
00030    typedef SharedPtr<Controller>::type ControllerPtr;
00031 
00033    class Controller
00034    {
00035    public:
00036       inline Controller(PerceptionPtr perception);
00037       inline virtual ~Controller();
00038 
00040       virtual void calcAction() = 0;
00042       inline Action const& getAction();
00044       inline void setAction(Action const& action);
00046       inline PerceptionPtr getPerception();
00050       inline void setPerception(PerceptionPtr perception);
00051    protected:
00052       // The controller's perception object (see Chapter 3).
00053       PerceptionPtr perception;
00054       // The last calculated action.
00055       Action action;
00056    private:
00057    }; // Controller
00058 
00059    Controller::Controller(PerceptionPtr perception) :
00060       perception(perception)
00061    {
00062    }
00063 
00064    Controller::~Controller()
00065    {
00066    }
00067 
00068    Action const& Controller::getAction()
00069    {
00070       return this->action;
00071    }
00072    
00073    void Controller::setAction(Action const& action)
00074    {
00075       this->action = action;
00076    }
00077    
00078    PerceptionPtr Controller::getPerception()
00079    {
00080       return perception;
00081    }
00082    
00083    void Controller::setPerception(PerceptionPtr perception)
00084    {
00085       this->perception = perception;
00086    }
00087 }
00088 
00089 #endif

Generated on Sat Mar 31 22:30:54 2007 for tagGame by  doxygen 1.5.1