Skip to content

Commit ee6987e

Browse files
author
Norbert Kozlowski
committed
MazeF1
1 parent 3572136 commit ee6987e

File tree

6 files changed

+20
-9
lines changed

6 files changed

+20
-9
lines changed

.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ indent_style = space
1515
indent_size = 4
1616
max_line_length = 79
1717

18+
[*.maze]
19+
insert_final_newline = false
20+
1821
# Matches the exact files either package.json or .travis.yml
1922
[*.yml]
2023
indent_style = space

alcs/environment/maze/Maze.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ def insert_animat(self, pos_x: int = None, pos_y: int = None) -> None:
8989
possible_coords = []
9090
for x in range(0, self.max_x):
9191
for y in range(0, self.max_y):
92-
if self.matrix[x][y] == self.mapping['path']['value']:
93-
possible_coords.append((x, y))
92+
if self.matrix[y][x] == self.mapping['path']['value']:
93+
possible_coords.append((y, x))
9494

9595
starting_position = random.choice(possible_coords)
9696
self.animat_pos_x = starting_position[1]

alcs/environment/maze/MazeMapping.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ def find_value(self, symbol: str) -> int:
2626
if v['symbol'] == symbol:
2727
return v['value']
2828

29-
raise ValueError('No mapping for symbol ' + symbol)
29+
raise ValueError('No mapping for symbol [{}]'.format(symbol))

examples/helpers/visualization.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,30 @@ def plot_performance(**kwargs):
1414

1515
ax1 = fig.add_subplot(221)
1616
ax1.plot(time, total_classifiers, 'b')
17-
ax1.plot(time, _filter(total_classifiers, f_reward), 'ro', linewidth=2.0)
17+
ax1.plot(time, _filter(total_classifiers, f_reward), 'r.')
1818
ax1.set_title('Total Classifiers')
1919
ax1.set_xlabel('Time')
2020
ax1.set_ylabel('Macro-classifiers')
2121
ax1.grid(True)
2222

2323
ax2 = fig.add_subplot(222)
2424
ax2.plot(time, avg_quality, 'g')
25-
ax2.plot(time, _filter(avg_quality, f_reward), 'ro', linewidth=2.0)
25+
ax2.plot(time, _filter(avg_quality, f_reward), 'r.')
2626
ax2.set_title('Quality')
2727
ax2.set_xlabel('Time')
2828
ax2.set_ylabel('Quality per classifier')
2929
ax2.grid(True)
3030

3131
ax3 = fig.add_subplot(223)
3232
ax3.plot(time, avg_fitness, 'y')
33-
ax3.plot(time, _filter(avg_fitness, f_reward), 'ro', linewidth=2.0)
33+
ax3.plot(time, _filter(avg_fitness, f_reward), 'r.')
3434
ax3.set_title('Fitness')
3535
ax3.set_xlabel('Time')
3636
ax3.set_ylabel('Fitness per classifier')
3737
ax3.grid(True)
3838

3939
plt.tight_layout()
40-
plt.savefig('learning_progress.png')
40+
plt.savefig('learning_progress.png', dpi=200)
4141

4242

4343
def _filter(metrics: list, mask: list) -> list:

examples/run_acs2.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
if __name__ == '__main__':
2020

2121
# Load environment
22-
env = maze.Maze('mazes/m1.maze')
22+
env = maze.Maze('mazes/MazeF1.maze')
2323

2424
# Initialize agent
2525
acs2 = ACS2(env)
2626

2727
# Evaluate simulation
28-
metrics = acs2.evaluate(500)
28+
metrics = acs2.evaluate(50)
2929

3030
# Plot results
3131
plot_performance(**metrics)

mazes/MazeF1.maze

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
4
2+
6
3+
####
4+
#.$#
5+
#.##
6+
#..#
7+
#.##
8+
####

0 commit comments

Comments
 (0)