diff options
author | Philip Paquette <pcpaquette@gmail.com> | 2019-03-05 16:01:53 -0500 |
---|---|---|
committer | Philip Paquette <pcpaquette@gmail.com> | 2019-04-18 11:25:05 -0400 |
commit | ab82a735cd57dd20236135447b774643faf7e1c1 (patch) | |
tree | 4ce08d7ff3f8f22861dbcfc701b424cfbf2bc649 /diplomacy/utils | |
parent | 88a5715f8c53852a6e231315d4aca361df2e6493 (diff) |
Refactored get_all_possible_orders for 2.5x speed improvement
- Returning all locations at once
- Removed 'loc' argument from method
- Map has pre-computed attribute dest_with_coats
Diffstat (limited to 'diplomacy/utils')
-rw-r--r-- | diplomacy/utils/export.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/diplomacy/utils/export.py b/diplomacy/utils/export.py index 459313d..3a03de1 100644 --- a/diplomacy/utils/export.py +++ b/diplomacy/utils/export.py @@ -118,13 +118,14 @@ def is_valid_saved_game(saved_game): # Validating orders orders = game.get_orders() + possible_orders = game.get_all_possible_orders() for power_name in orders: if sorted(orders[power_name]) != sorted(current_phase['orders'][power_name]): return False if 'NO_CHECK' not in game.rules: for order in orders[power_name]: loc = order.split()[1] - if order not in game.get_all_possible_orders(loc): + if order not in possible_orders[loc]: return False # Validating resulting state |