具体来说,我指的是为这个比赛编程:http://www.nodewar.com/about
比赛涉及你在二维世界中与其他团队对抗,使用一群太空船。船只受到边界的限制(如果离开边界它们会死亡),并且它们必须不断避开月球(月球会用引力将船只拉近)。目标是杀死对方的 queen(女王)。
我尝试过编写一些相对基础的技术,但感觉似乎遗漏了一些基本的东西。
例如,我实现了一些 boids 行为(http://www.red3d.com/cwr/boids/),但它们似乎缺乏…目标,可以这么说。
对于这种类型的游戏,有没有一些常见的技术(或者更preferably,技术的组合)?
编辑
我想再次开放这个问题并提供赏金,因为我觉得我仍然缺少一些关键信息。以下是我的 NodeWar 代码:
boundary_field = (o, position) -> distance = (o.game.moon_field - o.lib.vec.len(o.lib.vec.diff(position, o.game.center))) return distancemoon_field = (o, position) -> return o.lib.vec.len(o.lib.vec.diff(position, o.moons[0].pos))ai.step = (o) -> torque = 0; thrust = 0; label = null; fields = [boundary_field, moon_field] # Total the potential fields and determine a target. target = [0, 0] score = -1000000 step = 1 square = 1 for x in [(-square + o.me.pos[0])..(square + o.me.pos[0])] by step for y in [(-square + o.me.pos[1])..(square + o.me.pos[1])] by step position = [x, y] continue if o.lib.vec.len(position) > o.game.moon_field value = (fields.map (f) -> f(o, position)).reduce (t, s) -> t + s target = position if value > score score = value if value > score label = target { torque, thrust } = o.lib.targeting.simpleTarget(o.me, target) return { torque, thrust, label }
然而,我可能在实现潜在场方面有误,因为我能找到的所有例子都是关于离散移动的(而 NodeWar 是连续且不精确的)。
主要问题是我的 AI 无法在游戏区域内停留超过10秒而不飞出屏幕或撞上月球。
回答:
你可以轻松地让 boids 算法玩 Nodewar 游戏,只需向你的 boids 添加额外的转向行为和/或修改默认行为。例如,你可以添加一个避免月球的转向行为,以及一个针对敌方船只的转向行为(根据你和敌方船只之间的位置决定是排斥还是吸引)。然后应该调整吸引/排斥力的权重(可能通过遗传算法,让不同的配置相互对抗)。
我相信这种方法已经可以为你提供一个相对强大的基础玩家,你可以开始添加协作策略等。