当前位置: 首页>>代码示例>>Java>>正文


Java MissionAIPlayer类代码示例

本文整理汇总了Java中net.sf.freecol.server.ai.MissionAIPlayer的典型用法代码示例。如果您正苦于以下问题:Java MissionAIPlayer类的具体用法?Java MissionAIPlayer怎么用?Java MissionAIPlayer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MissionAIPlayer类属于net.sf.freecol.server.ai包,在下文中一共展示了MissionAIPlayer类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: scoreSettlementPath

import net.sf.freecol.server.ai.MissionAIPlayer; //导入依赖的package包/类
/**
 * Scores a potential attack on a settlement.
 *
 * Do not cheat and look inside the settlement.
 * Just use visible facts about it.
 *
 * FIXME: if we are the REF and there is a significant Tory
 * population inside, assume traitors have briefed us.
 *
 * @param aiUnit The {@code AIUnit} to do the mission.
 * @param path The {@code PathNode} to take to the settlement.
 * @param settlement The {@code Settlement} to attack.
 * @return A score of the desirability of the mission.
 */
private static int scoreSettlementPath(AIUnit aiUnit, PathNode path,
                                       Settlement settlement) {
    if (invalidSettlementReason(aiUnit, settlement) != null) {
        return Integer.MIN_VALUE;
    }
    final Unit unit = aiUnit.getUnit();
    final CombatModel combatModel = unit.getGame().getCombatModel();

    int value = 1020;
    value -= path.getTotalTurns() * 100;

    final double off = combatModel.getOffencePower(unit, settlement);
    value += (int)Math.round(off * 50);

    value = settlement.calculateSettlementValue(value, unit);

    return ((MissionAIPlayer)aiUnit.getAIOwner()).adjustMission(
        aiUnit, path, UnitSeekAndDestroyMission.class, value);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:34,代码来源:UnitSeekAndDestroyMission.java

示例2: scorePath

import net.sf.freecol.server.ai.MissionAIPlayer; //导入依赖的package包/类
/**
 * Evaluate allocating a unit to the defence of a settlement.
 *
 * @param aiUnit The {@code AIUnit} that is to defend.
 * @param path A {@code PathNode} to take to the settlement.
 * @return A value for such a mission.
 */
public static int scorePath(AIUnit aiUnit, PathNode path) {
    final Location loc = extractTarget(aiUnit, path);
    return (loc instanceof Settlement)
        ? ((MissionAIPlayer)aiUnit.getAIOwner()).adjustMission(
            aiUnit, path, DefendSettlementMission.class,
            (int)(1000 * ((Settlement)loc).getDefenceRatio()
                / (path.getTotalTurns() + 1)))
        : Integer.MIN_VALUE;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:17,代码来源:DefendSettlementMission.java

示例3: scoreUnitPath

import net.sf.freecol.server.ai.MissionAIPlayer; //导入依赖的package包/类
/**
 * Scores a potential attack on a unit.
 *
 * @param aiUnit The {@code AIUnit} to do the mission.
 * @param path The {@code PathNode} to take to the settlement.
 * @param defender The {@code Unit} to attack.
 * @return A score of the desirability of the mission.
 */
private static int scoreUnitPath(AIUnit aiUnit, PathNode path,
                                 Unit defender) {
    if (invalidUnitReason(aiUnit, defender) != null) {
        return Integer.MIN_VALUE;
    }
    final Unit unit = aiUnit.getUnit();
    final Tile tile = path.getLastNode().getTile();
    final int turns = path.getTotalTurns();
    final CombatModel combatModel = unit.getGame().getCombatModel();
    final double off = combatModel.getOffencePower(unit, defender);
    final double def = combatModel.getDefencePower(unit, defender);
    if (tile == null || off <= 0) return Integer.MIN_VALUE;

    int value = 1020 - turns * 100;
    value += 100 * (off - def);

    // Add a big bonus for treasure trains on the tile.
    // Do not cheat and look at the value.
    value += 1000 * count(tile.getUnits(),
        u -> u.canCarryTreasure() && u.getTreasureAmount() > 0);

    if (defender.isNaval()) {
        if (tile.isLand()) value += 500; // Easy win
    } else {
        if (defender.hasAbility(Ability.EXPERT_SOLDIER)
            && !defender.isArmed()) value += 100;
    }
    return ((MissionAIPlayer)aiUnit.getAIOwner()).adjustMission(
        aiUnit, path, UnitSeekAndDestroyMission.class, value);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:39,代码来源:UnitSeekAndDestroyMission.java

示例4: getAIPlayer

import net.sf.freecol.server.ai.MissionAIPlayer; //导入依赖的package包/类
/**
 * Convenience accessor for the owning AI player.
 *
 * @return The {@code AIPlayer}.
 */
protected final MissionAIPlayer getAIPlayer() {
    return (MissionAIPlayer)getAIMain().getAIPlayer(getUnit().getOwner());
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:9,代码来源:Mission.java


注:本文中的net.sf.freecol.server.ai.MissionAIPlayer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。