multiplier new game setting (unit amounts option); tweaked commisions

This commit is contained in:
Vasyl Horbachenko
2018-06-22 02:11:47 +03:00
parent 1a491bb814
commit 25e2681665
13 changed files with 119 additions and 215 deletions

View File

@@ -9,10 +9,9 @@ from dcs.planes import *
from dcs.vehicles import *
from dcs.task import *
PLANES_IN_GROUP = 2
PLANES_SCRAMBLE_MIN = 4
PLANES_SCRAMBLE_MAX = 8
STRENGTH_AA_ASSEMBLE_MIN = 0.2
PLANES_SCRAMBLE_MIN_BASE = 4
PLANES_SCRAMBLE_MAX_BASE = 8
PLANES_SCRAMBLE_FACTOR = 0.5
@@ -84,12 +83,6 @@ class Base:
def _find_best_armor(self, for_type: Task, count: int) -> typing.Dict[Armor, int]:
return self._find_best_unit(self.armor, for_type, count)
def _group_sizes(self, total_planes: int) -> typing.List[int]:
total_scrambled = 0
for _ in range(math.ceil(total_planes / PLANES_IN_GROUP)):
total_scrambled += PLANES_IN_GROUP
yield total_scrambled < total_planes and PLANES_IN_GROUP or total_planes - total_scrambled
def append_commision_points(self, for_type, points: float) -> int:
self.commision_points[for_type] = self.commision_points.get(for_type, 0) + points
points = self.commision_points[for_type]
@@ -147,24 +140,27 @@ class Base:
elif self.strength < 0:
self.strength = 0.001
def scramble_count(self) -> int:
def scramble_count(self, multiplier: float) -> int:
count = int(self.total_planes * PLANES_SCRAMBLE_FACTOR * self.strength)
return min(min(max(count, PLANES_SCRAMBLE_MIN), PLANES_SCRAMBLE_MAX), self.total_planes)
return min(min(max(count, PLANES_SCRAMBLE_MIN_BASE), int(PLANES_SCRAMBLE_MAX_BASE * multiplier)), self.total_planes)
def assemble_count(self):
return int(self.total_armor * self.strength)
def assemble_aa_count(self) -> int:
return int(self.total_aa * (self.strength > 0.2 and self.strength or 0))
if self.strength > STRENGTH_AA_ASSEMBLE_MIN:
return self.total_aa
else:
return 0
def scramble_sweep(self) -> typing.Dict[PlaneType, int]:
return self._find_best_planes(CAP, self.scramble_count())
def scramble_sweep(self, multiplier: float) -> typing.Dict[PlaneType, int]:
return self._find_best_planes(CAP, self.scramble_count(multiplier))
def scramble_cas(self) -> typing.Dict[PlaneType, int]:
return self._find_best_planes(CAS, self.scramble_count())
def scramble_cas(self, multiplier: float) -> typing.Dict[PlaneType, int]:
return self._find_best_planes(CAS, self.scramble_count(multiplier))
def scramble_interceptors(self) -> typing.Dict[PlaneType, int]:
return self._find_best_planes(CAP, self.scramble_count())
def scramble_interceptors(self, multiplier: float) -> typing.Dict[PlaneType, int]:
return self._find_best_planes(CAP, self.scramble_count(multiplier))
def assemble_cap(self) -> typing.Dict[Armor, int]:
return self._find_best_armor(PinpointStrike, self.assemble_count())

View File

@@ -5,16 +5,17 @@ from theater.conflicttheater import *
UNIT_VARIETY = 3
UNIT_AMOUNT_FACTOR = 16
UNIT_COUNT_IMPORTANCE_LOG = 1.3
COUNT_BY_TASK = {
PinpointStrike: 24,
CAP: 16,
CAS: 8,
AirDefence: 0.5,
PinpointStrike: 12,
CAP: 8,
CAS: 4,
AirDefence: 2,
}
def generate_initial(theater: ConflictTheater, enemy: str, sams: bool):
def generate_initial(theater: ConflictTheater, enemy: str, sams: bool, multiplier: float):
for cp in theater.enemy_points():
if cp.captured:
continue
@@ -30,7 +31,8 @@ def generate_initial(theater: ConflictTheater, enemy: str, sams: bool):
if not sams:
unittypes = [x for x in unittypes if x not in db.SAM_BAN]
count = max(COUNT_BY_TASK[task] * importance_factor, 1)
count_log = math.log(cp.importance + 0.01, UNIT_COUNT_IMPORTANCE_LOG)
count = max(COUNT_BY_TASK[task] * multiplier * (1+count_log), 1)
count_per_type = max(int(float(count) / len(unittypes)), 1)
for unit_type in unittypes:
print("{} - {} {}".format(cp.name, db.unit_type_name(unit_type), count_per_type))