RLPark 1.0.0
Reinforcement Learning Framework in Java
|
00001 package rlpark.plugin.rltoys.problems.counting; 00002 00003 import rlpark.plugin.rltoys.math.vector.implementations.BVector; 00004 import zephyr.plugin.core.api.monitoring.annotations.Monitor; 00005 00006 @Monitor 00007 public class CountingProblem { 00008 private final int[] inputState; 00009 private final int[] targetStates; 00010 private final BVector input; 00011 00012 public CountingProblem(int nbInputs, int nbTargets) { 00013 inputState = new int[nbInputs]; 00014 targetStates = new int[nbTargets]; 00015 input = new BVector(nbInputs); 00016 } 00017 00018 public BVector updateInput() { 00019 input.clear(); 00020 for (int i = 0; i < inputState.length; i++) { 00021 if (inputState[i] == 0) 00022 input.setOn(i); 00023 inputState[i] = (inputState[i] + 1) % (i + 2); 00024 } 00025 return input; 00026 } 00027 00028 public int[] targets() { 00029 int[] result = targetStates.clone(); 00030 for (int i = 0; i < targetStates.length; i++) 00031 targetStates[i] = (targetStates[i] + 1) % (2 + i); 00032 return result; 00033 } 00034 }