I'm taking a tutorial on building a simple behavior Ai. It's 'brain' class is abstract and contains states as in "running","success","failure". Now in the my ai unit - droid class i have a method to start the droid up
public void update(){
if(Routine.getState()==null){
Routine.start();
}
Routine.act(this, board);
}
Eclipse tells me that the methods from Routine are not valid because:
Cannot make a static reference to the non-static method getState() from the type Routine
Which i can do for getState but i have to change the RoutineState into static as well, but i can't do for start or act as they containt this.
This is the brain of the ai so far:
public abstract class Routine {
public enum RoutineState{
Success,
Failure,
Running
}
public RoutineState getState(){
return state;
}
protected RoutineState state;
protected Routine() { }
public void start(){
this.state = RoutineState.Running;
}
public abstract void reset();
public abstract void act(droid droid, board board);
public void succed(){
this.state = RoutineState.Success;
}
public void Fail(){
this.state = RoutineState.Failure;
}
public boolean isSuccess(){
return state.equals(RoutineState.Success);
}
public boolean isFailure(){
return state.equals(RoutineState.Failure);
}
public boolean isRunning(){
return state.equals(RoutineState.Running);
}
}