Skip to content

Commit

Permalink
make easy and medium bot levels biased against other bots
Browse files Browse the repository at this point in the history
  • Loading branch information
Sesu8642 committed Oct 7, 2024
1 parent 99b6853 commit c2cc054
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import de.sesu8642.feudaltactics.lib.gamestate.InputValidationHelper;
import de.sesu8642.feudaltactics.lib.gamestate.Kingdom;
import de.sesu8642.feudaltactics.lib.gamestate.PalmTree;
import de.sesu8642.feudaltactics.lib.gamestate.Player.Type;
import de.sesu8642.feudaltactics.lib.gamestate.Tree;
import de.sesu8642.feudaltactics.lib.gamestate.Unit;
import de.sesu8642.feudaltactics.lib.gamestate.Unit.UnitTypes;
Expand Down Expand Up @@ -704,6 +705,10 @@ private OffenseTileScoreInfo getOffenseTileScoreInfo(GameState gameState, Intell
if (!intelligence.smartAttacking) {
score = 0;
}
if (tile.getPlayer().getType() == Type.LOCAL_BOT) {
score += intelligence.attackOtherBotsBias;
}

return new OffenseTileScoreInfo(tile, score, requiredStrength);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

/** Possible intelligence levels for the AI. */
public enum Intelligence {
LEVEL_1(0.5F, 0, false, Integer.MAX_VALUE, Integer.MAX_VALUE, false, false),
LEVEL_2(0.8F, 0, false, Integer.MAX_VALUE, Integer.MAX_VALUE, false, true),
LEVEL_3(1F, 4, false, 25, 20, true, true), LEVEL_4(1F, 7, true, 25, 20, true, true);
LEVEL_1(0.5F, 0, false, Integer.MAX_VALUE, Integer.MAX_VALUE, 5, false, false),
LEVEL_2(0.8F, 0, false, Integer.MAX_VALUE, Integer.MAX_VALUE, 5, false, true),
LEVEL_3(1F, 4, false, 25, 20, 0, true, true), LEVEL_4(1F, 7, true, 25, 20, 0, true, true);

/** Chance that the bot will even try to conquer anything in a given turn. */
public final float chanceToConquerPerTurn;
Expand Down Expand Up @@ -38,29 +38,36 @@ public enum Intelligence {
*/
public final int protectWithUnitScoreTreshold;

/**
* Offense tile scores for other bot players will be increased by this amount to
* make the game easier for the human players.
*/
public final int attackOtherBotsBias;

/**
* Whether to defend smartly: i.e. considering how many tiles are protected. If
* false, the defense score of every tile is 0. This means that (basically)
* random tiles near the border are protected.
*/
boolean smartDefending;
public final boolean smartDefending;

/**
* Whether to attack smartly: prefer enemy kingdom tiles over unconnected ones,
* destroy castles etc. If false, the offense score of every tile is 0. This
* means that (basically) random tiles are conquered.
*/
boolean smartAttacking;
public final boolean smartAttacking;

private Intelligence(float chanceToConquerPerTurn, int blockingObjectRemovalScoreTreshold,
boolean reconsidersWhichTilesToProtect, int protectWithCastleScoreTreshold,
int protectWithUnitScoreTreshold, boolean smartDefending, boolean smartAttacking) {
int protectWithUnitScoreTreshold, int attackOtherBotsBias, boolean smartDefending, boolean smartAttacking) {
this.chanceToConquerPerTurn = chanceToConquerPerTurn;
this.blockingObjectRemovalScoreTreshold = blockingObjectRemovalScoreTreshold;
this.reconsidersWhichTilesToProtect = reconsidersWhichTilesToProtect;
this.smartDefending = smartDefending;
this.protectWithCastleScoreTreshold = protectWithCastleScoreTreshold;
this.protectWithUnitScoreTreshold = protectWithUnitScoreTreshold;
this.attackOtherBotsBias = attackOtherBotsBias;
this.smartDefending = smartDefending;
this.smartAttacking = smartAttacking;
}

Expand Down

0 comments on commit c2cc054

Please sign in to comment.