火力规则:装备匹配规则实现,目标规则实现,阵位规则简单实现(需要细化)
This commit is contained in:
@@ -4,6 +4,8 @@ import com.solution.rule.domain.ultimately.fact.DroolsFact;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.solution.rule.utils.RuleFunction.equipmentRule;
|
||||
import static com.solution.rule.utils.RuleFunction.target;
|
||||
import static com.solution.rule.utils.RuleFunction.position;
|
||||
|
||||
|
||||
global java.util.Map globalParams;
|
||||
@@ -74,6 +76,77 @@ function Map buildParam(){
|
||||
param.put("redMatchKeywords_missile", "防空,导弹,导弹发射");
|
||||
param.put("missileScore", 1);
|
||||
|
||||
// ===================== 目标分配参数(写入 Tasks.task.execute) =====================
|
||||
// executeTypeDefault:生成 execute[0] 的类型字段
|
||||
param.put("executeTypeDefault", "assault");
|
||||
// targetPickMode:roundRobin(稳定轮询) / random(伪随机但同输入稳定)
|
||||
param.put("targetPickMode", "roundRobin");
|
||||
// minTargetsPerRed / maxTargetsPerRedCap:每个红方任务最少/最多分配的目标数
|
||||
param.put("minTargetsPerRed", 1);
|
||||
param.put("maxTargetsPerRedCap", 3);
|
||||
// radToTargetsCsv:successTargetRad(命中率) -> 每红装目标数 的映射(阈值:目标数),按阈值从大到小匹配
|
||||
// 例:0.8:1,0.5:2,0.2:3 表示 successTargetRad>=0.8 分1个;>=0.5 分2个;>=0.2 分3个
|
||||
param.put("radToTargetsCsv", "0.8:1,0.5:2,0.2:3");
|
||||
// rangeParseRegex:从 attDefaultValue/attExplain 中提取射程数值的正则(取第1个数字)
|
||||
param.put("rangeParseRegex", "(\\\\d+(?:\\\\.\\\\d+)?)");
|
||||
// rangeUnit:提取数值的单位,km/m(二选一)
|
||||
param.put("rangeUnit", "km");
|
||||
// minRangeToAllowAssignKm:若解析到的蓝方射程小于该值,则该蓝方装备不参与被分配(无法解析则忽略此过滤)
|
||||
param.put("minRangeToAllowAssignKm", 0);
|
||||
|
||||
// ===================== 低命中率补拿装备参数 =====================
|
||||
// redHitRateThreshold:红方装备命中率阈值(低于该值时触发补拿)
|
||||
param.put("redHitRateThreshold", 0.6);
|
||||
// maxExtraWeaponsPerTask:每条蓝方任务最多补拿几件红装
|
||||
param.put("maxExtraWeaponsPerTask", 2);
|
||||
// maxSupplementRounds:补拿循环最大轮次(防死循环)
|
||||
param.put("maxSupplementRounds", 2);
|
||||
// extraPickMinScore:补拿时红装最低匹配分
|
||||
param.put("extraPickMinScore", 1);
|
||||
|
||||
// ===================== 阵位规则参数(写入 SubComponents.platform[].positions) =====================
|
||||
// positionRuleEnabled:是否启用阵位规则。true=执行阵位生成;false=跳过,不改 platform.positions。
|
||||
param.put("positionRuleEnabled", true);
|
||||
// positionAnchorMode:锚点模式。当前实现使用 hybrid(蓝方 taskWeapons.coordinate 的中心点作为主锚点)。
|
||||
param.put("positionAnchorMode", "hybrid");
|
||||
// trackPointDirectionMode:航向计算模式。
|
||||
// - head2next:取 trackPoints[0] -> trackPoints[1] 作为方向(默认)
|
||||
// - tail2prev:取倒数第二个 -> 最后一个点作为方向
|
||||
param.put("trackPointDirectionMode", "head2next");
|
||||
// fallbackBearingDeg:当 trackPoints 缺失或无法计算方位时,使用该默认方位角(度,0-360)。
|
||||
param.put("fallbackBearingDeg", 0);
|
||||
// deployDistanceKmMin:部署距离下限(km)。最终距离不会小于该值。
|
||||
param.put("deployDistanceKmMin", 8);
|
||||
// deployDistanceKmMax:部署距离上限(km)。最终距离不会大于该值。
|
||||
param.put("deployDistanceKmMax", 30);
|
||||
// deployDistanceKmDefault:默认部署距离(km)。
|
||||
// 当 distanceByPlatformCsv 未命中任何关键词时,使用该值。
|
||||
param.put("deployDistanceKmDefault", 15);
|
||||
// distanceByPlatformCsv:按“关键词”覆盖部署距离(km),不写死具体类型,完全由业务配置。
|
||||
// 格式:关键词:距离,关键词:距离(示例:防空:18,反坦克:10,迫击炮:8)
|
||||
// 匹配范围:红方装备 Name / Platform_type 文本包含关键词即命中。
|
||||
// 优先级:命中后覆盖 deployDistanceKmDefault;但最终仍受 deployDistanceKmMin 与 deployDistanceKmMax 约束。
|
||||
param.put("distanceByPlatformCsv", "");
|
||||
// formationType:编队样式,可选 line / wedge / circle。
|
||||
param.put("formationType", "line");
|
||||
// formationSpacingMeters:编队间距(米),影响同一红装下 platform[] 点位离散程度。
|
||||
// 说明:Java 侧会与 minInterPlatformDistanceMeters 比较,取更大值,避免平台重叠过近。
|
||||
param.put("formationSpacingMeters", 300);
|
||||
// formationHeadingOffsetDeg:编队相对主航向的偏转角(度),主要用于 wedge/circle 的分散方向。
|
||||
param.put("formationHeadingOffsetDeg", 15);
|
||||
// defaultDeployHeight:默认部署高度(米),用于 positions 第3位高度值基线。
|
||||
param.put("defaultDeployHeight", 30);
|
||||
// heightFollowBlueRatio:高度跟随蓝方比例(>=0)。
|
||||
// 计算方式:高度 = defaultDeployHeight + 蓝方锚点平均高度 * heightFollowBlueRatio。
|
||||
// 0 表示不跟随蓝方高度,仅使用默认高度。
|
||||
param.put("heightFollowBlueRatio", 0.0);
|
||||
// enableWarZoneClamp:是否启用作战区约束。true=超出 warZoneLocation 时回拉到区内。
|
||||
param.put("enableWarZoneClamp", true);
|
||||
// warZoneClampMode:作战区约束模式。当前实现使用 nearestInside(沿锚点到目标点方向二分回拉到区内)。
|
||||
param.put("warZoneClampMode", "nearestInside");
|
||||
// minInterPlatformDistanceMeters:平台最小间距(米)下限,用于抑制平台点位过度重叠。
|
||||
param.put("minInterPlatformDistanceMeters", 80);
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
@@ -86,3 +159,23 @@ then
|
||||
globalParams.putAll(buildParam());
|
||||
equipmentRule($fact, globalParams);
|
||||
end
|
||||
|
||||
rule "目标匹配"
|
||||
salience 90
|
||||
when
|
||||
$fact : DroolsFact(task != null)
|
||||
then
|
||||
// 显式目标分配规则:填充 Tasks.task.execute.targetList[*].targetId
|
||||
globalParams.putAll(buildParam());
|
||||
target($fact, globalParams);
|
||||
end
|
||||
|
||||
rule "阵位匹配"
|
||||
salience 80
|
||||
when
|
||||
$fact : DroolsFact(task != null)
|
||||
then
|
||||
// 显式阵位规则:填充 redWeapons.SubComponents.platform[].positions
|
||||
globalParams.putAll(buildParam());
|
||||
position($fact, globalParams);
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user