计算游戏中单位的价值
我目前正在开发一款游戏,其中每个单位都有生命值、护盾和敏捷性以及一定数量的六种武器。
例如,B 队有 2 个激光器、2 个重型激光器和 1 个导弹发射器,没有离子爆炸器、没有重离子爆炸器、没有核导弹、5 生命值、2 护盾和 40 敏捷性。
我已经尝试了 20 种不同的算法,试图让 MS Excel 平衡所有这些因素,从而给船舶评分。我当前的算法对于一些较小的单位来说效果很好,但对于较大的单位来说非常不平衡
每艘船都有一个伤害值,其中每种类型的武器乘以该武器的伤害并相加。
damage = weapon1*damage1 + weapon2*damage2 + ...
伤害值乘以生命值+2*护盾+2*敏捷。敏捷性和护盾成倍增加,使它们的重量超过生命值(如果单位不能被击中,则不会失去生命值)。我还减去了单位成本。因此,我目前的一个单位的方程式如下:
value = damage*(health + 2*shield + 2*agility) - 3*cost
以下是一些示例:
- 单位 1 - 1 个激光、1 个生命值、93 敏捷性和成本 1。总分是 233。
- 单位 2 - 2 个激光、一个导弹发射器和 3健康,但敏捷只有76。分数是200。
- 第3单元 - 6激光,30生命值和15护盾,37敏捷性 - 分数585。
我希望第3单元的分数更高,但第1和2单元的分数相当不错。谁能提出一个更好的方程来平滑这些值?
I'm currently working on a game where each unit has a value for health, shields and agility as well as a certain number of six types of weapon.
e.g. Unit B has 2 lasers, 2 heavy lasers, and 1 missile launcher, no ion blaster, no heavy ion blaster, no nuclear missiles, 5 health, 2 shield, and 40 agility.
I have gone through a good 20 different algorithms trying to get MS Excel to balance these all these factors to give the ship a score. My current algorithm works great for some of the smaller units, but gets very unbalanced with the bigger units
Each ship has a damage value, where each type of weaponry is multiplied by the damage of that weapon and added together.
damage = weapon1*damage1 + weapon2*damage2 + ...
The damage value is multiplied by health + 2*shield + 2*agility. Agility and shield are multiplied to give them weight over health (a unit cant lose health if it can't be hit). I also subtract the cost of the unit. So my current equation for one of my units looks like:
value = damage*(health + 2*shield + 2*agility) - 3*cost
Here are some examples:
- Unit 1 - 1 laser, 1 health, 93 agility, and costs 1. Total score is 233.
- Unit 2 - 2 lasers, a missile launcher, and 3 health, but only 76 agility. Score is 200.
- Unit 3 - 6 lasers, 30 health and 15 shields, 37 agility - scores 585.
I want the scores of unit 3 to be higher, but the scores for units 1 and 2 are pretty good. Can anyone suggest a better equation that will smooth out the values?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为遗传编程算法是解决您描述的问题的好方法。遗传编程通过迭代演进算法的计算,以最小化成本函数。这是通过创建一组应用于算法的“突变”来完成的,例如您减少单位成本的想法,因为 3R 可能是突变之一。成本函数将是相对于平衡概念增加/减少的东西。将根据该成本函数来评估突变。
请参阅《Python 代码编程集体智能》一书来解决此类问题。
I think a genetic programming algorithm is a good approach to solving the issue you describe. Genetic programming evolves an algorithm's computations through iteration to minimize a cost function. This is done by creating a set of "mutations" to apply to the algorithm, for instance your idea of decreasing by the cost of the unit as 3R could be one of the mutations. The cost function would be something that increases/decreases relative to the concept of balance. Mutations would be evaluated in light of this cost function.
See the book Programming Collective Intelligence for Python code to do this type of problem solving.
这个问题类似于我的云平衡示例(打开来源,java)。只需将计算机替换为单位,将进程替换为武器即可。
This problem is similar to my cloud balancing example (open source, java). Just replace Computer by Unit and Process by Weapon.