-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEconomy.java
More file actions
85 lines (62 loc) · 1.45 KB
/
Economy.java
File metadata and controls
85 lines (62 loc) · 1.45 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import java.util.*;
public class Economy {
// Pointers
Country country;
// Economic Variables
double spirits; // confidence -100 < x < 100
double dSpirits; // confidence delta
// Timing
int quarter;
int year;
// Business Cycle
BusinessCycle cycle;
// Companies
public ArrayList<Company> companies = new ArrayList<Company>();
int coId = 0;
// Constructors
public Economy (Country newCountry, int numCo, double taxRate, int suppressionLevel) {
MacSim.log(4, "Creating Economy... ");
country = country;
spirits = 0; // neutral spirits
}
// Update
public void tick(long tick) {
updateCycle(tick);
updateSentiment(tick);
if(tick % 25 == 0) {
updateQuarter();
}
if(tick % 100 == 0) {
updateYear();
}
}
void updateCycle(long tick) {
if(cycle == null || cycle.complete())
cycle = new BusinessCycle((MacSim.rand.nextInt(2) + 1) * 150, 2);
cycle.tick();
}
void updateSentiment(long tick) {
}
void updateYear() {
}
void updateQuarter() {
}
// Generation
void generateCompanies(int num) {
int each = (int)(country.pop.unemployed / num);
int remainder = country.pop.unemployed % num;
MacSim.log(3, "Generating " + num + " companies");
for(int i = 0; i < num; i++) {
if(i < remainder) {
generateCompany(each + remainder);
} else {
generateCompany(each);
}
}
}
void generateCompany(int hire) {
Company newCo = new Company(this, hire, coId);
companies.add(newCo);
coId++;
}
}