RLPark 1.0.0
Reinforcement Learning Framework in Java

RobotBehaviour.java

Go to the documentation of this file.
00001 package rlpark.example.irobot.surprise;
00002 
00003 import java.util.Random;
00004 
00005 import rlpark.plugin.rltoys.envio.actions.Action;
00006 import rlpark.plugin.rltoys.envio.policy.Policy;
00007 import rlpark.plugin.rltoys.math.vector.RealVector;
00008 import rlpark.plugin.rltoys.utils.NotImplemented;
00009 import rlpark.plugin.rltoys.utils.Utils;
00010 import zephyr.plugin.core.api.synchronization.Chrono;
00011 
00012 public class RobotBehaviour implements Policy {
00013   private static final long serialVersionUID = -6590692682863168325L;
00014   private final Chrono chrono = new Chrono();
00015   private final Action[] actions;
00016   private final double actionDuration;
00017   private Action currentAction = null;
00018   private final Random random;
00019 
00020   public RobotBehaviour(Random random, double time, Action[] actions) {
00021     this.random = random;
00022     this.actionDuration = time;
00023     this.actions = actions;
00024   }
00025 
00026   @Override
00027   public double pi(Action a) {
00028     throw new NotImplemented();
00029   }
00030 
00031   @Override
00032   public Action sampleAction() {
00033     if (currentAction != null && chrono.getCurrentChrono() < actionDuration)
00034       return currentAction;
00035     currentAction = Utils.choose(random, actions);
00036     chrono.start();
00037     return currentAction;
00038   }
00039 
00040   @Override
00041   public void update(RealVector x) {
00042   }
00043 }
 All Classes Namespaces Files Functions Variables Enumerations
Zephyr
RLPark