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