adopt MVC pattern and add real time graph interface
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package example;
|
||||
|
||||
import core.RNG;
|
||||
import core.algo.Method;
|
||||
import core.controller.RLController;
|
||||
import evironment.antGame.AntAction;
|
||||
import evironment.antGame.AntWorld;
|
||||
|
||||
public class RunningAnt {
|
||||
public static void main(String[] args) {
|
||||
RNG.setSeed(1234);
|
||||
|
||||
RLController<AntAction> rl = new RLController<AntAction>()
|
||||
.setEnvironment(new AntWorld(3,3,0.1))
|
||||
.setAllowedActions(AntAction.values())
|
||||
.setMethod(Method.MC_ONPOLICY_EGREEDY)
|
||||
.setDelay(10)
|
||||
.setEpisodes(1000);
|
||||
rl.start();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package example;
|
||||
|
||||
public class Test {
|
||||
interface Drawable{
|
||||
void draw();
|
||||
}
|
||||
interface State{
|
||||
int getInt();
|
||||
}
|
||||
|
||||
static class A implements Drawable, State{
|
||||
private int k;
|
||||
public A(int a){
|
||||
k = a;
|
||||
}
|
||||
@Override
|
||||
public void draw() {
|
||||
System.out.println("draw " + k);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt() {
|
||||
System.out.println("getInt" + k);
|
||||
return k;
|
||||
}
|
||||
}
|
||||
|
||||
static class B implements State{
|
||||
@Override
|
||||
public int getInt() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
State state = new A(24);
|
||||
State state2 = new B();
|
||||
state.getInt();
|
||||
|
||||
System.out.println(state2 instanceof Drawable);
|
||||
drawState(state2);
|
||||
}
|
||||
|
||||
static void drawState(State s){
|
||||
if(s instanceof Drawable){
|
||||
Drawable d = (Drawable) s;
|
||||
d.draw();
|
||||
}else{
|
||||
System.out.println("invalid");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user