From 59bcb0ccc54740a90fd70d934e39c08d4c7c8274 Mon Sep 17 00:00:00 2001 From: Thefeli73 Date: Sat, 3 Oct 2020 18:49:33 +0200 Subject: [PATCH 1/3] fix except traceback, var name, --- main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 964df87..95b530e 100644 --- a/main.py +++ b/main.py @@ -3,13 +3,14 @@ import time import sys from sys import exit from game_layer import GameLayer +import traceback api_key = "74e3998d-ed3d-4d46-9ea8-6aab2efd8ae3" # The different map names can be found on considition.com/rules map_name = "training1" # TODO: You map choice here. If left empty, the map "training1" will be selected. game_layer = GameLayer(api_key) -useTestStrategy = False +usePrebuiltStrategy = False def main(): @@ -23,8 +24,7 @@ def main(): try: take_turn() except: - e = sys.exc_info()[0] - print(e) + print(traceback.format_exc()) game_layer.end_game() exit() time_diff = time.time() - start_time @@ -40,7 +40,7 @@ def take_turn(): # TODO Implement your artificial intelligence here. # TODO Take one action per turn until the game ends. # TODO The following is a short example of how to use the StarterKit - if not useTestStrategy: + if not usePrebuiltStrategy: state = game_layer.game_state print("testrunda") # messages and errors for console log @@ -53,7 +53,7 @@ def take_turn(): # pre-made test strategy # which came with # starter kit - if useTestStrategy: + if usePrebuiltStrategy: state = game_layer.game_state if len(state.residences) < 1: for i in range(len(state.map)): From 16988ababbe87b31ae76f486354a9fdbfcd1f66a Mon Sep 17 00:00:00 2001 From: Thefeli73 Date: Sat, 3 Oct 2020 19:30:14 +0200 Subject: [PATCH 2/3] flutta game state var --- main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/main.py b/main.py index 95b530e..91787a5 100644 --- a/main.py +++ b/main.py @@ -10,6 +10,7 @@ api_key = "74e3998d-ed3d-4d46-9ea8-6aab2efd8ae3" map_name = "training1" # TODO: You map choice here. If left empty, the map "training1" will be selected. game_layer = GameLayer(api_key) +state = game_layer.game_state usePrebuiltStrategy = False From 416a2d3aedbd0158a7c7e9485814fe6c2ddbcb20 Mon Sep 17 00:00:00 2001 From: Thefeli73 Date: Sat, 3 Oct 2020 19:31:09 +0200 Subject: [PATCH 3/3] take turn och global chartMap def --- main.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 91787a5..925feda 100644 --- a/main.py +++ b/main.py @@ -38,12 +38,12 @@ def main(): def take_turn(): - # TODO Implement your artificial intelligence here. - # TODO Take one action per turn until the game ends. - # TODO The following is a short example of how to use the StarterKit if not usePrebuiltStrategy: - state = game_layer.game_state - print("testrunda") + # TODO Implement your artificial intelligence here. + # TODO Take one action per turn until the game ends. + # TODO The following is a short example of how to use the StarterKit + + # messages and errors for console log for message in game_layer.game_state.messages: print(message) @@ -91,6 +91,12 @@ def take_turn(): for error in game_layer.game_state.errors: print("Error: " + error) +def chartMap(): + availableTiles = [] + for x in range(len(state.map) - 1): + for y in range(len(state.map) - 1): + if state.map[x][y] == 0: + availableTiles.append((x, y)) if __name__ == "__main__": main()