// private RLAIFA rlaifa; // Use this for initialization void Start() { currInterval = AIMoveInterval; settings = GameObject.FindObjectOfType <Settings>().GetComponent <Settings>(); gameTreeAI = new GameTreeAI(gameState, depthSetting, AIMoveInterval); rlAI = new RLAI(AIMoveInterval); // rlaifa = new RLAIFA(AIMoveInterval); // incomplete reinforcemnt learning AI with Function Approx. }
// public bool test; // Use this for initialization void Start() { currInterval = AIMoveInterval; settings = GameObject.FindObjectOfType <Settings>().GetComponent <Settings>(); gameTreeAI = new GameTreeAI(gameState, depthSetting, AIMoveInterval); // rlAI = new RLAI (AIMoveInterval); rlaifa = new RLAIFA(AIMoveInterval); }
public static void generateJsonGameTree(GameState <T> state, string outName, int playerID) { state.generateFuture(); for (int max = 0; max < SystemInfo.processorCount / 2; max++) { MultiThreading.startNewThread((int)(ThreadingConstants.MB_IN_BYTES * 40)); } foreach (GameState <T> child in state.childGameStates) { GameState <T> c = child; MultiThreading.loadBalanceTask(() => { generate(c); Debug.Log("GENERATED:" + c); }); } string loc = Application.persistentDataPath; int thread = 0; thread = MultiThreading.loadBalanceTask(() => { while (MultiThreading.threadsIdle(thread)) { Thread.Sleep(1000); } Debug.Log("AI STARTED"); foreach (GameState <T> child in state.childGameStates) { GameState <T> c = child; MultiThreading.loadBalanceTask(() => GameTreeAI <T> .generatePercentHeuristic(c)); } thread = MultiThreading.loadBalanceTask(() => { while (MultiThreading.threadsIdle(thread)) { Thread.Sleep(1000); } Debug.Log("WRITING JSON"); using (StreamWriter file = File.CreateText(loc + "/" + outName + ".json")) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(file, state); } Debug.Log("DONE"); MultiThreading.stopAll(); }); }); }
void Start() { game = new TicTacToeGameState(); ai = new GameTreeAI <TicTacToeState> ( Application.dataPath + "/TicTacToeTree.json", 0, new TicTacToeEvaluator()); }