Re: AI Development Questions
Concerning r25363:
- Code: Select all
// will the creature attack (only relevant for sorcery speed)?
if (game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS)
&& game.getPhaseHandler().isPlayerTurn(ai)
&& ComputerUtilCard.doesCreatureAttackAI(ai, c)) {
return true;
}
- Code: Select all
//creature is attacking and would be destroyed itself
if (game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS)
&& combat.isAttacking(c) && combat.isBlocked(c) ) {
List<Card> blockers = combat.getBlockers(c);
if (!blockers.isEmpty() && ComputerUtilCombat.blockerWouldBeDestroyed(ai, blockers.get(0), combat)) {
List<Card> threats = combat.getBlockers(c);
ComputerUtilCard.sortByEvaluateCreature(threats);
return (true && (ProtectAi.toProtectFrom(threats.get(0), sa) != null));
}
}
- Code: Select all
//make unblockable
if (ph.getPlayerTurn() == ai && ph.getPhase() == PhaseType.MAIN1) {
AiAttackController aiAtk = new AiAttackController(ai, c);
String s = aiAtk.toProtectAttacker(sa);
if (s==null) {
return false;
} else {
Combat combat = ai.getGame().getCombat();
int dmg = ComputerUtilCombat.damageIfUnblocked(c, ai.getOpponent(), combat);
float ratio = 1.0f * dmg / ai.getOpponent().getLife();
Random r = MyRandom.getRandom();
return r.nextFloat() < ratio;
}
}