fixed look at plants

This commit is contained in:
Marcin Jabłoński 2019-06-05 17:14:15 +02:00
parent d13fa47643
commit 4cd8951b2b

12
env.py
View File

@ -92,6 +92,13 @@ def try_move(field, tractor):
return True
return False
def test_cords(cord, len1, len2):
if cord[0] > -1 and cord[0] < len1 \
and cord[1] > -1 and cord[1] < len2:
return True
return False
def look_at_plats(field, location):
wsp = [
(location[0] + 1, location[1]),
@ -99,9 +106,12 @@ def look_at_plats(field, location):
(location[0], location[1] - 1),
(location[0], location[1] + 1)
]
len1 = len(field)
len2 = len(field[0])
wsp = [l if test_cords(l, len1, len2) else None for l in wsp]
plants = []
for i in wsp:
if field[i[0]][i[1]]:
if i and field[i[0]][i[1]]:
plants.append(i)
return plants