added: trash refresh and better search
This commit is contained in:
parent
3bfa94344b
commit
0d0b1c6d43
9
TSP.py
9
TSP.py
@ -68,9 +68,14 @@ def tsp(x, y):
|
|||||||
|
|
||||||
routing.SetArcCostEvaluatorOfAllVehicles(transit_callback_index)
|
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 = pywrapcp.DefaultRoutingSearchParameters()
|
||||||
search_parameters.first_solution_strategy = (
|
search_parameters.local_search_metaheuristic = (
|
||||||
routing_enums_pb2.FirstSolutionStrategy.PATH_CHEAPEST_ARC)
|
routing_enums_pb2.LocalSearchMetaheuristic.GUIDED_LOCAL_SEARCH)
|
||||||
|
search_parameters.time_limit.seconds = 30
|
||||||
|
search_parameters.log_search = True
|
||||||
|
|
||||||
solution = routing.SolveWithParameters(search_parameters)
|
solution = routing.SolveWithParameters(search_parameters)
|
||||||
|
|
||||||
|
Binary file not shown.
12
houses.txt
12
houses.txt
@ -5,12 +5,12 @@
|
|||||||
10000000000001000010000100000001
|
10000000000001000010000100000001
|
||||||
11111111110001000010000000001111
|
11111111110001000010000000001111
|
||||||
11110000000111000100001111111111
|
11110000000111000100001111111111
|
||||||
10000000000000000001100000000001
|
10000000000000010001100000000001
|
||||||
10001110000000000010000000000001
|
10001110000011100010000000000001
|
||||||
11111111111111000010111111111011
|
11111011110111001010111111111011
|
||||||
10000000000000000010000001110001
|
10001000001000011010000001110001
|
||||||
10000000000001000000111100000011
|
10000010000001001000111100000011
|
||||||
10011111111001000010011001111011
|
10011111111001000010011001111011
|
||||||
10000110001000000001110000000011
|
10000110001000000001110000000011
|
||||||
10010000100000111100000001100001
|
10010000100010111100000001100001
|
||||||
11111111111111111111111111111111
|
11111111111111111111111111111111
|
10
main.py
10
main.py
@ -16,7 +16,7 @@ def game_keys(truck, multi_trash, houses, auto=False):
|
|||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.KEYDOWN:
|
if event.type == pygame.KEYDOWN:
|
||||||
if auto:
|
if auto:
|
||||||
sleep(.2)
|
sleep(.04)
|
||||||
if (event.key == pygame.K_w or event.key == pygame.K_UP):
|
if (event.key == pygame.K_w or event.key == pygame.K_UP):
|
||||||
if truck.test_crash(houses):
|
if truck.test_crash(houses):
|
||||||
break
|
break
|
||||||
@ -112,6 +112,14 @@ def game_loop():
|
|||||||
|
|
||||||
game_keys(truck, multi_trash, houses, True)
|
game_keys(truck, multi_trash, houses, True)
|
||||||
update_images(gameDisplay, truck, multi_trash, houses)
|
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:
|
else:
|
||||||
pygame.event.post(event)
|
pygame.event.post(event)
|
||||||
game_keys(truck, multi_trash, houses)
|
game_keys(truck, multi_trash, houses)
|
||||||
|
Loading…
Reference in New Issue
Block a user