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. //
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. //
12 // Written and (C) by François Fleuret //
13 // Contact <francois.fleuret@epfl.ch> for comments & bug reports //
14 ////////////////////////////////////////////////////////////////////////////////
18 #include "manipulator.h"
20 class Dummy : public Task {
23 virtual char *name() { return "DUMMY"; }
25 virtual int nb_degrees() { return 1; }
27 virtual int width() { return 600; }
29 virtual int height() { return 700; }
31 virtual void init(Universe *universe, int degree) {
33 scalar_t width = 80, height = 80;
34 scalar_t deltax = 100, deltay = 100;
36 for(int k = 0; k < 4; k++) {
37 scalar_t x0 = k * deltax;
39 p = new Polygon(1.0, 1.0, scalar_t(k)/scalar_t(4), 0.0, 0, 0, 4);
40 p->set_vertex(0, 0, 0);
41 p->set_vertex(1, width, 0);;
42 p->set_vertex(2, width, height);
43 p->set_vertex(3, 0, height);
44 p->set_position(x0 + deltax/2, y0 + deltay/2, 0);
45 p->set_speed(0, 0, 0);
46 universe->initialize(p);
47 universe->add_polygon(p);
50 for(int k = 0; k < 2; k++) {
51 scalar_t x0 = deltax + k * deltax * 2;
53 p = new Polygon(1.0, scalar_t(k)/scalar_t(2), 1.0, 0.0, 0, 0, 4);
54 p->set_vertex(0, 0, 0);
55 p->set_vertex(1, width + deltax, 0);;
56 p->set_vertex(2, width + deltax, height);
57 p->set_vertex(3, 0, height);
58 p->set_position(x0, y0 + deltay/2, 0);
59 p->set_speed(0, 0, 0);
60 universe->initialize(p);
61 universe->add_polygon(p);
65 scalar_t y0 = 2 * deltay;
66 p = new Polygon(1.0, 1.0, 1.0, 0.0, 0, 0, 4);
67 p->set_vertex(0, 0, 0);
68 p->set_vertex(1, width + 3 * deltax, 0);;
69 p->set_vertex(2, width + 3 * deltax, height);
70 p->set_vertex(3, 0, height);
71 p->set_position(x0 + deltax, y0 + deltay/2, 0);
72 p->set_speed(0, 0, 0);
73 universe->initialize(p);
74 universe->add_polygon(p);
76 p = new Polygon(1.0, 0.8, 0.2, 0.8, 0, 0, 8);
77 p->set_vertex(0, 0.0, 0.0);
78 p->set_vertex(1, 180.0, 0.0);
79 p->set_vertex(2, 180.0, 220.0);
80 p->set_vertex(3, 0.0, 220.0);
81 p->set_vertex(4, 0.0, 180.0);
82 p->set_vertex(5, 140.0, 180.0);
83 p->set_vertex(6, 140.0, 40.0);
84 p->set_vertex(7, 0.0, 40.0);
85 p->set_position(120, 420, 0);
86 p->set_speed(0, 0, 0);
87 universe->initialize(p);
88 universe->add_polygon(p);
91 p = new Polygon(1.0, 0.0, 0.25, 1.0, 0, 0, ne);
92 for(int e = 0; e < ne; e++) {
93 scalar_t alpha = 2 * M_PI * scalar_t(e) / scalar_t(ne);
94 p->set_vertex(e, 200 + 50 * cos(alpha), 200 + 70 * sin(alpha));
96 p->set_position(400, 400, 0);
97 p->set_speed(0, 0, 0);
98 universe->initialize(p);
99 universe->add_polygon(p);
102 virtual void update(scalar_t dt, Universe *universe, Manipulator *manipulator) { }
104 virtual scalar_t reward(Universe *universe, Manipulator *manipulator) { return 0.0; }
106 virtual void draw(SimpleWindow *window) { }
110 extern "C" Task *new_task() {