@@ -26,159 +26,13 @@ def setup():
26
26
"smell_signature" : [0 , 0 , 1 , 0 , 0 ]
27
27
}]
28
28
})
29
- test_robot_genome = RobotGenome ()
30
- test_robot_genome .randomise ()
31
- test_robot_genome .sensors .list [0 ].mapping .from_flattened ([ # contra food/water
32
- {"x" : 0.0 , "y" : - 1.0 / 2 },
33
- # {"x": 0.3, "y": -0.3/2},
34
- # {"x": 0.7, "y": 0.3/2},
35
- {"x" : 1.0 , "y" : 1.0 / 2 },
36
- ])
37
- test_robot_genome .sensors .list [3 ].mapping .from_flattened ([ # ipsi food/water
38
- {"x" : 0.0 , "y" : 1.0 / 2 },
39
- # {"x": 0.3, "y": 0.7/2},
40
- # {"x": 0.7, "y": 0.5/2},
41
- {"x" : 1.0 , "y" : 0.5 / 2 },
42
- ])
43
- test_robot_genome .sensors .list [5 ].mapping .from_flattened ([ # contra trap
44
- {"x" : 0.5 , "y" : 0.0 },
45
- # {"x": 0.3, "y": 0.0},
46
- # {"x": 0.5, "y": 0.0},
47
- {"x" : 1.0 , "y" : - 1.0 },
48
- ])
49
- test_robot_genome .sensors .list [2 ].mapping .from_flattened ([ # ipsi trap
50
- {"x" : 0.3 , "y" : 1.0 },
51
- # {"x": 0.3, "y": 1.0},
52
- # {"x": 0.7, "y": 0.0},
53
- {"x" : 1.0 , "y" : - 0.5 },
54
- ])
55
- test_robot_genome .sensors .list [4 ].mapping .from_flattened (
56
- test_robot_genome .sensors .list [3 ].mapping .flatten ()
57
- )
58
- test_robot_genome .sensors .list [1 ].mapping .from_flattened (
59
- test_robot_genome .sensors .list [0 ].mapping .flatten ()
60
- )
61
- # test_robot_genome.sensors.list[8].mapping.from_flattened(
62
- # test_robot_genome.sensors.list[5].mapping.flatten()
63
- # )
64
- # test_robot_genome.sensors.list[11].mapping.from_flattened(
65
- # test_robot_genome.sensors.list[2].mapping.flatten()
66
- # )
67
- """
68
- test_robot_genome.sensors.list[0].mapping.from_flattened([ # contra food/water
69
- {"x": 0.000, "y": 0.694},
70
- {"x": 0.026, "y": 0.588},
71
- {"x": 0.164, "y": 0.127},
72
- {"x": 1.000, "y": 0.536},
73
- ])
74
- test_robot_genome.sensors.list[3].mapping.from_flattened([ # ipsi food/water
75
- {"x": 0.000, "y": -0.980},
76
- {"x": 0.023, "y": -0.001},
77
- {"x": 0.734, "y": 0.851},
78
- {"x": 1.000, "y": 0.659},
79
- ])
80
- test_robot_genome.sensors.list[5].mapping.from_flattened([ # contra trap
81
- {"x": 0.000, "y": 0.853},
82
- {"x": 0.537, "y": 0.707},
83
- {"x": 0.909, "y": 0.432},
84
- {"x": 1.000, "y": -0.982},
85
- ])
86
- test_robot_genome.sensors.list[2].mapping.from_flattened([ # ipsi trap
87
- {"x": 0.000, "y": 0.390},
88
- {"x": 0.018, "y": 0.732},
89
- {"x": 0.488, "y": 0.017},
90
- {"x": 1.000, "y": 0.148},
91
- ])
92
- for i in [4, 6, 7]:
93
- test_robot_genome.sensors.list[i].mapping.from_flattened(
94
- test_robot_genome.sensors.list[3].mapping.flatten()
95
- )
96
- for i in [1, 9, 10]:
97
- test_robot_genome.sensors.list[i].mapping.from_flattened(
98
- test_robot_genome.sensors.list[0].mapping.flatten()
99
- )
100
- test_robot_genome.sensors.list[8].mapping.from_flattened(
101
- test_robot_genome.sensors.list[5].mapping.flatten()
102
- )
103
- test_robot_genome.sensors.list[11].mapping.from_flattened(
104
- test_robot_genome.sensors.list[2].mapping.flatten()
105
- )
106
- """
107
- '''
108
- test_robot_genome.from_flattened({
109
- "sensors": [
110
- {
111
- "threshold": 0.0,
112
- "angle": math.pi / 4,
113
- "smell_signature": [1, 0, 0, 0, 0],
114
- "mapping": [
115
- {"x": 0.0, "y": 0.1},
116
- {"x": 1.0, "y": 1.0},
117
- ],
118
- "motor_side": "LEFT"
119
- },
120
- {
121
- "threshold": 0.0,
122
- "angle": math.pi * 7 / 4,
123
- "smell_signature": [1, 0, 0, 0, 0],
124
- "mapping": [
125
- {"x": 0.0, "y": -0.1},
126
- {"x": 1.0, "y": 1.0},
127
- ],
128
- "motor_side": "RIGHT"
129
- },
130
- {
131
- "threshold": 0.0,
132
- "angle": math.pi / 4,
133
- "smell_signature": [0, 1, 0, 0, 0],
134
- "mapping": [
135
- {"x": 0.0, "y": 0.1},
136
- {"x": 1.0, "y": 1.0},
137
- ],
138
- "motor_side": "LEFT"
139
- },
140
- {
141
- "threshold": 0.0,
142
- "angle": math.pi * 7 / 4,
143
- "smell_signature": [0, 1, 0, 0, 0],
144
- "mapping": [
145
- {"x": 0.0, "y": -0.1},
146
- {"x": 1.0, "y": 1.0},
147
- ],
148
- "motor_side": "RIGHT"
149
- },
150
- {
151
- "threshold": 0.0,
152
- "angle": math.pi / 4,
153
- "smell_signature": [0, 0, 1, 0, 0],
154
- "mapping": [
155
- {"x": 0.0, "y": 0.1},
156
- {"x": 1.0, "y": -1.0},
157
- ],
158
- "motor_side": "LEFT"
159
- },
160
- {
161
- "threshold": 0.0,
162
- "angle": math.pi * 7 / 4,
163
- "smell_signature": [0, 0, 1, 0, 0],
164
- "mapping": [
165
- {"x": 0.0, "y": -0.1},
166
- {"x": 1.0, "y": -1.0},
167
- ],
168
- "motor_side": "RIGHT"
169
- },
170
- ]
171
- })
172
- '''
173
29
# Setup the population of robot and environment genomes
174
30
for _ in range (simulation_state .pop_size ):
175
31
robot_genome = RobotGenome ()
176
32
robot_genome .randomise ()
177
33
simulation_state .robot_genomes .append (robot_genome )
178
34
simulation_state .environment_genomes .append (environment_genome )
179
35
180
- simulation_state .robot_genomes [0 ] = test_robot_genome
181
-
182
36
if LOAD_INITIAL_POPULATION_FROM is not None :
183
37
best_robot_index = None
184
38
with open (f"Data/tournament_data{ LOAD_INITIAL_POPULATION_FROM } .json" ) as file :
0 commit comments