-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.py
153 lines (118 loc) · 4.92 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
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
153
TEST_MODE = False
from math import sqrt
# Common settings for windows
TITLE = 'eportal'
# Window settings
WINDOW_SIZE = {'width': 1100, 'height': 550}
FPS = 80
# Scale
SCALE_MAX = 500
NONE_SPACES = ' '*13
SHORT_TERM_SPACES = ' '*9
LONG_TERM_SPACES = ' '*9
NONE_LABEL = NONE_SPACES + 'none'
SHORT_TERM_LABEL = SHORT_TERM_SPACES + 'short term'
LONG_TERM_LABEL = LONG_TERM_SPACES + 'long term'
SHORT_TERM_SEC = 0.3
LONG_TERM_SEC = 3
ENABLE = 1
DISABLE = 0
# Buttons
START_TEXT = '▷'
PAUSE_TEXT = '⏸︎'
RUN = 0
PAUSE = 1
# Help maintenance
GEOMETRY_RATIO = 0.7
POPULATED_ROOM = 80 # Room populated by the bottom items of the help window (defined experimentally)
HELP_SCROLLED_TEXT_FONT_SIZE = 10 # The initial height of the letters in points
SCROLLED_TEXT_FONT_SIZE_IN_PIXELS = HELP_SCROLLED_TEXT_FONT_SIZE*1.3333 # Retrieving the text with its size being transformed from points into pixels (1.333 must not be changed)
SCROLLED_FONT_SIZE_GAP_HEIGHT = SCROLLED_TEXT_FONT_SIZE_IN_PIXELS*1.13 # Retrieving the height of lines (the factor must not be changed)
LETTER_WIDTH = SCROLLED_TEXT_FONT_SIZE_IN_PIXELS/2 # Retrieving the width of letters (the divisior must not be changed)
TEXT_COLOR = '#ffffff'
HELP_WINDOW_BG = '#303030'
# Canvas
CANVAS_BORDER = 2 # Width of the outline of canvas
RIGHT_BUTTON_AREA_SIZE = 150
BOTTOM_BUTTON_AREA_SIZE = 50
CANVAS_WIDTH = WINDOW_SIZE['width'] - RIGHT_BUTTON_AREA_SIZE # Width of canvas
CANVAS_HEIGHT = WINDOW_SIZE['height'] - BOTTOM_BUTTON_AREA_SIZE # Height of canvas
HALF_EVOLUTION_FIELD_SIZE = {
'width': CANVAS_WIDTH/2,
'height': CANVAS_HEIGHT/2
}
# The canvas border enframes the canvas while the evolution field (the field where the graphics are painted) saves the size of the canvas. The (0, 0) coordinates for the evolution field equal the (CANVAS_BORDER, CANVAS_BORDER) coordinates for the canvas. While the evolution is going, nominal coordinates of the evolution field are used. While displaying the evolution, nominal coordinates are transformed into coordinates that are suitable for canvas
# Bodies
# Shapes
BODY_SIZE = 10 # Size of the Bodies
DOUBLE_BODY_SIZE = BODY_SIZE*2
NEWLY_BORN_PERIOD = FPS*1.2 # When time-lapse is 'none', 1.2 seconds is the period of time when the body is newly born
TRIANGLE = 0
CIRCLE = 1
SQUARE = 2
RHOMBUS = 3
SMART_BODY_SHAPES = (SQUARE, RHOMBUS)
# Triangle shape
TRIANGLE_WIDTH = BODY_SIZE*1.1 # Width of the triangle base
# The further constants are only calculations
TRIANGLE_WIDTH_2 = TRIANGLE_WIDTH/2
SQRT_OF_THREE = sqrt(3)
R_TRIANGLE = TRIANGLE_WIDTH/SQRT_OF_THREE # Radius of the circumscribed circle
D_TIANGLE = (TRIANGLE_WIDTH*SQRT_OF_THREE)/2 - R_TRIANGLE # Triangle height - R_TRIANGLE
# Rhombus shape
RHOMBUS_SIZE = BODY_SIZE*1.4
HALF_RHOMBUS_SIZE = RHOMBUS_SIZE/2
# Food preference
BODY = 'bodies'
PLANT = 'plants'
# Status
SLEEPING = 0
RUNNING_AWAY = 1
FOLLOWING_PLANT = 2
FOLLOWING_BODY = 3
CONTROL_PREPARATION = 0
DELETE_EVERYTHING = 1
EVOLUTION_PREPARATION = 2
EVOLUTION = 3
USER_SELECTING_BODY = 4
ON_PAUSE = 5
FROM = 0
TO = 1
WON = 0
DRAW = 1
# Related to plants
PLANT_ENERGY = 100
PLANT_PREFERENCE_CHANCE = 0.5 # The chance that the body will prefer eating plant
PROCREATION_THRESHOLD = 5*PLANT_ENERGY
# Appearance
VISION_DISTANCE = 75
HALF_BODY_SIZE = BODY_SIZE/2
MAXIMUM_COLOUR = 220
MAX_COLOUR_DISTANCE = sqrt(3*MAXIMUM_COLOUR**2) # This is the maximum of sqrt((r1-r2)**2 + (g1-g2)**2 + (b1-b2)**2)
# First generation
PLANT_ENERGY = 100 # Energy to a body for eating a plant
INITIAL_ENERGY = 4*PLANT_ENERGY # Initial energy at the start for the body not to die immediately
# Procreating
FOOD_PREFERENCE_CHANCE_CHILD = 0.9 # The chance that the child will inherit the food preference of the parent
DEVIATION_OF_RANDOM_PROPERTIES = 0.1 # Proportionates to standard deviation
DEVIATION_OF_RANDOM_PROPERTIES_ZERO_GENERATION = 0.4 # Proportionates to standard deviation for the zero generation
PLACEMENT_GAP = 2.5
BODY_SPEED = 0.6
BODIES_AMOUNT = 20 if TEST_MODE is False else 1 # Amount of Bodies on the window
ENERGY_FOR_VISION = 0.00007*PLANT_ENERGY if TEST_MODE is False else 534354534*PLANT_ENERGY # Energy spent for vision
ENERGY_FOR_MOVING = 0.007*PLANT_ENERGY if TEST_MODE is False else 534354534*PLANT_ENERGY # Energy spent for moving
# Plants
PLANT_COLOUR = (14, 209, 69) # Not defining the colour, but saying that the RGB of the plant is this one
TIMES_ATTEMPTED = 1000 # Limit of times for trying to place a plant on the window
PLANT_SIZE_RATIO = 25 # Higher => smaller
PLANT_CHANCE = 0.1 if TEST_MODE is False else 0 # The chance (percent = PLANT_CHANCE * 100) of a plant emerging
INITIALLY_PLANTED = BODIES_AMOUNT*3 if TEST_MODE is False else 100 # Amount of plants that have to be planted initially
# Crosses
CROSS_LIFETIME = 3 # Lifetime of a cross
# Cross appearance
CROSS_SIZE_RATIO = 3 # Higher => smaller
# Display results
RATIO = 100 # Making the results that are displayed more readable
# Other
DELTA = 0.1 # Window update every DELTA seconds
AI_THINKS = 5 # In seconds