add dino jumping environment, deterministic/reproducable behaviour and save-and-load feature
- add feature to save and load learning progress (Q-Table) and current episode count - episode end is now purely decided by environment instead of monte carlo algo capping it on 10 actions - using linkedHashMap on all locations to ensure deterministic behaviour - fixed major RNG issue to reproduce algorithmic behaviour - clearing rewardHistory, to only save the last 10k rewards - added google dino jump environment
This commit is contained in:
@@ -29,7 +29,8 @@ public class EpsilonGreedyPolicy<A extends Enum> implements EpsilonPolicy<A>{
|
||||
|
||||
@Override
|
||||
public A chooseAction(Map<A, Double> actionValues) {
|
||||
if(RNG.getRandom().nextFloat() < epsilon){
|
||||
float f = RNG.getRandom().nextFloat();
|
||||
if(f < epsilon){
|
||||
// Take random action
|
||||
return randomPolicy.chooseAction(actionValues);
|
||||
}else{
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package core.policy;
|
||||
|
||||
import core.RNG;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
public class GreedyPolicy<A extends Enum> implements Policy<A> {
|
||||
|
||||
@@ -26,6 +27,6 @@ public class GreedyPolicy<A extends Enum> implements Policy<A> {
|
||||
}
|
||||
}
|
||||
|
||||
return equalHigh.get(new Random().nextInt(equalHigh.size()));
|
||||
return equalHigh.get(RNG.getRandom().nextInt(equalHigh.size()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package core.policy;
|
||||
|
||||
import core.RNG;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class RandomPolicy<A extends Enum> implements Policy<A>{
|
||||
@Override
|
||||
public A chooseAction(Map<A, Double> actionValues) {
|
||||
int idx = RNG.getRandom().nextInt(actionValues.size());
|
||||
System.out.println("selected action " + idx);
|
||||
int i = 0;
|
||||
for(A action : actionValues.keySet()){
|
||||
if(i++ == idx) return action;
|
||||
if(i++ == idx) return action;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user