/***
*
* agent-cmac-dbi.h
*
* $Revision: 1.3 $
*
* Description:
*
*   This module is the interface for the agent's functions for
*   controlling a double integrator. The Q-function approximation is
*   implemented with cmacs.
*
* Author:
*   Juan Carlos Santamaria
*     E-mail: carlos@cc.gatech.edu
*     URL:    http://www.cc.gatech.edu/ai/students/jcs
*
* File name:
*   $Id: agent-cmac-dbi.h,v 1.3 1996/09/19 22:09:25 carlos Exp $
*
* Revision History:
*   $Log: agent-cmac-dbi.h,v $
*   Revision 1.3  1996/09/19  22:09:25  carlos
*   - The discount factor, GAMMA, is now an agent field instead of a constant.
*     The value can be set at the moment of creation through the constructor.
*     The default value is 0.99.
*   - Eliminate the arguments ps and pa from Agent::step.
*
*   Revision 1.2  1996/08/28  20:11:38  carlos
*   - Old local variables are now member variables.
*   - New private function A_CMAC_DBI::policy was added.
*   - Change in the order of arguments in Agent::step:
*       old: S,A,r,S'    new: S,A,S',r
*
*   Revision 1.1  1996/08/14  20:54:25  carlos
*   Initial revision
*
****/

#pragma interface

#ifndef _INCL_AGENT_CMAC_DBI
#define _INCL_AGENT_CMAC_DBI


// -- Include files

#ifndef _INCL_RLI
#include "rli.h"
#endif

#ifndef _INCL_ENVIRONMENT_DBI
#include "environment-dbi.h"
#endif

#ifndef _INCL_CMAC
#include "cmac.h"
#endif


// -- Class and type declarations


class A_CMAC_DBI : public Agent {
public:
    int      rnd_strm;
    bool     verbose;
    char     filename[30];
    
    double   GAMMA;
    
    CMAC_CA* pcmac;
    
    int      features[36];

    A_CMAC_DBI( double gamma = 0.99 ) : Agent(), rnd_strm(1), verbose(FALSE), 
                                        GAMMA(gamma), pcmac(0)
        { filename[0]='\0'; }
    ~A_CMAC_DBI( void ) { delete pcmac; }

    void init( int argc, char *argv[] );

    Action *start_trial( const Sensation *ps );

    Action *step( const Sensation *pnext_s,
                  double           reward );

    void    output_value_function_grid( ostream& to );

private:
    double  policy( const State *ps, Force *pa );
};


#endif

/****************************** end of file *********************************/