bug fixes
This commit is contained in:
parent
55baf24513
commit
893a0c8c5a
@ -43,8 +43,6 @@ class GarbageTruck:
|
|||||||
self.rect.y -= FIELDWIDTH
|
self.rect.y -= FIELDWIDTH
|
||||||
|
|
||||||
def next_destination(self):
|
def next_destination(self):
|
||||||
if self.fuel <= 0 or not self.request_list:
|
|
||||||
return self.dump_x, self.dump_y
|
|
||||||
|
|
||||||
for i in range(len(self.request_list)):
|
for i in range(len(self.request_list)):
|
||||||
request = self.request_list[i]
|
request = self.request_list[i]
|
||||||
@ -54,12 +52,12 @@ class GarbageTruck:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
#nie straczy paliwa na dojechanie i powrót na wysypisko
|
#nie straczy paliwa na dojechanie i powrót na wysypisko
|
||||||
if heuristicfn(request.x_pos, request.y_pos, self.dump_x, self.dump_y) / 50 * 200 > self.fuel:
|
if heuristicfn(request.x_pos, request.y_pos, self.dump_x, self.dump_y) // 50 * 200 > self.fuel:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
distance = heuristicfn(self.rect.x, self.rect.y, request.x_pos, request.y_pos) / 50
|
distance = heuristicfn(self.rect.x, self.rect.y, request.x_pos, request.y_pos) // 50
|
||||||
|
|
||||||
r = [
|
r = [
|
||||||
self.fuel,
|
self.fuel,
|
||||||
@ -82,7 +80,7 @@ class GarbageTruck:
|
|||||||
|
|
||||||
def collect(self):
|
def collect(self):
|
||||||
if self.rect.x == self.dump_x and self.rect.y == self.dump_y:
|
if self.rect.x == self.dump_x and self.rect.y == self.dump_y:
|
||||||
self.fuel = MAX_WEIGHT
|
self.fuel = MAX_FUEL
|
||||||
self.free_space = MAX_SPACE
|
self.free_space = MAX_SPACE
|
||||||
self.weight_capacity = MAX_WEIGHT
|
self.weight_capacity = MAX_WEIGHT
|
||||||
print(f'agent at ({self.rect.x}, {self.rect.y}); fuel: {self.fuel}; free space: {self.free_space}; weight capacity: {self.weight_capacity}')
|
print(f'agent at ({self.rect.x}, {self.rect.y}); fuel: {self.fuel}; free space: {self.free_space}; weight capacity: {self.weight_capacity}')
|
||||||
|
3
main.py
3
main.py
@ -49,7 +49,7 @@ def main():
|
|||||||
if x == agent.rect.x and y == agent.rect.y:
|
if x == agent.rect.x and y == agent.rect.y:
|
||||||
print('out of jobs')
|
print('out of jobs')
|
||||||
break
|
break
|
||||||
steps = astar(State(None, None, agent.rect.x, agent.rect.y, agent.orientation, priority_array[0][0], heuristicfn(agent.rect.x, agent.rect.y, x, y)), x, y, priority_array)
|
steps = astar(State(None, None, agent.rect.x, agent.rect.y, agent.orientation, priority_array[agent.rect.x//50][agent.rect.y//50], heuristicfn(agent.rect.x, agent.rect.y, x, y)), x, y, priority_array)
|
||||||
for interm in steps:
|
for interm in steps:
|
||||||
if interm.action == 'LEFT':
|
if interm.action == 'LEFT':
|
||||||
agent.turn_left()
|
agent.turn_left()
|
||||||
@ -68,6 +68,7 @@ def main():
|
|||||||
time.sleep(0.3)
|
time.sleep(0.3)
|
||||||
agent.collect()
|
agent.collect()
|
||||||
fields[agent.rect.x//50][agent.rect.y//50] = GRASS
|
fields[agent.rect.x//50][agent.rect.y//50] = GRASS
|
||||||
|
priority_array[agent.rect.x//50][agent.rect.y//50] = 1
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user