-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvaccum-cleaner.py
More file actions
36 lines (31 loc) · 920 Bytes
/
Copy pathvaccum-cleaner.py
File metadata and controls
36 lines (31 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
import numpy as np
rows = 5
cols = 3
cleaned_rooms = 0
total_rooms = rows * cols
matrix = np.random.randint(0, 2, (rows, cols))
print(matrix)
states = {
0: 'clean',
1: 'dirty'
}
actions = {
0: 'nothing',
1: 'cleaning'
}
for x in range(matrix.shape[0]):
for y in range(matrix.shape[1]):
state = matrix[x, y]
if (x == rows-1) and (y == cols-1):
print(f'Agent in room ({x}, {y}); state={states[state]}; action={actions[state]}')
else:
print(f'Agent in room ({x}, {y}); state={states[state]}; action={actions[state]} and move ', end='')
if y == cols-1:
print('down.')
else:
print('right.')
if state == 1:
cleaned_rooms += 1
matrix[x, y] = 0
print(f'All the rooms checked and {cleaned_rooms} rooms were cleaned!')
print(matrix)