protected void setLastBattleAction(Move m) { if (m.isBoost) { lastAction = LastBattleAction.ACTION_BOOST; } else if (m.name.Contains("Sleep Talk")) { lastAction = LastBattleAction.ACTION_SLEEPTALK; } else if (m.name.Contains("Fake Out")) { lastAction = LastBattleAction.ACTION_FAKEOUT; currentActive.canUseFakeout = false; } else if (m.field) { lastAction = LastBattleAction.ACTION_HAZARD; currentActive.hasUsedHazard = true; } else if (m.status) { lastAction = LastBattleAction.ACTION_STATUS; } else { lastAction = LastBattleAction.ACTION_ATTACK_SUCCESS; } lastMove = m; }
/// <summary> /// Returns a rank from -4 to 7 /// </summary> /// <param name="e"></param> /// <param name="lastAction"></param> /// <returns></returns> private int getRecoverChance(BattlePokemon e, LastBattleAction lastAction) { BattlePokemon you = this; int hpThreshold = 40; //Percent of health at which to conisder recovering. int chance = 0; if (you.getHPPercentage() <= hpThreshold) { chance += 3; } else if (you.getHPPercentage() > (100 - hpThreshold)) { chance -= 2; } if (e.checkKOChance(you) < 0.3f) { chance += 2; //heal if the opponent cannot ohko us. } if (you.status != Status.STATE_HEALTHY && lastAction != LastBattleAction.ACTION_SLEEPTALK) { chance += 2; } if (lastAction == LastBattleAction.ACTION_RECOVER) { chance -= 2; } return(chance); }
private int getBoostChance(BattlePokemon you, BattlePokemon e, Move m, LastBattleAction lastAction) { int chance = 0; int minHP = 30; float enemyTolerance = 0.5f; List <String> boosts = m.whatBoosts(); //lower rank if already maxed out. foreach (string s in boosts) { if (this.getBoostModifier(s) == 4f) { chance -= 1; } } if (you.getHPPercentage() <= minHP) { chance -= 2; //too weak, should focus efforts elsewhere } if (e.checkKOChance(you) < enemyTolerance) { chance += 2; //enemy does not threaten us } else if (e.checkKOChance(you) - 0.2f < enemyTolerance) { chance += 2; //if boosting will make us survive, do it. } else { chance -= 2; //otherwise too risky } if (you.mon.getRole().setup) { chance += 4; //if the mon is a setup sweeper, etc, } if (lastAction == LastBattleAction.ACTION_BOOST) { chance -= 1; //Be careful not to boost forever. } return(chance); }
private int getBoostChance(BattlePokemon you, BattlePokemon e, Move m, LastBattleAction lastAction) { int chance = 0; int minHP = 30; float enemyTolerance = 0.5f; List<String> boosts = m.whatBoosts(); //lower rank if already maxed out. foreach (string s in boosts) { if (this.getBoostModifier(s) == 4f) chance -= 1; } if (you.getHPPercentage() <= minHP) chance -= 2; //too weak, should focus efforts elsewhere if (e.checkKOChance(you) < enemyTolerance) chance += 2; //enemy does not threaten us else if (e.checkKOChance(you) - 0.2f < enemyTolerance) chance += 2; //if boosting will make us survive, do it. else chance -= 2; //otherwise too risky if (you.mon.getRole().setup) chance += 4; //if the mon is a setup sweeper, etc, if (lastAction == LastBattleAction.ACTION_BOOST) chance -= 1; //Be careful not to boost forever. return chance; }
/// <summary> /// Returns a rank from -4 to 7 /// </summary> /// <param name="e"></param> /// <param name="lastAction"></param> /// <returns></returns> private int getRecoverChance(BattlePokemon e, LastBattleAction lastAction) { BattlePokemon you = this; int hpThreshold = 40; //Percent of health at which to conisder recovering. int chance = 0; if (you.getHPPercentage() <= hpThreshold) chance += 3; else if (you.getHPPercentage() > (100 - hpThreshold)) chance -= 2; if (e.checkKOChance(you) < 0.3f) chance += 2; //heal if the opponent cannot ohko us. if (you.status != Status.STATE_HEALTHY && lastAction != LastBattleAction.ACTION_SLEEPTALK) chance += 2; if (lastAction == LastBattleAction.ACTION_RECOVER) chance -= 2; return chance; }
/// <summary> /// Ranks a given move. /// Returns a rank >= 1 /// </summary> /// <param name="m"></param> /// <param name="enemy"></param> /// <returns></returns> public int rankMove(Move m, BattlePokemon enemy,List<BattlePokemon> enemyTeam, LastBattleAction lba) { int DEFAULT_RANK = 11; //(15 - 4) int rank = DEFAULT_RANK; // rank of move m if (m.group != "status") { rank = hitsToKill(m, enemy); //discourage the use of low accuracy moves if they're overkill if (m.accuracy != 1 && enemy.getHPPercentage() < 20) ++rank; if (m.priority > 0) rank -= m.priority; //To rank in ascending order (ie 1 is a poor rank) subtract the rank from the max. if (rank > GlobalConstants.MAX_MOVE_RANK) rank = GlobalConstants.MAX_MOVE_RANK; rank = GlobalConstants.MAX_MOVE_RANK - rank; } else { if (m.heal) { rank = getRecoverChance(enemy, lba); rank += ((100-getHPPercentage())/10); } else if (m.status) { rank += getStatusChance(this, enemy, m, enemyTeam); /* add the status rank to the default rank, meaning a good * status move will rank around the same as a 2HKO. This * will prevent cases where an easy OHKO is available, but * a turn is wasted on status. However it may need more * balancing. */ } else if (m.isBoost) { rank += getBoostChance(this, enemy, m, lba); } } return rank; }
/// <summary> /// Ranks a given move. /// Returns a rank >= 1 /// </summary> /// <param name="m"></param> /// <param name="enemy"></param> /// <returns></returns> public int rankMove(Move m, BattlePokemon enemy, List <BattlePokemon> enemyTeam, LastBattleAction lba, Weather weather) { int DEFAULT_RANK = 11; //(15 - 4) int rank = DEFAULT_RANK; // rank of move m if (m.group != "status") { rank = hitsToKill(m, enemy, weather); /* * Set the rank to the maximum if this move is fake out, and it can be used. * This is isn't always the move we want to make, so further checks need * to be developed. Namely, prevent using it against ghost types and * rough skin/iron barbs, etc. */ if (m.name.Contains("Fake Out") && this.canUseFakeout) { rank = 0; //Rank order is reversed for damaging moves, 0 = Max Rank. } //discourage the use of low accuracy moves if they're overkill if (m.accuracy != 1 && enemy.getHPPercentage() < 20) { ++rank; } if (m.priority > 0) { rank -= m.priority; } //To rank in ascending order (ie 1 is a poor rank) subtract the rank from the max. if (rank > GlobalConstants.MAX_MOVE_RANK) { rank = GlobalConstants.MAX_MOVE_RANK; //Prevent negative ranks. } rank = GlobalConstants.MAX_MOVE_RANK - rank; } else { if (m.heal) { rank = getRecoverChance(enemy, lba); rank += ((100 - getHPPercentage()) / 10); } else if (m.status) { rank += getStatusChance(this, enemy, m, enemyTeam); /* add the status rank to the default rank, meaning a good * status move will rank around the same as a 2HKO. This * will prevent cases where an easy OHKO is available, but * a turn is wasted on status. However it may need more * balancing. */ } else if (m.isBoost) { rank += getBoostChance(this, enemy, m, lba); } else if (m.field) { /* * If the pokemon is a lead and hasn't used a hazard, * rank this highly. Otherwise give it a small boost, * or have it remain default for non-lead pokemon. * This needs to be refined more. */ if (this.mon.getRole().lead&& !this.hasUsedHazard) { rank = GlobalConstants.MAX_MOVE_RANK; } else if (this.mon.getRole().lead) { rank += 1; } } } return(rank); }
private void setLastBattleAction(Move m) { if (m.isBoost) lastAction = LastBattleAction.ACTION_BOOST; else if (m.name.Contains("Sleep Talk")) { lastAction = LastBattleAction.ACTION_SLEEPTALK; } else if (m.status) { lastAction = LastBattleAction.ACTION_STATUS; } else lastAction = LastBattleAction.ACTION_ATTACK_SUCCESS; lastMove = m; }