-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
84 lines (69 loc) · 1.73 KB
/
config.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
from dataclasses import dataclass
from typing import Callable
from pygame.locals import Color
@dataclass
class Ruleset:
conditions: list[Callable[[int, int], int]]
max_state: int
start_rule: Callable[[int, int], int]
count_indirect_neighbours: bool
@dataclass
class Config:
behaviour: Ruleset
env_width: int
env_height: int
win_width: int
win_height: int
cell_gap: int
bg_colour: Color
alive_colour: Color
dead_colour: Color
# ------------ DEFINE RULESETS HERE ------------ #
conway = Ruleset(
conditions=(
lambda n,s: False if n < 2 or n > 3 else s,
lambda n,s: True if n==3 else s
),
max_state=1,
start_rule=lambda x,y: 0,
count_indirect_neighbours=True
)
labyrinth = Ruleset(
conditions=(
lambda n,s: s+1 if n > 5 and n < 9 else s,
lambda n,s: 0 if n < 3 or n > 8 else s
),
max_state=2,
start_rule=lambda x,y: 2 if x*100+y % 2 == 0 else 0,
count_indirect_neighbours=True
)
corruptor = Ruleset(
conditions=(
lambda n,s: s+1 if n > 5 and n < 9 else s,
lambda n,s: 0 if n < 3 or n > 8 else s
),
max_state=2,
start_rule=lambda x,y: 2 if y%2 == 0 else 0,
count_indirect_neighbours=True
)
biobrush = Ruleset(
conditions=(
lambda n,s: s+1 if n > 5 and n < 9 else s,
lambda n,s: 0 if n < 3 or n > 8 else s
),
max_state=3,
start_rule=lambda x,y: 0,
count_indirect_neighbours=False
)
# ------------ DEFINE CONFIG HERE ------------ #
config = Config(
behaviour=conway,
env_width=100,
env_height=100,
win_width=500,
win_height=500,
cell_gap=1,
bg_colour=Color(0, 0, 0),
alive_colour=Color(240, 0, 120),
dead_colour=Color(30, 30, 30)
)