Initial commit
[universe.git] / intelligence.h
1
2 ////////////////////////////////////////////////////////////////////////////////
3 // This program is free software; you can redistribute it and/or              //
4 // modify it under the terms of the GNU General Public License                //
5 // version 2 as published by the Free Software Foundation.                    //
6 //                                                                            //
7 // This program is distributed in the hope that it will be useful, but        //
8 // WITHOUT ANY WARRANTY; without even the implied warranty of                 //
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU          //
10 // General Public License for more details.                                   //
11 //                                                                            //
12 // Written and (C) by François Fleuret                                        //
13 // Contact <francois.fleuret@epfl.ch> for comments & bug reports              //
14 ////////////////////////////////////////////////////////////////////////////////
15
16 // $Id: intelligence.h,v 1.20 2006-07-26 06:52:30 fleuret Exp $
17
18 #include "map.h"
19 #include "approximer.h"
20 #include "manipulator.h"
21
22 class Intelligence {
23   int _nb_actions;
24   Map *_input;
25   Manipulator *_manipulator;
26   int _max_memory_tick, _memory_tick;
27   scalar_t *_memory, *_rewards;
28   int *_actions;
29   MappingApproximer **_q_predictors;
30   int _nb_weak_learners;
31 public:
32   Intelligence(Map *input, Manipulator *manipulator, int max_memory_tick, int nb_weak_learners);
33   ~Intelligence();
34   void load(istream &is);
35   void save(ostream &os);
36   void update(int last_action, scalar_t last_reward);
37   void save_memory(char *filename);
38   void load_memory(char *filename);
39   void learn(scalar_t proportion_for_training);
40   int best_action();
41 };