private bool IsBetterMove(MoveAction newAction, float currentDistance, MoveAction prevAction, float bestDistance, Kernel kernel) { var newContext = (MoveActionContext)newAction.getContext(); var prevContext = (MoveActionContext)prevAction.getContext(); Fruiton newSource = KernelUtils.GetFruitonAt(kernel, newContext.source); Fruiton prevSource = KernelUtils.GetFruitonAt(kernel, prevContext.source); float newDistModifier = newSource.type == Fruiton.MAJOR_TYPE ? -1 : newSource.get_isKing() ? +1 : 0; float prevDistModifier = prevSource.type == Fruiton.MAJOR_TYPE ? -1 : prevSource.get_isKing() ? +1 : 0; return(currentDistance + newDistModifier < bestDistance + prevDistModifier); }
private bool IsBetterHeal(HealAction newAction, HealAction prevAction, Kernel kernel) { var newContext = (HealActionContext)newAction.getContext(); var prevContext = (HealActionContext)prevAction.getContext(); Fruiton newTarget = KernelUtils.GetFruitonAt(kernel, newContext.target); Fruiton prevTarget = KernelUtils.GetFruitonAt(kernel, prevContext.target); int newHealAmount = Math.Min(newContext.heal, newTarget.originalAttributes.hp - newTarget.currentAttributes.hp); int prevHealAmount = Math.Min(prevContext.heal, prevTarget.originalAttributes.hp - prevTarget.currentAttributes.hp); return(newTarget.get_isKing() || newTarget.type == Fruiton.MAJOR_TYPE && prevTarget.type == Fruiton.MINOR_TYPE || newTarget.type == prevTarget.type && newHealAmount > prevHealAmount); }
private bool IsBetterAttack(AttackAction newAction, AttackAction prevAction, Kernel kernel) { var newContext = (AttackActionContext)newAction.getContext(); var prevContext = (AttackActionContext)prevAction.getContext(); Fruiton newTarget = KernelUtils.GetFruitonAt(kernel, newContext.target); Fruiton prevTarget = KernelUtils.GetFruitonAt(kernel, prevContext.target); bool isNewKill = newTarget.currentAttributes.hp <= newContext.damage; bool isPrevKill = prevTarget.currentAttributes.hp <= prevContext.damage; if (prevTarget.get_isKing()) { return(false); } return(newTarget.get_isKing() || isNewKill && !isPrevKill || newContext.damage > prevContext.damage || newTarget.type == Fruiton.MAJOR_TYPE && prevTarget.type == Fruiton.MINOR_TYPE); }