|
@@ -1,6 +1,7 @@
|
1
|
1
|
# coding: utf-8
|
2
|
2
|
import argparse
|
3
|
3
|
import logging
|
|
4
|
+import sys
|
4
|
5
|
from random import seed
|
5
|
6
|
|
6
|
7
|
from synergine2.log import get_default_logger
|
|
@@ -20,9 +21,13 @@ def main(
|
20
|
21
|
map_dir_path: str,
|
21
|
22
|
seed_value: int=None,
|
22
|
23
|
state_file_path: str=None,
|
|
24
|
+ troops_file_path: str=None,
|
23
|
25
|
state_save_dir: str='.',
|
24
|
26
|
placement_mode: bool = False,
|
25
|
27
|
):
|
|
28
|
+ assert not (state_file_path and troops_file_path),\
|
|
29
|
+ 'Do not provide troops file when state file given'
|
|
30
|
+
|
26
|
31
|
if seed_value is not None:
|
27
|
32
|
seed(seed_value)
|
28
|
33
|
|
|
@@ -49,6 +54,12 @@ def main(
|
49
|
54
|
state = state_loader.get_state(state_file_path)
|
50
|
55
|
subjects.extend(state.subjects)
|
51
|
56
|
|
|
57
|
+ elif troops_file_path:
|
|
58
|
+ troop_loader_builder = TroopConstructorBuilder(config, simulation)
|
|
59
|
+ troop_loader = troop_loader_builder.get_troop_loader()
|
|
60
|
+ troops = troop_loader.get_troops(troops_file_path)
|
|
61
|
+ subjects.extend(troops.subjects)
|
|
62
|
+
|
52
|
63
|
simulation.subjects = subjects
|
53
|
64
|
|
54
|
65
|
core = Core(
|
|
@@ -76,6 +87,7 @@ if __name__ == '__main__':
|
76
|
87
|
)
|
77
|
88
|
parser.add_argument('map_dir_path', help='map directory path')
|
78
|
89
|
parser.add_argument('--seed', dest='seed', default=None)
|
|
90
|
+ parser.add_argument('--troops', dest='troops', default=None)
|
79
|
91
|
parser.add_argument('--state', dest='state', default=None)
|
80
|
92
|
parser.add_argument(
|
81
|
93
|
'--state-save-dir',
|
|
@@ -90,10 +102,22 @@ if __name__ == '__main__':
|
90
|
102
|
|
91
|
103
|
args = parser.parse_args()
|
92
|
104
|
|
|
105
|
+ if args.troops and args.state:
|
|
106
|
+ print(
|
|
107
|
+ 'Cannot load state "{}" because you provide troops file "{}". '
|
|
108
|
+ 'You must provide only one of them.'.format(
|
|
109
|
+ args.state,
|
|
110
|
+ args.troops,
|
|
111
|
+ ),
|
|
112
|
+ file=sys.stderr,
|
|
113
|
+ )
|
|
114
|
+ exit(1)
|
|
115
|
+
|
93
|
116
|
main(
|
94
|
117
|
args.map_dir_path,
|
95
|
118
|
seed_value=args.seed,
|
96
|
119
|
state_file_path=args.state,
|
|
120
|
+ troops_file_path=args.troops,
|
97
|
121
|
state_save_dir=args.state_save_dir,
|
98
|
122
|
placement_mode=args.placement,
|
99
|
123
|
)
|