battle strategy auxiliary module

owly

闇の伝説
Staff member
戦闘 コーダー
this will be good for games and maybe other AGI usages.
it could have a game state and a machine state element to it.
 

owly

闇の伝説
Staff member
戦闘 コーダー
team fuki is the best coder team in the history of time and space !

strategy:
limitedSizedQ
RndDraw

AXStrategy:
size // q size
int endState
// consts:
pain
{context, strategy}
addStrategy(context, drawRnd)
process(input)->Str // context/pain
battleMode()
-evolveStrategy()
 

fukurou

the supreme coder
ADMIN
Java:
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();
    }
}
 

owly

闇の伝説
Staff member
戦闘 コーダー
AXStrategy:
lim
PAIN // const
{context, Strategy}
addStrategy(context,Strategy:DrawRnd){create, evole}
process(input:Str)->Str //evolve?

HP player2 should be handled externally anyways
 

fukurou

the supreme coder
ADMIN
Java:
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 "";
    }
}

 

fukurou

the supreme coder
ADMIN
Java:
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();
    }
}
 

fukurou

the supreme coder
ADMIN
Java:
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 "";
    }
}
 

fukurou

the supreme coder
ADMIN
Java:
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"));
        }
    }

kombo3
reversal

kombo3
zoning

kombo2
reversal

kombo3
reversal

kombo2
reversal

kombo3
zoning

kombo3
zoning

kombo3
reversal

kombo3
zoning

kombo3
reversal


Process finished with exit code 0
 

fukurou

the supreme coder
ADMIN
Java:
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 "";
    }
}
 

fukurou

the supreme coder
ADMIN
Java:
    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(""));
        }
    }

kombo5
zoning
grapple1

kombo1
zoning
hit n grab kombo

kombo5
zoning
grapple1

kombo5
zoning
hit n grab kombo

kombo5
zoning
grapple1

kombo1
zoning
hit n grab kombo

kombo1
zoning
grapple1

kombo5
zoning
grapple1

kombo1
zoning
grapple1

kombo1
zoning
hit n grab kombo

following game lose the combat AI has evolved!
kombo1
zoning
grapple2

kombo1
reversal
hit n grab kombo

kombo1
zoning
grapple2

kombo1
zoning
hit n grab kombo

kombo1
reversal
grapple2

kombo3
zoning
hit n grab kombo

kombo1
zoning
hit n grab kombo

kombo3
zoning
hit n grab kombo

kombo3
zoning
grapple2

kombo1
reversal
grapple2


Process finished with exit code 0
 
Top