Esempio n. 1
0
    private void TestAdvanceTurnAndExecuteAction()
    {
        TGame game = DebugSnapshot();

        print("");
        M_FlowController test = new M_FlowController();

        test.TESTAdvanceTurnAndExecuteActions(0, Utilities.Actions.Wait, game);
        DebugSnapshot(game);
    }
Esempio n. 2
0
    /// <summary>
    /// Generates the root and the first expansion of nodes
    /// </summary>
    /// <param name="gameStateAtRoot">THe game that will be in the root</param>
    /// <param name="id">Player id of the owner of the tree</param>
    /// <param name="maxConcurrentTasks">Maximmum number of simultaneous simulations</param>
    public MontecarloTree(TGame gameStateAtRoot, int id)
    {
        Debug.Log("Creando arbol");

        tree    = new M_Node[100];
        tree[0] = new M_Node(gameStateAtRoot, 0);
        if (tree[0].State.SomeoneWon() != GlobalData.NO_PLAYER)
        {
            Debug.Log("VICTORIA EN LA RAIZ");
        }
        this.id        = id;
        flowController = new M_FlowController();
        treeMutex      = new Mutex();
        ExtendNode(tree[0]);
    }
Esempio n. 3
0
    void Awake()
    {
        instance = this;
        GameObject aux = GameObject.Find("Level");

        EventEntity[] planets = new EventEntity[aux.transform.childCount];
        for (int i = 0; i < aux.transform.childCount; i++)
        {
            planets[i]    = aux.transform.GetChild(i).GetComponent <EventEntity>();
            planets[i].Id = i;
        }

        currentGame = new Game(planets);

        remainingTime = 5f;
        test          = new M_FlowController();
    }
Esempio n. 4
0
    private void Simulate(System.Object info)
    {
        M_FlowController flow = new M_FlowController(id);
        M_Node           node = (M_Node)info;

        //Debug.Log("Empezando entrenamiento de nodo " + node.Position);
        flow.StartTrainingInThisThread(node.State);
        #if UNITY_EDITOR
        if (node.State.SomeoneWon() == GlobalData.NO_PLAYER)
        {
            Debug.LogError("NADIE GANO AL EJECUTAR LA SIMULACION");
        }
        #endif

        if (flow.currentWinner == id)
        {
            //Debug.Log("Terminando entrenamiento de nodo " + node.Position);
            node.Score += GlobalData.MONTECARLO_REWARD;
        }
        else if (flow.currentWinner != GlobalData.TIE)
        {
            node.Score += GlobalData.MONTECARLO_PENALIZATION;
        }
        else
        {
            node.Score = 0;
        }

        node.Score += flow.RatioExtraScore * 2;
        // Debug.Log("Terminando entrenamiento de nodo " + node.Position + " con "  + node.Score + " puntos" );
        tree.BackpropagateScore(node);
        node.State.RestoreSnapshot();
        mMutex.WaitOne();
        currentActiveSimulations--;
        mMutex.ReleaseMutex();
    }