stochastic simulation, predator/prey

Dependencies:   mbed

Committer:
manitou
Date:
Mon Dec 23 18:56:56 2019 +0000
Revision:
0:fc1335b7b54f
stochastic simulation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
manitou 0:fc1335b7b54f 1 //
manitou 0:fc1335b7b54f 2 // Bug.h
manitou 0:fc1335b7b54f 3 // INHERITANCE_AND_POLYMORPHISM
manitou 0:fc1335b7b54f 4 //
manitou 0:fc1335b7b54f 5 // Created by Kristjan Thorsteinsson on 01/04/14.
manitou 0:fc1335b7b54f 6 // Copyright (c) 2014 Kristjan Thorsteinsson. All rights reserved.
manitou 0:fc1335b7b54f 7 //
manitou 0:fc1335b7b54f 8
manitou 0:fc1335b7b54f 9 #ifndef INHERITANCE_AND_POLYMORPHISM_Bug
manitou 0:fc1335b7b54f 10 #define INHERITANCE_AND_POLYMORPHISM_Bug
manitou 0:fc1335b7b54f 11
manitou 0:fc1335b7b54f 12 //#include <iostream>
manitou 0:fc1335b7b54f 13
manitou 0:fc1335b7b54f 14 #include "World.h"
manitou 0:fc1335b7b54f 15 #include "Organism.h"
manitou 0:fc1335b7b54f 16 #include "Counter.h"
manitou 0:fc1335b7b54f 17
manitou 0:fc1335b7b54f 18 class Bug : public Organism, public counter<Bug>
manitou 0:fc1335b7b54f 19 {
manitou 0:fc1335b7b54f 20 public:
manitou 0:fc1335b7b54f 21
manitou 0:fc1335b7b54f 22 Bug(World* aWorld, int xcoord, int ycoord);
manitou 0:fc1335b7b54f 23 // In the given world moves this organism.
manitou 0:fc1335b7b54f 24 void move();
manitou 0:fc1335b7b54f 25
manitou 0:fc1335b7b54f 26 // Makes this organism breed.
manitou 0:fc1335b7b54f 27 void breed();
manitou 0:fc1335b7b54f 28
manitou 0:fc1335b7b54f 29 // Returns the type of this organism.
manitou 0:fc1335b7b54f 30 OrganismType getType() const;
manitou 0:fc1335b7b54f 31
manitou 0:fc1335b7b54f 32 // The character representation of this organism.
manitou 0:fc1335b7b54f 33 char representation() const;
manitou 0:fc1335b7b54f 34
manitou 0:fc1335b7b54f 35 // The size of this organism.
manitou 0:fc1335b7b54f 36 int size() const;
manitou 0:fc1335b7b54f 37 // Returns true if organism is dead, false otherwise.
manitou 0:fc1335b7b54f 38 bool isDead() const;
manitou 0:fc1335b7b54f 39
manitou 0:fc1335b7b54f 40 bool in_range(int xx, int yy);
manitou 0:fc1335b7b54f 41
manitou 0:fc1335b7b54f 42 private:
manitou 0:fc1335b7b54f 43
manitou 0:fc1335b7b54f 44 void generateOffspring(int whereX, int whereY);
manitou 0:fc1335b7b54f 45 int starveTicks;
manitou 0:fc1335b7b54f 46 };
manitou 0:fc1335b7b54f 47
manitou 0:fc1335b7b54f 48 #endif /* defined(__INHERITANCE_AND_POLYMORPHISM__Bug__) */