-
Notifications
You must be signed in to change notification settings - Fork 1
/
grid.h
62 lines (45 loc) · 1.73 KB
/
grid.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef __grid_H__
#define __grid_H__
#include "plant.h"
#include "genepack.h"
#include "vector.h"
#include "canopy.h"
#include <iostream>
class grid {
// 2D array of pointers to plant objects
plant ***plants;
//
canopy *canop;
int width, height, numPlants;
// sum of characteristics of all plants on the grid
float totalLife, totalNum, totalSpread, totalChance, totalHeight, totalWidth;
public:
// This class is implemented using a singleton design pattern
// instance is a pointer to the grid which will be used
static grid *instance;
// prevents more than one grid from ever being created; either
// returns instance or creates a new grid object
static grid *getInstance(int x, int y);
// initializes the grid
grid (int width = 0, int height = 0);
// destructs the grid as well as the arrays of pointers
~grid();
// creates a plant object with the given gene pack, at the
// given location, and occupies the corresponding tile
void addPlant (genePack const *gp, int ID, int x, int y);
// deletes a plant object at the given location and de-occupies
// the tile
void removePlant (int x, int y);
// increases the age of all plants on the board, removes plants
// which have lasted for their full duration and creates new
// plants
void tick ();
// if (individuals) prints stats for each plant on the grid
// if (wholeGrid) prints a ASCII representation of the grid
// if (averageStats) prints average stats of all the plants
void listPlants (bool individuals, bool wholeGrid, bool averageStats) const;
// prints the current averages of all of the stats for all the
// plants currently on the grid, separated by commas
void printCSV () const;
};
#endif