forked from omelyanchikd/ace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathideal_world.py
34 lines (30 loc) · 1.15 KB
/
ideal_world.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
from firm_action import FirmAction
from firm_result import FirmResult
from world import World
class IdealWorld(World):
def apply_firm_action(self, firm_id):
"""
Ideal world! Everything is sold and new workers are everywhere.
:type firm_id: int
"""
firm_action = self.firm_actions[firm_id]
assert isinstance(firm_action, FirmAction)
workers_count = firm_action.offer_count
workers = []
# here you have everyone non-employed
for worker in self.workers:
if worker.employer is None:
workers.append(worker)
workers_count -= 1
if workers_count == 0:
break
# if it's not enough - here you have more!
# if workers_count > 0:
# for w in range(workers_count):
# new_worker_id = len(self.workers)
# worker = Worker(new_worker_id)
# self.workers.append(worker)
# workers.append(worker)
# all your stuff is sold!
sold_count = firm_action.production_count
return FirmResult(workers, firm_action.salary, sold_count)