zmiana karmienia
This commit is contained in:
parent
1e5ba0765c
commit
539a08af0d
14
agent.py
14
agent.py
@ -31,9 +31,9 @@ class Agent:
|
||||
elif event.key == pygame.K_RIGHT:
|
||||
self.move('Turn Right', max_x, max_y, obstacles, animals)
|
||||
|
||||
feed_animal(self, animals)
|
||||
# feed_animal(self, animals)
|
||||
|
||||
def move(self, action, max_x, max_y, obstacles, animals):
|
||||
def move(self, action, max_x, max_y, obstacles, animals, goal):
|
||||
if action == 'Go Forward':
|
||||
new_x, new_y = self.x, self.y
|
||||
if self.direction == 'N':
|
||||
@ -56,11 +56,13 @@ class Agent:
|
||||
self.direction = {'N': 'E', 'E': 'S', 'S': 'W', 'W': 'N'}[self.direction]
|
||||
|
||||
self.istate = (self.x, self.y, self.direction)
|
||||
feed_animal(self, animals)
|
||||
feed_animal(self, animals, goal)
|
||||
|
||||
def feed_animal(self, animals):
|
||||
for animal in animals:
|
||||
if self.x == animal.x and self.y == animal.y:
|
||||
def feed_animal(self, animals, goal):
|
||||
goal_x, goal_y = goal
|
||||
if self.x == goal_x and self.y == goal_y:
|
||||
for animal in animals:
|
||||
if animal.x == goal_x and animal.y == goal_y:
|
||||
if animal.feed() == 'True':
|
||||
animal._feed = 0
|
||||
print(animal.name, "fed with", animal.food)
|
Loading…
Reference in New Issue
Block a user