constants.py
1 """ 2 Constants representing the game variation being played. 3 Most constants are global and come from game engine and are immutable and are strictly informational. 4 Some constants are only used by the local game client and so are mutable. 5 """ 6 7 ################################################ 8 # Local and mutable constants. 9 10 """Maximum number of steps to consider in pathfinding.""" 11 MAX_BFS_STEPS = 1024 # = can search a 32x32 area completely 12 13 ################################################ 14 # Global and immutable constants. 15 16 """The maximum amount of halite a ship can carry.""" 17 MAX_HALITE = 1000 18 """The cost to build a single ship.""" 19 SHIP_COST = 500 20 """The cost to build a dropoff.""" 21 DROPOFF_COST = 2000 22 """The maximum number of turns a game can last.""" 23 MAX_TURNS = 500 24 """1/EXTRACT_RATIO halite (rounded) is collected from a square per turn.""" 25 EXTRACT_RATIO = 4 26 """1/MOVE_COST_RATIO halite (rounded) is needed to move off a cell.""" 27 MOVE_COST_RATIO = 10 28 29 def load_constants(constants): 30 """ 31 Load constants from JSON given by the game engine. 32 """ 33 global SHIP_COST, DROPOFF_COST, MAX_HALITE, MAX_TURNS 34 global EXTRACT_RATIO, MOVE_COST_RATIO 35 SHIP_COST = constants.get('NEW_ENTITY_ENERGY_COST', SHIP_COST) 36 DROPOFF_COST = constants.get('DROPOFF_COST', DROPOFF_COST) 37 MAX_HALITE = constants.get('MAX_ENERGY', MAX_HALITE) 38 MAX_TURNS = constants.get('MAX_TURNS', MAX_TURNS) 39 EXTRACT_RATIO = constants.get('EXTRACT_RATIO', EXTRACT_RATIO) 40 MOVE_COST_RATIO = constants.get('MOVE_COST_RATIO', MOVE_COST_RATIO)