-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame_builder.py
More file actions
37 lines (25 loc) · 920 Bytes
/
game_builder.py
File metadata and controls
37 lines (25 loc) · 920 Bytes
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
class GameBuilder:
def __init__(self, controller):
self.controller = controller
# ---------------------------------
# BUILD WORLD FROM STORY
# ---------------------------------
def build(self, spec):
self.controller.world_spec = spec
# POWERUPS
for p in spec.get("powerups", []):
self.controller.powerups.add(
p["name"],
p.get("effect", {}),
duration=10.0
)
# ENTITIES
self.controller.entities = spec.get("entities", [])
# ---------------------------------
# APPLY RULES EACH STEP
# ---------------------------------
def apply_rules(self, signals):
rules = self.controller.world_spec.get("rules", {})
if rules.get("entropy_increases_over_time"):
signals["entropy"] = signals.get("entropy", 0.3) + 0.01
return signals