-
Notifications
You must be signed in to change notification settings - Fork 3
/
old_main.py
152 lines (122 loc) · 4.19 KB
/
old_main.py
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import database as d
import people as p
import jobs as j
import unit as u
import business as b
import gameMap as g
import profiles as pr
import generator as gen
import pickle
import sys
#main
#world generator
worldGen = gen.generator()
BraveNewWorld = worldGen.generateWorld(30, 3, 3)
BraveNewWorld.printMap()
Jonestown = d.getLocality()[0]
#people, unit, business test
JohnDoe = d.peopleList[0]
JaneDoe = d.peopleList[1]
SusanSmith = d.peopleList[2]
MillersMill = b.Business("Miller's Mill", 30)
TheMill = u.Mill("The old mill", Jonestown, (1,1), MillersMill)
MillersWarehouse = u.Warehouse("Miller's Warehouse", Jonestown, (7,3), MillersMill)
Bakery = u.Market("Ye Olde Bakery", Jonestown, (7,1), MillersMill)
Deli = u.Market("Ye Delicious Deli", Jonestown, (1,3), MillersMill)
MillingJob = j.Miller(10, MillersMill, TheMill)
Transporter = j.Carrier(1, MillersMill, MillersWarehouse)
ManagerJob = j.Manager(1, MillersMill, MillersWarehouse)
BraveNewWorld.printMap()
Jonestown.printMap()
#jobs test
print("Hire JaneDoe MillingJob:", MillersMill.hire(JaneDoe,MillingJob))
print("Hire JohnDoe Transporter:", MillersMill.hire(JohnDoe,Transporter))
print("Hire JaneDoe MillingJob:", MillersMill.hire(JaneDoe,MillingJob))
print("Hire SusanSmith ManagerJob:", MillersMill.hire(SusanSmith,ManagerJob))
print("MillingJob slots:", MillingJob.getSlots())
print(JaneDoe.toString())
print(JohnDoe.toString())
print(SusanSmith.toString())
print("TheMill initial grain stock:", TheMill.getStock(0))
TheMill.addStock(0,10)
print("TheMill final grain stock:", TheMill.getStock(0))
print("Grain:", TheMill.getStock(0))
print("Flour:", TheMill.getStock(1))
print(MillingJob.grind(3))
print("Grain:", TheMill.getStock(0))
print("Flour:", TheMill.getStock(1))
print("MillingJob final employees:", MillingJob.getEmployees())
print("TheMill initial output:", TheMill.output)
ManagerJob.transferMats(TheMill,1,3)
print("TheMill middle output:", TheMill.output)
Transporter.transportMats(TheMill, MillersWarehouse, 1, 2)
print("TheMill final output:", TheMill.output)
print("MillersWarehouse stock:", MillersWarehouse.stock)
#orders test
print("TheMill stock:", TheMill.stock)
MillersMill.createOrder(MillingJob.grind, [2])
MillersMill.orders[0].execute()
print("TheMill stock:", TheMill.stock)
#mu test
JaneDoe.home.stock = [1,2,0,1]
print("JaneDoe home stock:", JaneDoe.home.getAllStock())
JaneDoe.marginalUtility()
print("JaneDoe mu:",JaneDoe.getmuList())
#store choice test
p_Bakery = pr.StoreProfile(Bakery)
p_Bakery.updateLocality(Jonestown)
p_Bakery.updateFamiliarity(5)
p_Bakery.updateExperience(1)
p_Bakery.updateLocation(Bakery.getLocation())
p_Bakery.updatePrices([1,1,1,1])
p_Deli = pr.StoreProfile(Deli)
p_Deli.updateLocality(Jonestown)
p_Deli.updateFamiliarity(5)
p_Deli.updateExperience(10)
p_Deli.updateLocation(Deli.getLocation())
p_Deli.updatePrices([1,1,1,1])
JaneDoe.knownStores.append(p_Bakery)
JaneDoe.knownStores.append(p_Deli)
print("JaneDoe chooses to shop at:",JaneDoe.chooseStore()[0].name)
#pricegen test
Bakery.output = [1,0,1,5]
Bakery.capital = [6,1,1,1]
Bakery.price = [1,1,1,1]
Bakery.sales = [1,0,10,10]
Deli.output = [1,0,1,5]
Deli.capital = [6,1,1,1]
Deli.price = [1,1,1,1]
Deli.sales = [1,0,10,10]
print("Bakery initial prices:",Bakery.price)
Bakery.priceGen()
print("Bakery final prices:",Bakery.price)
#purchase test
JaneDoe.capital = 100
print("JaneDoe initial capital:",JaneDoe.capital)
print("Bakery initial capital:",Bakery.money)
JaneDoe.purchase(Bakery)
print("Bakery final capital:",Bakery.money)
print("JaneDoe final capital:",JaneDoe.capital)
print("JaneDoe inventory:",JaneDoe.getInventory())
print("Bakery final output:",Bakery.output)
#FSM test
print("Time:",Jonestown.clock.state)
print("Day of week:",Jonestown.week.state)
Jonestown.clock.next_state()
print("Time:",Jonestown.clock.state)
print("Day of week:",Jonestown.week.state)
print(JaneDoe.state)
JaneDoe.wake_up()
print(JaneDoe.state)
JaneDoe.work_end()
print(JaneDoe.state)
JaneDoe.wind_down()
print(JaneDoe.state)
JaneDoe.bedtime()
print(JaneDoe.state)
#write to file test
# output = open("./peopleDatabase.txt", "wb")
# pickle.dump(JaneDoe, output)
# ourFile = open("./peopleDatabase.txt", "rb")
# JanetteDoe = pickle.load(ourFile)
# print(JanetteDoe.chooseStore()[0].name)