added: trash refresh and better search

This commit is contained in:
MonoYuku 2021-06-16 11:53:54 +02:00
parent 3bfa94344b
commit 0d0b1c6d43
4 changed files with 22 additions and 9 deletions

9
TSP.py
View File

@ -68,9 +68,14 @@ def tsp(x, y):
routing.SetArcCostEvaluatorOfAllVehicles(transit_callback_index)
#search_parameters = pywrapcp.DefaultRoutingSearchParameters()
# search_parameters.first_solution_strategy = (
# routing_enums_pb2.FirstSolutionStrategy.PATH_CHEAPEST_ARC)
search_parameters = pywrapcp.DefaultRoutingSearchParameters()
search_parameters.first_solution_strategy = (
routing_enums_pb2.FirstSolutionStrategy.PATH_CHEAPEST_ARC)
search_parameters.local_search_metaheuristic = (
routing_enums_pb2.LocalSearchMetaheuristic.GUIDED_LOCAL_SEARCH)
search_parameters.time_limit.seconds = 30
search_parameters.log_search = True
solution = routing.SolveWithParameters(search_parameters)

Binary file not shown.

View File

@ -5,12 +5,12 @@
10000000000001000010000100000001
11111111110001000010000000001111
11110000000111000100001111111111
10000000000000000001100000000001
10001110000000000010000000000001
11111111111111000010111111111011
10000000000000000010000001110001
10000000000001000000111100000011
10000000000000010001100000000001
10001110000011100010000000000001
11111011110111001010111111111011
10001000001000011010000001110001
10000010000001001000111100000011
10011111111001000010011001111011
10000110001000000001110000000011
10010000100000111100000001100001
10010000100010111100000001100001
11111111111111111111111111111111

10
main.py
View File

@ -16,7 +16,7 @@ def game_keys(truck, multi_trash, houses, auto=False):
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if auto:
sleep(.2)
sleep(.04)
if (event.key == pygame.K_w or event.key == pygame.K_UP):
if truck.test_crash(houses):
break
@ -112,6 +112,14 @@ def game_loop():
game_keys(truck, multi_trash, houses, True)
update_images(gameDisplay, truck, multi_trash, houses)
truck.direction = [1, 0]
truck.dir_control = 0
truck.image = pygame.image.load('./img/truck.png')
if not multi_trash:
for _ in range(7):
trash = Trash(game_w, game_h, grid_size)
trash.new_pos(truck.pos, houses, multi_trash)
multi_trash.append(trash)
else:
pygame.event.post(event)
game_keys(truck, multi_trash, houses)