Learn

Sunday, 3 December 2017

How Does OldBlockState Is Used In JAVA Artificial Intelligence Algorithm Progrmming


Use of OldBlockState:


The next POJO class OldBlockState is used to represent previous states of blocks as they are being moved as the rules in this example “fire.” We will later see rules that will not put a block into a state that it previously existed in:

public static class OldBlockState extends Block {

public OldBlockState(String name,
String onTopOf,

String supporting) {

super(name, onTopOf, supporting);

}

public String toString() {

return "[OldBlockState_" + this.hashCode() +" " + name + " on top of: " + onTopOf +" supporting: " + supporting+"]";


}


}


The next POJO class Goal is used to represent a goal state for the blocks that we are trying to reach:


public static class Goal {
private String supportingBlock;
private String supportedBlock;
public Goal(String supporting, String supported) {
this.supportingBlock = supporting;
this.supportedBlock = supported;
}
public String toString() {
return "[Goal_" + this.hashCode() +
" Goal: supporting block: " +
supportingBlock +
" and supported block: " +
supportedBlock +"]";
}
public void setSupportingBlock(
String supportingBlock) {
this.supportingBlock = supportingBlock;
}
public String getSupportingBlock() {
return supportingBlock;
}
public void setSupportedBlock(
String supportedBlock) {
this.supportedBlock = supportedBlock;
}
public String getSupportedBlock() {
return supportedBlock;
}
}

How to Run JAVA POJO Object Models for Blocks World Example Artificial Intelligence Programming



POJO Object Models for Blocks World Example:

We will use the following three POJO classes (defined in the file DroolsBock- World.java as static inner classes). The first POJO class Block represents the state of one block:


public static class Block {

protected String name;
protected String onTopOf;
protected String supporting;

public Block(String name, String onTopOf, String supporting) {

this.name = name;
this.onTopOf = onTopOf;
this.supporting = supporting;

}

public String toString() {

return "[Block_" + this.hashCode() + " " +
name + " on top of: " + onTopOf +
" supporting: " + supporting+"]";

}

public String getName() {

return this.name;

}

public void setName(String name) {

this.name = name;

}

public String getOnTopOf() {

return this.onTopOf;

}

public void setOnTopOf(String onTopOf) {

this.onTopOf = onTopOf;

}

public String getSupporting() {

return this.supporting;

}

public void setSupporting(String supporting) {

this.supporting = supporting;

}
}