equal
deleted
inserted
replaced
21 using namespace lemon; |
21 using namespace lemon; |
22 |
22 |
23 class MyEntity : public EntityBase { |
23 class MyEntity : public EntityBase { |
24 public: |
24 public: |
25 double d, prev_d; |
25 double d, prev_d; |
26 MyEntity() : d(100000.0) { srand48(time(0)); } |
26 MyEntity() : d(100000.0) {} |
27 double mutate() { |
27 double mutate() { |
28 prev_d = d; |
28 prev_d = d; |
29 if (drand48() < 0.8) { d += 1.0; } |
29 if (rnd.boolean(0.8)) { d += 1.0; } |
30 else { d -= 1.0; } |
30 else { d -= 1.0; } |
31 return d; |
31 return d; |
32 } |
32 } |
33 void revert() { d = prev_d; } |
33 void revert() { d = prev_d; } |
34 MyEntity* clone() { return new MyEntity (*this); } |
34 MyEntity* clone() { return new MyEntity (*this); } |