Skip to content

Commit e65f5cd

Browse files
Breaking the contract (Sorry Corfixen) for debugging reasons
1 parent 6e46f75 commit e65f5cd

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/main/java/dk/sdu/mmmi/modulemon/MCTSBattleAI/Node.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import dk.sdu.mmmi.modulemon.CommonBattleSimulation.IBattleState;
55
import dk.sdu.mmmi.modulemon.CommonMonster.IMonster;
66
import dk.sdu.mmmi.modulemon.CommonMonster.IMonsterMove;
7+
import dk.sdu.mmmi.modulemon.Monster.BattleMonsterProcessor;
78

89
import java.util.ArrayList;
910

@@ -109,7 +110,9 @@ public String toString() {
109110
if(this.parent != null){
110111
String action = "doing nothing";
111112
if(this.parentMove != null){
112-
action = String.format("%s using %s", this.parent.getParticipant().getActiveMonster().getName(), this.parentMove);
113+
// Debugging and breaking the contract
114+
var damageMoveWouldDeal = new BattleMonsterProcessor().calculateDamage(this.parent.getParticipant().getActiveMonster(), this.parentMove, getOpposingParticipant(this.parent.getParticipant(), this.parent.state).getActiveMonster());
115+
action = String.format("%s using %s (would deal %d)", this.parent.getParticipant().getActiveMonster().getName(), this.parentMove, damageMoveWouldDeal);
113116
}else if(this.parentSwitch != null){
114117
action = "Switching to " + this.parentSwitch;
115118
}

src/main/java/dk/sdu/mmmi/modulemon/Monster/BattleMonsterProcessor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ public int calculateDamage(IMonster iSource, IMonsterMove iMove, IMonster iTarge
3434
float sourceAttack = (float) source.getAttack();
3535
float targetDefence = (float) target.getDefence();
3636

37-
boolean shouldUseNonDeterminism = (Boolean) settings.getSetting(SettingsRegistry.getInstance().getNonDeterminism());
37+
// Defaults to non-random if settings is null
38+
boolean shouldUseNonDeterminism = settings != null && (Boolean) settings.getSetting(SettingsRegistry.getInstance().getNonDeterminism());
3839

3940
if (!doAccuracyHit(move.getAccuracy()) && shouldUseNonDeterminism) { return 0; }
4041
// Same type attack bonus. Effectively the same as STAB in that other game

0 commit comments

Comments
 (0)