From 0d0b1c6d432067ae78fb16618aabd366fbfea41c Mon Sep 17 00:00:00 2001 From: MonoYuku Date: Wed, 16 Jun 2021 11:53:54 +0200 Subject: [PATCH] added: trash refresh and better search --- TSP.py | 9 +++++++-- __pycache__/TSP.cpython-39.pyc | Bin 2574 -> 2639 bytes houses.txt | 12 ++++++------ main.py | 10 +++++++++- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/TSP.py b/TSP.py index 10b9468..e48c3b0 100644 --- a/TSP.py +++ b/TSP.py @@ -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) diff --git a/__pycache__/TSP.cpython-39.pyc b/__pycache__/TSP.cpython-39.pyc index 152f2626114b65a1a76d579688a6424c9bd0eec2..8b28ddc4b74c54f6e48f28c64943477feb14bcb0 100644 GIT binary patch delta 302 zcmeAZIWNMO$ji&c00b-tPbS>u-N?6qg>lm4^(>isDQq>YSv>K)DeN_@@q9H*3;1hT z7c$ne)vy)yl?Ze&)-ctuH8a<;*RTgOXmU)pV13H*QVwWPh^F9VdA7;*5v(kH@~$ji&c00a~4PbM7T*~qtmg|TJwdX`Lu8m0w2HLMF6YuRepiW*9II~Z%2 zYS@~YYuRhqgBdj0CcCjdWzyuEY|J*yZ|&6nBdGBT=8F65ME44mA{Y0hXo`6#Ckw>nU3kuivn1j-3d*5{IE GlmP(ykUVPu diff --git a/houses.txt b/houses.txt index 1a26060..1f4bcbf 100644 --- a/houses.txt +++ b/houses.txt @@ -5,12 +5,12 @@ 10000000000001000010000100000001 11111111110001000010000000001111 11110000000111000100001111111111 -10000000000000000001100000000001 -10001110000000000010000000000001 -11111111111111000010111111111011 -10000000000000000010000001110001 -10000000000001000000111100000011 +10000000000000010001100000000001 +10001110000011100010000000000001 +11111011110111001010111111111011 +10001000001000011010000001110001 +10000010000001001000111100000011 10011111111001000010011001111011 10000110001000000001110000000011 -10010000100000111100000001100001 +10010000100010111100000001100001 11111111111111111111111111111111 \ No newline at end of file diff --git a/main.py b/main.py index 16ab1fe..8420c6d 100644 --- a/main.py +++ b/main.py @@ -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)