SlideShare a Scribd company logo
1 of 60
FightingICE AI Coding
PUJANA P.
To Run AI Step 1 Export JAR
MUST use the same name
To Run AI Step 2 Put JAR to the game folder
AI00: Null
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
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
AI01: Random
Randomly Press Keys
Final Code For Copy-Paste
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;
}
Step 2 Modify Processing
@Override
public Key input() {
return inputKey;
//return null;
}
@Override
public void processing() {
// every key is set randomly.
inputKey.A = (rnd.nextInt(10) > 4) ? true : false;
inputKey.B = (rnd.nextInt(10) > 4) ? true : false;
inputKey.C = (rnd.nextInt(10) > 4) ? true : false;
inputKey.U = (rnd.nextInt(10) > 4) ? true : false;
inputKey.D = (rnd.nextInt(10) > 4) ? true : false;
inputKey.L = (rnd.nextInt(10) > 4) ? true : false;
inputKey.R = (rnd.nextInt(10) > 4) ? true : false;
}
0 - 9
More Details
Press keys in FightingICE
U
D RL
A B C
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”
More Details
D DF F A
AI02: Copy
Copy Opponent Skills
Final Code For Copy-Paste
Step 1 Declare Global Variables & Initialization
private Key inputKey;
private boolean player;
private FrameData frameData;
private CommandCenter commandCenter;
@Override
public int initialize(GameData arg0, boolean player) {
inputKey = new Key();
this.player = player;
frameData = new FrameData();
this.commandCenter = new CommandCenter();
return 0;
}
Step 2 Modify Other Part
@Override
public void getInformation(FrameData frameData) {
this.frameData = frameData;
this.commandCenter.setFrameData(this.frameData, player);
}
@Override
public Key input() {
//return null;
return inputKey;
}
Be careful
http://www.ice.ci.ritsumei.ac.jp/~ftgaic/ATKdoc/str
uct/FrameData.html
Step 3 Modify Processing
@Override
public void processing() {
if(!frameData.getEmptyFlag()){
if(frameData.getRemainingFramesNumber()>0){
if (commandCenter.getSkillFlag()) {
inputKey = commandCenter.getSkillKey();
} else {
inputKey.empty();
commandCenter.skillCancel();
commandCenter.commandCall(frameData.getCharacter(!player).getAction().name());
}
}
}
}
Code Investigation
NEED
#1
AI is P2
#1
Name of the Skill being execute by the opponent will be printed
Code Investigation
Nothing Happen: inputKey is not set
#2
Code Investigation
#3
#3
Code Investigation
#4
Code Investigation
#5
3600-nowFrame
For intrinsic problem:
“we don't want ai to process during round-round” (?)
Summary
private Key inputKey;
private boolean player;
private FrameData frameData;
private CommandCenter commandCenter;
@Override
public int initialize(GameData arg0, boolean player) {
inputKey = new Key();
this.player = player;
frameData = new FrameData();
commandCenter = new CommandCenter();
return 0;
}
@Override
public void getInformation(FrameData frameData) {
this.frameData = frameData;
this.commandCenter.setFrameData(this.frameData, player);
}
@Override
public Key input() {
return inputKey;
}
@Override
public void processing() {
if(!frameData.getEmptyFlag()){
if(frameData.getRemainingFramesNumber()>0){
//CODE HERE
}
Rule-of-Thumb
Coding of most AI can start from
this rule-of-thumb template
AI As01: Rand n Rule
Random+RuleBased
Template
Rule-of-Thumb
Copy and Complete it based on clues
Goals
1. Random Action
2. Use the Projectile Attack
“STAND_DF_FA” when Energy > 50
Clues
???.getEnergy()
commandCenter.commandCall("STAND_D_DF_FA");
OR
commandCenter.commandCall(Action.STAND_D_DF_FA.name());
1
2
AI03: BetterRandom
Random Skills
Final Code For Copy-Paste
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;
@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
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();
Code Investigation#1
Code Investigation#2
Code Investigation#3
AI As02:
BetterRandom2
Random Skills considering Energy
Template For Copy-Paste
Goal
1. Upgrade “BetterRandom” by considering only actions that
can be executed by the current energy on randomization
Clues#1
actionGround[i].name();
actionGround[i].energy();
get “STAND_D_DF_FA”
ERROR, you cannot get 30
How to get Energy Requirement?
Different Character uses different amount of
energy for each Action
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
AI As03:
BetterRandom3
Random Skills considering Energy + Distance
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
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
AI04: Machate
BetterRandom3 (P1) vs Machate (P2)
Champion of 2015
Final Code For Copy-Paste
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()
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()
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()
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
AI05: Switch
Final Code For Copy-Paste
1. Copy-Paste, export JAR
2. Test
3. Create “dataaiDataSwitchsignal.txt”
Put 1 as value
4. Test again
@Override
public void processing() {
if (!frameData.getEmptyFlag()) {
if (frameData.getRemainingFramesNumber() > 0) {
if (switchFlag) {
randomProcessing();
} else {
copyProcessing();
}
}
}
}
Step 1 Use of Switch
@Override
public int initialize(GameData gameData, boolean playerNumber) {
...
file = new File("data/aiData/Switch/signal.txt");
if(!file.exists()){
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
try {
br = new BufferedReader(new FileReader(file));
String line = br.readLine();
System.out.println("signal:" + line);
if (line.equals("1"))
switchFlag = true;
else
switchFlag = false;
br.close();
} catch (IOException e) {
Step 2 Read Switch
2
1
public void close() {
try {
System.out.println("myScore:" + myScore);
System.out.println("opScore:" + opponentScore);
if (myScore < opponentScore) {
System.out.println("lose");
pw = new PrintWriter(new BufferedWriter(new FileWriter(file)));
if (switchFlag) {
pw.println("0");
} else {
pw.println("1");
}
pw.close();
} else {
System.out.println("win");
}
} catch (IOException e) {
e.printStackTrace();
}
}
Step 3 Write Switch
AI As04:
???
(build any AI that beats Machate)
Goals
1. Build an AI that beats Machate (set Machete P2)
2. There will be a competition to find the strongest AI.

More Related Content

What's hot

The Ring programming language version 1.4 book - Part 21 of 30
The Ring programming language version 1.4 book - Part 21 of 30The Ring programming language version 1.4 book - Part 21 of 30
The Ring programming language version 1.4 book - Part 21 of 30Mahmoud Samir Fayed
 
code for quiz in my sql
code for quiz  in my sql code for quiz  in my sql
code for quiz in my sql JOYITAKUNDU1
 
The Ring programming language version 1.5.4 book - Part 48 of 185
The Ring programming language version 1.5.4 book - Part 48 of 185The Ring programming language version 1.5.4 book - Part 48 of 185
The Ring programming language version 1.5.4 book - Part 48 of 185Mahmoud Samir Fayed
 
Formal Verification of Transactional Interaction Contract
Formal Verification of Transactional Interaction ContractFormal Verification of Transactional Interaction Contract
Formal Verification of Transactional Interaction ContractGera Shegalov
 
Testing a 2D Platformer with Spock
Testing a 2D Platformer with SpockTesting a 2D Platformer with Spock
Testing a 2D Platformer with SpockAlexander Tarlinder
 
Connecting your phone and home with firebase and android things - James Cogga...
Connecting your phone and home with firebase and android things - James Cogga...Connecting your phone and home with firebase and android things - James Cogga...
Connecting your phone and home with firebase and android things - James Cogga...DroidConTLV
 
The Ring programming language version 1.3 book - Part 85 of 88
The Ring programming language version 1.3 book - Part 85 of 88The Ring programming language version 1.3 book - Part 85 of 88
The Ring programming language version 1.3 book - Part 85 of 88Mahmoud Samir Fayed
 
생산적인 개발을 위한 지속적인 테스트
생산적인 개발을 위한 지속적인 테스트생산적인 개발을 위한 지속적인 테스트
생산적인 개발을 위한 지속적인 테스트기룡 남
 
AST: threats and opportunities
AST: threats and opportunitiesAST: threats and opportunities
AST: threats and opportunitiesAlexander Lifanov
 
PostgreSQL Open SV 2018
PostgreSQL Open SV 2018PostgreSQL Open SV 2018
PostgreSQL Open SV 2018artgillespie
 
Building a turn-based game prototype using ECS - Unite Copenhagen 2019
Building a turn-based game prototype using ECS - Unite Copenhagen 2019Building a turn-based game prototype using ECS - Unite Copenhagen 2019
Building a turn-based game prototype using ECS - Unite Copenhagen 2019Unity Technologies
 
The Ring programming language version 1.7 book - Part 63 of 196
The Ring programming language version 1.7 book - Part 63 of 196The Ring programming language version 1.7 book - Part 63 of 196
The Ring programming language version 1.7 book - Part 63 of 196Mahmoud Samir Fayed
 
Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6fisher.w.y
 
How fast is it really? Benchmarking in Practice (Ruby Version)
How fast is it really? Benchmarking in Practice (Ruby Version)How fast is it really? Benchmarking in Practice (Ruby Version)
How fast is it really? Benchmarking in Practice (Ruby Version)Tobias Pfeiffer
 
Stop Guessing and Start Measuring - Benchmarking Practice (Poly Version)
 Stop Guessing and Start Measuring - Benchmarking Practice (Poly Version) Stop Guessing and Start Measuring - Benchmarking Practice (Poly Version)
Stop Guessing and Start Measuring - Benchmarking Practice (Poly Version)Tobias Pfeiffer
 
The Ring programming language version 1.5.4 book - Part 65 of 185
The Ring programming language version 1.5.4 book - Part 65 of 185The Ring programming language version 1.5.4 book - Part 65 of 185
The Ring programming language version 1.5.4 book - Part 65 of 185Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 55 of 84
The Ring programming language version 1.2 book - Part 55 of 84The Ring programming language version 1.2 book - Part 55 of 84
The Ring programming language version 1.2 book - Part 55 of 84Mahmoud Samir Fayed
 

What's hot (20)

The Ring programming language version 1.4 book - Part 21 of 30
The Ring programming language version 1.4 book - Part 21 of 30The Ring programming language version 1.4 book - Part 21 of 30
The Ring programming language version 1.4 book - Part 21 of 30
 
code for quiz in my sql
code for quiz  in my sql code for quiz  in my sql
code for quiz in my sql
 
The Ring programming language version 1.5.4 book - Part 48 of 185
The Ring programming language version 1.5.4 book - Part 48 of 185The Ring programming language version 1.5.4 book - Part 48 of 185
The Ring programming language version 1.5.4 book - Part 48 of 185
 
Formal Verification of Transactional Interaction Contract
Formal Verification of Transactional Interaction ContractFormal Verification of Transactional Interaction Contract
Formal Verification of Transactional Interaction Contract
 
Testing a 2D Platformer with Spock
Testing a 2D Platformer with SpockTesting a 2D Platformer with Spock
Testing a 2D Platformer with Spock
 
Connecting your phone and home with firebase and android things - James Cogga...
Connecting your phone and home with firebase and android things - James Cogga...Connecting your phone and home with firebase and android things - James Cogga...
Connecting your phone and home with firebase and android things - James Cogga...
 
The Ring programming language version 1.3 book - Part 85 of 88
The Ring programming language version 1.3 book - Part 85 of 88The Ring programming language version 1.3 book - Part 85 of 88
The Ring programming language version 1.3 book - Part 85 of 88
 
생산적인 개발을 위한 지속적인 테스트
생산적인 개발을 위한 지속적인 테스트생산적인 개발을 위한 지속적인 테스트
생산적인 개발을 위한 지속적인 테스트
 
AST: threats and opportunities
AST: threats and opportunitiesAST: threats and opportunities
AST: threats and opportunities
 
PostgreSQL Open SV 2018
PostgreSQL Open SV 2018PostgreSQL Open SV 2018
PostgreSQL Open SV 2018
 
Building a turn-based game prototype using ECS - Unite Copenhagen 2019
Building a turn-based game prototype using ECS - Unite Copenhagen 2019Building a turn-based game prototype using ECS - Unite Copenhagen 2019
Building a turn-based game prototype using ECS - Unite Copenhagen 2019
 
libGDX: Scene2D
libGDX: Scene2DlibGDX: Scene2D
libGDX: Scene2D
 
The Ring programming language version 1.7 book - Part 63 of 196
The Ring programming language version 1.7 book - Part 63 of 196The Ring programming language version 1.7 book - Part 63 of 196
The Ring programming language version 1.7 book - Part 63 of 196
 
Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6
 
How fast is it really? Benchmarking in Practice (Ruby Version)
How fast is it really? Benchmarking in Practice (Ruby Version)How fast is it really? Benchmarking in Practice (Ruby Version)
How fast is it really? Benchmarking in Practice (Ruby Version)
 
Stop Guessing and Start Measuring - Benchmarking Practice (Poly Version)
 Stop Guessing and Start Measuring - Benchmarking Practice (Poly Version) Stop Guessing and Start Measuring - Benchmarking Practice (Poly Version)
Stop Guessing and Start Measuring - Benchmarking Practice (Poly Version)
 
2013 2-5
2013 2-52013 2-5
2013 2-5
 
The Ring programming language version 1.5.4 book - Part 65 of 185
The Ring programming language version 1.5.4 book - Part 65 of 185The Ring programming language version 1.5.4 book - Part 65 of 185
The Ring programming language version 1.5.4 book - Part 65 of 185
 
libGDX: User Input
libGDX: User InputlibGDX: User Input
libGDX: User Input
 
The Ring programming language version 1.2 book - Part 55 of 84
The Ring programming language version 1.2 book - Part 55 of 84The Ring programming language version 1.2 book - Part 55 of 84
The Ring programming language version 1.2 book - Part 55 of 84
 

Similar to Games, AI, and Research - Part 2 Training (FightingICE AI Programming)

This is Java,I am currently stumped on how to add a scoreboard for.pdf
This is Java,I am currently stumped on how to add a scoreboard for.pdfThis is Java,I am currently stumped on how to add a scoreboard for.pdf
This is Java,I am currently stumped on how to add a scoreboard for.pdfanjandavid
 
Here are the instructions and then the code in a sec. Please R.pdf
Here are the instructions and then the code in a sec. Please R.pdfHere are the instructions and then the code in a sec. Please R.pdf
Here are the instructions and then the code in a sec. Please R.pdfaggarwalshoppe14
 
Ifgqueue.h#ifndef LFGQUEUE_H #define LFGQUEUE_H#include pl.pdf
Ifgqueue.h#ifndef LFGQUEUE_H #define LFGQUEUE_H#include pl.pdfIfgqueue.h#ifndef LFGQUEUE_H #define LFGQUEUE_H#include pl.pdf
Ifgqueue.h#ifndef LFGQUEUE_H #define LFGQUEUE_H#include pl.pdffazilfootsteps
 
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdfWorking with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdfudit652068
 
De CRUD à DDD pas à pas
De CRUD à DDD pas à pasDe CRUD à DDD pas à pas
De CRUD à DDD pas à pasCharles Desneuf
 
public interface Game Note interface in place of class { .pdf
public interface Game  Note interface in place of class { .pdfpublic interface Game  Note interface in place of class { .pdf
public interface Game Note interface in place of class { .pdfkavithaarp
 
package com.tictactoe; public class Main {public void play() {.pdf
package com.tictactoe; public class Main {public void play() {.pdfpackage com.tictactoe; public class Main {public void play() {.pdf
package com.tictactoe; public class Main {public void play() {.pdfinfo430661
 
groovy databases
groovy databasesgroovy databases
groovy databasesPaul King
 
I really need some help if I have this right so far. PLEASE CHANG.pdf
I really need some help if I have this right so far. PLEASE CHANG.pdfI really need some help if I have this right so far. PLEASE CHANG.pdf
I really need some help if I have this right so far. PLEASE CHANG.pdfaggarwalshoppe14
 
とある断片の超動的言語
とある断片の超動的言語とある断片の超動的言語
とある断片の超動的言語Kiyotaka Oku
 
I really need some help if I have this right so far. Please Resub.pdf
I really need some help if I have this right so far. Please Resub.pdfI really need some help if I have this right so far. Please Resub.pdf
I really need some help if I have this right so far. Please Resub.pdfaggarwalshoppe14
 
Quest 1 define a class batsman with the following specifications
Quest  1 define a class batsman with the following specificationsQuest  1 define a class batsman with the following specifications
Quest 1 define a class batsman with the following specificationsrajkumari873
 
VideoGamepublic class VideoGam.pdf
VideoGamepublic class VideoGam.pdfVideoGamepublic class VideoGam.pdf
VideoGamepublic class VideoGam.pdfannaistrvlr
 
I dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdfI dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdfarchanaemporium
 
The main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdfThe main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdfasif1401
 
in this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdfin this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdfmichardsonkhaicarr37
 
Modular games in Unity / Paweł Krakowiak (Rage Quit Games)
Modular games in Unity / Paweł Krakowiak (Rage Quit Games)Modular games in Unity / Paweł Krakowiak (Rage Quit Games)
Modular games in Unity / Paweł Krakowiak (Rage Quit Games)DevGAMM Conference
 
Developing RESTful Services in .NET
Developing RESTful Services in .NETDeveloping RESTful Services in .NET
Developing RESTful Services in .NETRobert MacLean
 

Similar to Games, AI, and Research - Part 2 Training (FightingICE AI Programming) (20)

This is Java,I am currently stumped on how to add a scoreboard for.pdf
This is Java,I am currently stumped on how to add a scoreboard for.pdfThis is Java,I am currently stumped on how to add a scoreboard for.pdf
This is Java,I am currently stumped on how to add a scoreboard for.pdf
 
Here are the instructions and then the code in a sec. Please R.pdf
Here are the instructions and then the code in a sec. Please R.pdfHere are the instructions and then the code in a sec. Please R.pdf
Here are the instructions and then the code in a sec. Please R.pdf
 
Ifgqueue.h#ifndef LFGQUEUE_H #define LFGQUEUE_H#include pl.pdf
Ifgqueue.h#ifndef LFGQUEUE_H #define LFGQUEUE_H#include pl.pdfIfgqueue.h#ifndef LFGQUEUE_H #define LFGQUEUE_H#include pl.pdf
Ifgqueue.h#ifndef LFGQUEUE_H #define LFGQUEUE_H#include pl.pdf
 
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdfWorking with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
 
De CRUD à DDD pas à pas
De CRUD à DDD pas à pasDe CRUD à DDD pas à pas
De CRUD à DDD pas à pas
 
Flappy bird
Flappy birdFlappy bird
Flappy bird
 
Android workshop
Android workshopAndroid workshop
Android workshop
 
public interface Game Note interface in place of class { .pdf
public interface Game  Note interface in place of class { .pdfpublic interface Game  Note interface in place of class { .pdf
public interface Game Note interface in place of class { .pdf
 
package com.tictactoe; public class Main {public void play() {.pdf
package com.tictactoe; public class Main {public void play() {.pdfpackage com.tictactoe; public class Main {public void play() {.pdf
package com.tictactoe; public class Main {public void play() {.pdf
 
groovy databases
groovy databasesgroovy databases
groovy databases
 
I really need some help if I have this right so far. PLEASE CHANG.pdf
I really need some help if I have this right so far. PLEASE CHANG.pdfI really need some help if I have this right so far. PLEASE CHANG.pdf
I really need some help if I have this right so far. PLEASE CHANG.pdf
 
とある断片の超動的言語
とある断片の超動的言語とある断片の超動的言語
とある断片の超動的言語
 
I really need some help if I have this right so far. Please Resub.pdf
I really need some help if I have this right so far. Please Resub.pdfI really need some help if I have this right so far. Please Resub.pdf
I really need some help if I have this right so far. Please Resub.pdf
 
Quest 1 define a class batsman with the following specifications
Quest  1 define a class batsman with the following specificationsQuest  1 define a class batsman with the following specifications
Quest 1 define a class batsman with the following specifications
 
VideoGamepublic class VideoGam.pdf
VideoGamepublic class VideoGam.pdfVideoGamepublic class VideoGam.pdf
VideoGamepublic class VideoGam.pdf
 
I dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdfI dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdf
 
The main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdfThe main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdf
 
in this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdfin this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdf
 
Modular games in Unity / Paweł Krakowiak (Rage Quit Games)
Modular games in Unity / Paweł Krakowiak (Rage Quit Games)Modular games in Unity / Paweł Krakowiak (Rage Quit Games)
Modular games in Unity / Paweł Krakowiak (Rage Quit Games)
 
Developing RESTful Services in .NET
Developing RESTful Services in .NETDeveloping RESTful Services in .NET
Developing RESTful Services in .NET
 

Recently uploaded

SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 

Recently uploaded (20)

SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 

Games, AI, and Research - Part 2 Training (FightingICE AI Programming)

  • 2. To Run AI Step 1 Export JAR MUST use the same name
  • 3. To Run AI Step 2 Put JAR to the game folder
  • 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
  • 8. Final Code For Copy-Paste
  • 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; }
  • 10. Step 2 Modify Processing @Override public Key input() { return inputKey; //return null; } @Override public void processing() { // every key is set randomly. inputKey.A = (rnd.nextInt(10) > 4) ? true : false; inputKey.B = (rnd.nextInt(10) > 4) ? true : false; inputKey.C = (rnd.nextInt(10) > 4) ? true : false; inputKey.U = (rnd.nextInt(10) > 4) ? true : false; inputKey.D = (rnd.nextInt(10) > 4) ? true : false; inputKey.L = (rnd.nextInt(10) > 4) ? true : false; inputKey.R = (rnd.nextInt(10) > 4) ? true : false; } 0 - 9
  • 11. More Details Press keys in FightingICE U D RL A B C
  • 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”
  • 15. Final Code For Copy-Paste
  • 16. Step 1 Declare Global Variables & Initialization private Key inputKey; private boolean player; private FrameData frameData; private CommandCenter commandCenter; @Override public int initialize(GameData arg0, boolean player) { inputKey = new Key(); this.player = player; frameData = new FrameData(); this.commandCenter = new CommandCenter(); return 0; }
  • 17. Step 2 Modify Other Part @Override public void getInformation(FrameData frameData) { this.frameData = frameData; this.commandCenter.setFrameData(this.frameData, player); } @Override public Key input() { //return null; return inputKey; } Be careful http://www.ice.ci.ritsumei.ac.jp/~ftgaic/ATKdoc/str uct/FrameData.html
  • 18. Step 3 Modify Processing @Override public void processing() { if(!frameData.getEmptyFlag()){ if(frameData.getRemainingFramesNumber()>0){ if (commandCenter.getSkillFlag()) { inputKey = commandCenter.getSkillKey(); } else { inputKey.empty(); commandCenter.skillCancel(); commandCenter.commandCall(frameData.getCharacter(!player).getAction().name()); } } } }
  • 20. AI is P2 #1 Name of the Skill being execute by the opponent will be printed
  • 21. Code Investigation Nothing Happen: inputKey is not set #2
  • 23. #3
  • 25. Code Investigation #5 3600-nowFrame For intrinsic problem: “we don't want ai to process during round-round” (?)
  • 26. Summary private Key inputKey; private boolean player; private FrameData frameData; private CommandCenter commandCenter; @Override public int initialize(GameData arg0, boolean player) { inputKey = new Key(); this.player = player; frameData = new FrameData(); commandCenter = new CommandCenter(); return 0; } @Override public void getInformation(FrameData frameData) { this.frameData = frameData; this.commandCenter.setFrameData(this.frameData, player); } @Override public Key input() { return inputKey; } @Override public void processing() { if(!frameData.getEmptyFlag()){ if(frameData.getRemainingFramesNumber()>0){ //CODE HERE } Rule-of-Thumb Coding of most AI can start from this rule-of-thumb template
  • 27. AI As01: Rand n Rule Random+RuleBased
  • 29. Goals 1. Random Action 2. Use the Projectile Attack “STAND_DF_FA” when Energy > 50
  • 32. Final Code For Copy-Paste
  • 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();
  • 41. Goal 1. Upgrade “BetterRandom” by considering only actions that can be executed by the current energy on randomization
  • 42. Clues#1 actionGround[i].name(); actionGround[i].energy(); get “STAND_D_DF_FA” ERROR, you cannot get 30 How to get Energy Requirement? Different Character uses different amount of energy for each Action
  • 43. 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
  • 44. AI As03: BetterRandom3 Random Skills considering Energy + Distance
  • 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
  • 48. BetterRandom3 (P1) vs Machate (P2) Champion of 2015
  • 49. Final Code For Copy-Paste
  • 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
  • 55. Final Code For Copy-Paste 1. Copy-Paste, export JAR 2. Test 3. Create “dataaiDataSwitchsignal.txt” Put 1 as value 4. Test again
  • 56. @Override public void processing() { if (!frameData.getEmptyFlag()) { if (frameData.getRemainingFramesNumber() > 0) { if (switchFlag) { randomProcessing(); } else { copyProcessing(); } } } } Step 1 Use of Switch
  • 57. @Override public int initialize(GameData gameData, boolean playerNumber) { ... file = new File("data/aiData/Switch/signal.txt"); if(!file.exists()){ try { file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } try { br = new BufferedReader(new FileReader(file)); String line = br.readLine(); System.out.println("signal:" + line); if (line.equals("1")) switchFlag = true; else switchFlag = false; br.close(); } catch (IOException e) { Step 2 Read Switch 2 1
  • 58. public void close() { try { System.out.println("myScore:" + myScore); System.out.println("opScore:" + opponentScore); if (myScore < opponentScore) { System.out.println("lose"); pw = new PrintWriter(new BufferedWriter(new FileWriter(file))); if (switchFlag) { pw.println("0"); } else { pw.println("1"); } pw.close(); } else { System.out.println("win"); } } catch (IOException e) { e.printStackTrace(); } } Step 3 Write Switch
  • 59. AI As04: ??? (build any AI that beats Machate)
  • 60. Goals 1. Build an AI that beats Machate (set Machete P2) 2. There will be a competition to find the strongest AI.