SDL中文论坛
标题:
函数:power_projection
[打印本页]
作者:
admin
时间:
2020-8-24 16:46
标题:
函数:power_projection
计算特定群体(dstsrc指定)在loc这个格子上累计能释放出的攻击能量。
double ai::power_projection(const map_location& loc, const move_map& dstsrc, bool use_terrain) const
@loc:要针对那点进能累计的格子;
@dstsrc:它的value(map中的<key, value>对)是要同它们进行累计群体。像累计反击,用enemy_dstsrc,累计援助,用fullmove_dstsrc。在此可以根据字面推出是反击还是援助,只要记住函数中用了dstsrc.equal_range(locs[i])来枚举要考虑的在该格子上单位集。enemy_dstsrc,它的src(dstsrc中src)是敌方阵营单位,用了equal_range后它反回就是敌方阵营迭代器。
@use_terrain:计算释放出的能量时是否要考虑地形因素。
作者:
admin
时间:
2020-8-24 16:48
标题:
实例:执行一次power_projection
(, 下载次数: 3102)
上传
点击文件名下载附件
说明:
do_attack_analysis中,被攻击目标锁定周瑜。如果徐晃移动到(2,1)对周瑜执行攻击,那么在(2,1)点徐晃将受到的来自敌方团队的反击和已方团队的支援情况。
#1(2, 1), hp: 1000, defense: 40, most_damage: 6000, village_bonus: 2, rating: 2400000, best_rating: 2400000, res: 1680000
#1(2, 1):loc某个方向上空格。(2,1)1方向上空格,即(3,0);
hp,defense,most_damage,village_bonus,rating:分别对应程序中的同名变量的值。像6000 = 15 * 4 * 100;
best_rating:到这个单位止,在#1(2,1)找到的最佳单位。
res:到这个单位止,在(2,1)累计能能释的能量。作为返回值是要res/100000.0;
来自敌方团队的反击
#0(2, 1), hp: 1000, defense: 40, most_damage: 4200, village_bonus: 2, rating: 1680000, best_rating: 1680000, res: 0
#1(2, 1), hp: 1000, defense: 40, most_damage: 6000, village_bonus: 2, rating: 2400000, best_rating: 2400000, res: 1680000
#1(2, 1), hp: 1000, defense: 40, most_damage: 4200, village_bonus: 2, rating: 1680000, best_rating: 2400000, res: 1680000
#2(2, 1), hp: 1000, defense: 40, most_damage: 6000, village_bonus: 2, rating: 2400000, best_rating: 2400000, res: 4080000
#2(2, 1), hp: 1000, defense: 40, most_damage: 4200, village_bonus: 2, rating: 1680000, best_rating: 2400000, res: 4080000
#3(2, 1), hp: 1000, defense: 40, most_damage: 6000, village_bonus: 2, rating: 2400000, best_rating: 2400000, res: 4080000
#3(2, 1), hp: 1000, defense: 40, most_damage: 4200, village_bonus: 2, rating: 1680000, best_rating: 2400000, res: 4080000
#5(2, 1), hp: 1000, defense: 40, most_damage: 6000, village_bonus: 2, rating: 2400000, best_rating: 2400000, res: 4080000
res: 40.80000
来自已方团队的支援
#1(2, 1), hp: 1000, defense: 50, most_damage: 4000, village_bonus: 2, rating: 2000000, best_rating: 2000000, res: 0
#1(2, 1), hp: 1000, defense: 50, most_damage: 3900, village_bonus: 2, rating: 1950000, best_rating: 2000000, res: 0
#1(2, 1), hp: 1000, defense: 50, most_damage: 4800, village_bonus: 2, rating: 2400000, best_rating: 2400000, res: 0
#1(2, 1), hp: 1000, defense: 50, most_damage: 6800, village_bonus: 2, rating: 3400000, best_rating: 3400000, res: 0
#1(2, 1), hp: 1000, defense: 50, most_damage: 4400, village_bonus: 2, rating: 2200000, best_rating: 3400000, res: 0
在(3,0),满宠能产生3400000,它作为最好能量。
#2(2, 1), hp: 1000, defense: 50, most_damage: 4000, village_bonus: 2, rating: 2000000, best_rating: 2000000, res: 3400000
#2(2, 1), hp: 1000, defense: 50, most_damage: 3900, village_bonus: 2, rating: 1950000, best_rating: 2000000, res: 3400000
#2(2, 1), hp: 1000, defense: 50, most_damage: 4800, village_bonus: 2, rating: 2400000, best_rating: 2400000, res: 3400000
#2(2, 1), hp: 1000, defense: 50, most_damage: 6800, village_bonus: 2, rating: 3400000, best_rating: 3400000, res: 3400000
#2(2, 1), hp: 1000, defense: 50, most_damage: 4400, village_bonus: 2, rating: 2200000, best_rating: 3400000, res: 3400000
在(3,1),满宠能产生3400000,依旧是他最大,但一个人一个时刻只能站在一个格子。作为较好累计方法是3400000+2400000,但是现在程序没这么做,遇到这种等值突冲情况它只是简单地忽略掉第二个。
#3(2, 1), hp: 1000, defense: 50, most_damage: 4000, village_bonus: 2, rating: 2000000, best_rating: 2000000, res: 3400000
#3(2, 1), hp: 1000, defense: 50, most_damage: 3900, village_bonus: 2, rating: 1950000, best_rating: 2000000, res: 3400000
#3(2, 1), hp: 1000, defense: 50, most_damage: 4800, village_bonus: 2, rating: 2400000, best_rating: 2400000, res: 3400000
#3(2, 1), hp: 1000, defense: 50, most_damage: 6800, village_bonus: 2, rating: 3400000, best_rating: 3400000, res: 3400000
#3(2, 1), hp: 1000, defense: 50, most_damage: 4400, village_bonus: 2, rating: 2200000, best_rating: 3400000, res: 3400000
和在(3,1)一样,在(2,2)满宠产生3400000,依旧是他最大,但这值再次被忽略
#4(2, 1), hp: 1000, defense: 50, most_damage: 4800, village_bonus: 2, rating: 2400000, best_rating: 2400000, res: 3400000
只有徐晃能移动到(1,2)(它站在那个格式,别的单位没法移动到那里)。作为累计,结果就是3400000+2400000=5800000
res: 58.00000
单点能量公式:
rating = hp * defense * most_damage * village_bonus / 200;
-------------------------------------------------
为计算一团队在一格子上能产生的能总和,像以上的在曹魏对(2,1)支援,采用办法是分对对(2,1)周围6个格子计算能量,然后累计,而对于某个特定毗邻格子,像(3,1),则是在所以到移动它的单位取最大值,以上就是徐晃,乐进、牛金(友军)、徐晃、满宠和曹仁(友军)中取。
这个算法在实际执行时会遇到个问题,就是一个单位在一个时刻只能站在一个格子上。就以上的满宠,他在(3,0),(3,1)和(2,2)都是产生最大能量,但他只能作为在一个地方被取值。为了解决定个冲突,程序借用以下三个变量,
map_location used_locs[6]:用于存放已经选中的最优单位;
int ratings[6]:对应used_locs,在那位置上的能量值;
int num_used_locs:used_locs,used_locs中已使用的有效位置数;
以上也可以发现,像来自已方团队支援分析,因为冲突问题,三个点上累计时其实只使用了一个,这当然就造成结果不精确。或许吧,这函数本来就没法做到精确。
作者:
admin
时间:
2020-8-24 16:48
标题:
几个问题
一、计算时该点是被计算在内,但在实际移动时单位可能已经无法移动到那里了。像考虑(2,1)反击,计算时周瑜能在(3,0)产生反击,但经过徐晃阵营移动后,(2,1)被占,周瑜可能就没法移动到(3,0);
二、计算most_damage没有考虑命中率,全用了100%,这和实际自然有差入;
三、因为最优值冲突问题,几个点上累计时其实只使用了一个。
===>这个函数只能算为一种模糊参考
--------------------------
power_projection返回值范围:大概等于单位平均攻击造成伤害*3。
平均攻击造成伤害:攻击次数*每次攻击造成伤害。考虑到谁都可能被采用最大值,使用平均。
*3:6个格子,但在计算rating时用了/200。
欢迎光临 SDL中文论坛 (http://www.libsdl.cn/bbs/)
Powered by Discuz! X3.3