public class Strategy {
private UniqueItemSizeLimitedPriorityQueue activeStrategy;
private DrawRnd allStrategies;
public Strategy(DrawRnd allStrategies) {
this.allStrategies = allStrategies;
this.activeStrategy = new UniqueItemSizeLimitedPriorityQueue();
}
public void evolveStrategies(int strategiesLimit){
activeStrategy.setLimit(strategiesLimit);
String temp = allStrategies.draw();
for (int i = 0; i < strategiesLimit; i++) {
if(temp.isEmpty()){
break;
}
activeStrategy.add(temp);
temp = allStrategies.draw();
}
allStrategies.reset();
}
public String getStrategy(){
return this.activeStrategy.getRNDElement();
}
}
package AXJava;
import java.util.Enumeration;
import java.util.Hashtable;
public class AXStrategy {
private int lim;
private Hashtable<String,Strategy> strategies = new Hashtable<>();
public void addStrategy(String context,DrawRnd techniques){
Strategy temp = new Strategy(techniques);
temp.evolveStrategies(lim);
this.strategies.put(context,temp);
}
public void evolve(){
Enumeration<String> e = this.strategies.keys();
String key = "";
while (e.hasMoreElements()){
key = e.nextElement();
this.strategies.get(key).evolveStrategies(lim);
}
}
public String process(String context){
if(this.strategies.contains(context)){
return this.strategies.get(context).getStrategy();
}
return "";
}
}
I've been wondering weather auxiliary modules should have a summary conventionlet's add documentation
does the pop shit in the woods?I've been wondering weather auxiliary modules should have a summary convention
package AXJava;
public class Strategy {
private UniqueItemSizeLimitedPriorityQueue activeStrategy; // active strategic options
private DrawRnd allStrategies; // bank of all strategies. out of this pool active strategies are pulled
public Strategy(DrawRnd allStrategies) {
// create the strategy Object with a bank of options
this.allStrategies = allStrategies;
this.activeStrategy = new UniqueItemSizeLimitedPriorityQueue();
}
public void evolveStrategies(int strategiesLimit){
// add N strategic options to the active strategies bank, from the total strategy bank
activeStrategy.setLimit(strategiesLimit);
String temp = allStrategies.draw();
for (int i = 0; i < strategiesLimit; i++) {
if(temp.isEmpty()){
break;
}
activeStrategy.add(temp);
temp = allStrategies.draw();
}
allStrategies.reset();
}
public String getStrategy(){
return this.activeStrategy.getRNDElement();
}
}
package AXJava;
import java.util.Enumeration;
import java.util.Hashtable;
public class AXStrategy {
private int lim;
private Hashtable<String,Strategy> strategies = new Hashtable<>();
public AXStrategy(int lim) {
this.lim = lim;
}
public void addStrategy(String context, DrawRnd techniques){
Strategy temp = new Strategy(techniques);
temp.evolveStrategies(lim);
this.strategies.put(context,temp);
}
public void evolve(){
Enumeration<String> e = this.strategies.keys();
String key = "";
while (e.hasMoreElements()){
key = e.nextElement();
this.strategies.get(key).evolveStrategies(lim);
}
}
public String process(String context){
if(this.strategies.containsKey(context)){
return this.strategies.get(context).getStrategy();
}
return "";
}
}
public static void main(String[] args) {
DrawRnd offense = new DrawRnd("kombo1","kombo2","kombo3","kombo4","kombo5");
DrawRnd defense = new DrawRnd("zoning","reversal","backdash");
AXStrategy combatAI = new AXStrategy(2);
combatAI.addStrategy("offense",offense);
combatAI.addStrategy("defense",defense);
System.out.println("");
for (int i = 0; i < 10; i++) {
System.out.println(combatAI.process("offense"));
System.out.println(combatAI.process("defense"));
System.out.println(combatAI.process("shielder"));
}
}
package AXJava;
import java.util.Enumeration;
import java.util.Hashtable;
public class AXStrategy {
/* this auxiliary module is used to output strategies based on context
can be used for battles, and games
upon pain/lose use the evolve methode to update to different new active strategies
check for battle state end externaly (opponent state/hits on rival counter)
a dictionary of strategies*/
private int lim;
private Hashtable<String,Strategy> strategies = new Hashtable<>();
public AXStrategy(int lim) {
// limit of active strategies (pulled from all available strategies)
this.lim = lim;
}
public void addStrategy(String context, DrawRnd techniques){
// add strategies per context
Strategy temp = new Strategy(techniques);
temp.evolveStrategies(lim);
this.strategies.put(context,temp);
}
public void evolve(){
// replace active strategies
Enumeration<String> e = this.strategies.keys();
String key = "";
while (e.hasMoreElements()){
key = e.nextElement();
this.strategies.get(key).evolveStrategies(lim);
}
}
public String process(String context){
// process input, return action based on game context now
if(this.strategies.containsKey(context)){
return this.strategies.get(context).getStrategy();
}
return "";
}
}
public static void main(String[] args) {
DrawRnd offense = new DrawRnd("kombo1","kombo2","kombo3","kombo4","kombo5");
DrawRnd defense = new DrawRnd("zoning","reversal","backdash");
DrawRnd blocking = new DrawRnd("grapple1","grapple2","wait","hit n grab kombo");
AXStrategy combatAI = new AXStrategy(2);
combatAI.addStrategy("offense",offense);
combatAI.addStrategy("defense",defense);
combatAI.addStrategy("blocking",blocking);
System.out.println("");
for (int i = 0; i < 10; i++) {
System.out.println(combatAI.process("offense"));
System.out.println(combatAI.process("defense"));
System.out.println(combatAI.process("blocking"));
System.out.println(combatAI.process(""));
}
combatAI.evolve();
System.out.println("following game lose the combat AI has evolved!");
for (int i = 0; i < 10; i++) {
System.out.println(combatAI.process("offense"));
System.out.println(combatAI.process("defense"));
System.out.println(combatAI.process("blocking"));
System.out.println(combatAI.process(""));
}
}