e5dab7db1a707abe66f720888224749090c0356e
[universe.git] / task.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 #ifndef TASK_H
17 #define TASK_H
18
19 #include "misc.h"
20 #include "simple_window.h"
21
22 class Manipulator;
23 class Universe;
24
25 class Task {
26 public:
27   virtual ~Task();
28   // A canonical name for the task, upper caps, digits and "_"
29   virtual char *name() = 0;
30   // A task can be started with several degrees of difficulty
31   virtual int nb_degrees() = 0;
32   // Returns the size of the area
33   virtual int width() = 0;
34   virtual int height() = 0;
35   // Initializes the world (put polygons with Universe::add_polygon)
36   virtual void init(Universe *universe, int degree) = 0;
37   // Updates the world
38   virtual void update(scalar_t dt, Universe *universe, Manipulator *manipulator) = 0;
39   // Computes and returns the reward (can be positive or negative)
40   virtual scalar_t reward(Universe *universe, Manipulator *manipulator) = 0;
41   // If we need to draw something
42   virtual void draw(SimpleWindow *window) = 0;
43 };
44
45 // Loads a shared object file
46
47 Task *load_task(char *filename);
48
49 #endif