5. Class Structure
@Override
public void close() {
}
@Override
public void getInformation(FrameData arg0) {
}
@Override
public int initialize(GameData arg0, boolean arg1) {
return 0;
}
• runs only once at the end of each game.
• gets information from the game status of each frame
• If fd.getRemaningTime() returns a negative value,
the current round has not started yet.
• More info in Javadoc of AIToolkit.
1 game = 3 rounds (60 sec / round)
• executed only once in the beginning of a game
6. Class Structure
@Override
public Key input() {
return null;
}
@Override
public void processing() {
}
@Override
public void roundEnd(int arg0, int arg1, int arg2) {
}
• receives key inputted from AI.
• It is executed in each frame and returns a value in the Key type.
• executed in each frame
• informs the result of each round.
[not sure] frames / sec
9. Step 1 Declare Global Variables & Initialization
Key inputKey;// Key class for return.
Random rnd;// is used for getting a random number.
@Override
public int initialize(GameData arg0, boolean arg1) {
inputKey = new Key();
rnd = new Random();
return 0;
}
12. More Details
1. Go to http://www.ice.ci.ritsumei.ac.jp/~ftgaic/index-2a.html
2. See “Brief table of ZEN's skills.pdf”
Key in FightingICE
“Brief table of GARNET's skills.pdf”
33. Step 1 Declare Global Variables & Initialization
Key inputKey;// Key class for return.
Random rnd;// is used for getting a random number.
private FrameData frameData;
private CommandCenter commandCenter;
private boolean player;
private Action[] actionAir;
private Action[] actionGround;
34. @Override
public int initialize(GameData gameData, boolean player) {
inputKey = new Key();
rnd = new Random();
frameData = new FrameData();
commandCenter = new CommandCenter();
actionAir = new Action[] { Action.AIR_GUARD, Action.AIR_A, Action.AIR_B, Action.AIR_DA, Action.AIR_DB,
Action.AIR_FA, Action.AIR_FB, Action.AIR_UA, Action.AIR_UB, Action.AIR_D_DF_FA, Action.AIR_D_DF_FB,
Action.AIR_F_D_DFA, Action.AIR_F_D_DFB, Action.AIR_D_DB_BA, Action.AIR_D_DB_BB };
actionGround = new Action[] { Action.STAND_D_DB_BA, Action.BACK_STEP, Action.FORWARD_WALK, Action.DASH,
Action.JUMP, Action.FOR_JUMP, Action.BACK_JUMP, Action.STAND_GUARD, Action.CROUCH_GUARD, Action.THROW_A,
Action.THROW_B, Action.STAND_A, Action.STAND_B, Action.CROUCH_A, Action.CROUCH_B, Action.STAND_FA,
Action.STAND_FB, Action.CROUCH_FA, Action.CROUCH_FB, Action.STAND_D_DF_FA, Action.STAND_D_DF_FB,
Action.STAND_F_D_DFA, Action.STAND_F_D_DFB, Action.STAND_D_DB_BB };
this.player = player;
return 0;
}
Step 1 Declare Global Variables & Initialization
35. Step 2 Modify Processing
@Override
public void processing() {
if(!frameData.getEmptyFlag()){
if(frameData.getRemainingFramesNumber()>0){
if (commandCenter.getSkillFlag()) {
inputKey = commandCenter.getSkillKey();
}
else {
inputKey.empty();
commandCenter.skillCancel();
//
String cmd = "STAND";
Random rnd = new Random();
CharacterData myCharacter = frameData.getCharacter(player);
//boolean inTheAir = false; if (myCharacter.getState() == State.AIR) { inTheAir = true; }
boolean inTheAir = (myCharacter.getState() == State.AIR) ? true : false;
if(inTheAir) {
int i = rnd.nextInt(actionAir.length);
cmd = actionAir[i].name();
}
else {
int i = rnd.nextInt(actionGround.length);
cmd = actionGround[i].name();
45. Goals
1. Upgrade “BetterRandom” by considering only actions that
can be executed by the current energy on randomization
2. Get closer to the opponent when Distance > 300
int distance = frameData.getDistanceX();
System.err.println("Dist: " + distance);
if(distance > 300) {
availableAction.add(Action.DASH);
availableAction.add(Action.DASH);
availableAction.add(Action.DASH);
availableAction.add(Action.DASH);
availableAction.add(Action.FOR_JUMP);
}
Clues
46. Clues#1
How to get Energy Requirement?
private GameData gameData;
private ArrayList<MotionData> myMotion;
@Override
public int initialize(GameData gameData, boolean player) {
...
this.player = player;
this.gameData = gameData;
myMotion = gameData.getMotionData(player);
return 0;
}
for (Action a : actionAir) {
if(Math.abs( myMotion.get(Action.valueOf(a.name()).ordinal()).getAttackStartAddEnergy())
<= myCharacter.getEnergy()) {
...
}
}
Convert Action Name to character-specific Motion/Skill
50. if ((opp.getEnergy() >= 300) && ((my.getHp() - opp.getHp()) <= 300))
cc.commandCall("FOR_JUMP _B B B");
// if the opp has 300 of energy, it is dangerous, so better jump!!
// if the health difference is high we are dominating so we are fearless :)
else if (!my.getState().equals(State.AIR) && !my.getState().equals(State.DOWN)) { //if not in air
if ((distance > 150)) {
cc.commandCall("FOR_JUMP"); //If its too far, then jump to get closer fast
}
else if (energy >= 300)
cc.commandCall("STAND_D_DF_FC"); //High energy projectile
else if ((distance > 100) && (energy >= 50))
cc.commandCall("STAND_D_DB_BB"); //Perform a slide kick
else if (opp.getState().equals(State.AIR)) //if enemy on Air
cc.commandCall("STAND_F_D_DFA"); //Perform a big punch
else if (distance > 100)
cc.commandCall("6 6 6"); // Perform a quick dash to get closer
else
cc.commandCall("B"); //Perform a kick in all other cases, introduces randomness
}
else if ((distance <= 150) && (my.getState().equals(State.AIR) || my.getState().equals(State.DOWN))
&& (((gd.getStageWidth() - my.getCenterX())>=200) || (xDifference > 0))
&& ((my.getCenterX() >=200) || xDifference < 0)) { //Conditions to handle game corners
if (energy >= 5)
cc.commandCall("AIR_DB"); // Perform air down kick when in air
else
cc.commandCall("B"); //Perform a kick in all other cases, introduces randomness
}
else
cc.commandCall("B"); //Perform a kick in all other cases, introduces randomness
In processing()
51. if ((opp.getEnergy() >= 300) && ((my.getHp() - opp.getHp()) <= 300))
cc.commandCall("FOR_JUMP _B B B");
// if the opp has 300 of energy, it is dangerous, so better jump!!
// if the health difference is high we are dominating so we are fearless :)
else if (!my.getState().equals(State.AIR) && !my.getState().equals(State.DOWN)) { //if not in air
if ((distance > 150)) {
cc.commandCall("FOR_JUMP"); //If its too far, then jump to get closer fast
}
else if (energy >= 300)
cc.commandCall("STAND_D_DF_FC"); //High energy projectile
else if ((distance > 100) && (energy >= 50))
cc.commandCall("STAND_D_DB_BB"); //Perform a slide kick
else if (opp.getState().equals(State.AIR)) //if enemy on Air
cc.commandCall("STAND_F_D_DFA"); //Perform a big punch
else if (distance > 100)
cc.commandCall("6 6 6"); // Perform a quick dash to get closer
else
cc.commandCall("B"); //Perform a kick in all other cases, introduces randomness
}
else if ((distance <= 150) && (my.getState().equals(State.AIR) || my.getState().equals(State.DOWN))
&& (((gd.getStageWidth() - my.getCenterX())>=200) || (xDifference > 0))
&& ((my.getCenterX() >=200) || xDifference < 0)) { //Conditions to handle game corners
if (energy >= 5)
cc.commandCall("AIR_DB"); // Perform air down kick when in air
else
cc.commandCall("B"); //Perform a kick in all other cases, introduces randomness
}
else
cc.commandCall("B"); //Perform a kick in all other cases, introduces randomness
In processing()
52. if ((opp.getEnergy() >= 300) && ((my.getHp() - opp.getHp()) <= 300))
cc.commandCall("FOR_JUMP _B B B");
// if the opp has 300 of energy, it is dangerous, so better jump!!
// if the health difference is high we are dominating so we are fearless :)
else if (!my.getState().equals(State.AIR) && !my.getState().equals(State.DOWN)) { //if not in air
if ((distance > 150)) {
cc.commandCall("FOR_JUMP"); //If its too far, then jump to get closer fast
}
else if (energy >= 300)
cc.commandCall("STAND_D_DF_FC"); //High energy projectile
else if ((distance > 100) && (energy >= 50))
cc.commandCall("STAND_D_DB_BB"); //Perform a slide kick
else if (opp.getState().equals(State.AIR)) //if enemy on Air
cc.commandCall("STAND_F_D_DFA"); //Perform a big punch
else if (distance > 100)
cc.commandCall("6 6 6"); // Perform a quick dash to get closer
else
cc.commandCall("B"); //Perform a kick in all other cases, introduces randomness
}
else if ((distance <= 150) && (my.getState().equals(State.AIR) || my.getState().equals(State.DOWN))
&& (((gd.getStageWidth() - my.getCenterX())>=200) || (xDifference > 0))
&& ((my.getCenterX() >=200) || xDifference < 0)) { //Conditions to handle game corners
if (energy >= 5)
cc.commandCall("AIR_DB"); // Perform air down kick when in air
else
cc.commandCall("B"); //Perform a kick in all other cases, introduces randomness
}
else
cc.commandCall("B"); //Perform a kick in all other cases, introduces randomness
In processing()
53. if ((opp.getEnergy() >= 300) && ((my.getHp() - opp.getHp()) <= 300))
cc.commandCall("FOR_JUMP _B B B");
// if the opp has 300 of energy, it is dangerous, so better jump!!
// if the health difference is high we are dominating so we are fearless :)
else if (!my.getState().equals(State.AIR) && !my.getState().equals(State.DOWN)) { //if not in air
if ((distance > 150)) {
cc.commandCall("FOR_JUMP"); //If its too far, then jump to get closer fast
}
else if (energy >= 300)
cc.commandCall("STAND_D_DF_FC"); //High energy projectile
else if ((distance > 100) && (energy >= 50))
cc.commandCall("STAND_D_DB_BB"); //Perform a slide kick
else if (opp.getState().equals(State.AIR)) //if enemy on Air
cc.commandCall("STAND_F_D_DFA"); //Perform a big punch
else if (distance > 100)
cc.commandCall("6 6 6"); // Perform a quick dash to get closer
else
cc.commandCall("B"); //Perform a kick in all other cases, introduces randomness
}
else if ((distance <= 150) && (my.getState().equals(State.AIR) || my.getState().equals(State.DOWN))
&& (((gd.getStageWidth() - my.getCenterX())>=200) || (xDifference > 0))
&& ((my.getCenterX() >=200) || xDifference < 0)) { //Conditions to handle game corners
if (energy >= 5)
cc.commandCall("AIR_DB"); // Perform air down kick when in air
else
cc.commandCall("B"); //Perform a kick in all other cases, introduces randomness
}
else
cc.commandCall("B"); //Perform a kick in all other cases, introduces randomness
Tips