Beispiel #1
0
    // Aplica algoritmo minmax con poda alpha beta para calcular la mejor accion.
    protected AIRawSlimeAction GetActionWithAlphaBeta(AIGameState state)
    {
        playerId = state.GetCurrentPlayer().GetId();
        turn     = state.GetCurrentTurn();

        float playerSlimes = state.GetCurrentPlayer().GetSlimes().Count;

        //depth = (int)Mathf.Max(minDepth, maxDepth-Mathf.Floor(playerSlimes/depthSlimeFactor));

        // Normalmente trabajaremos con profundidad 2. Si en cualquiera de estos dos pasos de profundidad hay que analizar mas de 3 slimes,
        // solamente bajaremos 1 grado de profundidad (sino demasiado coste).
        if (playerSlimes > 2 ||
            (state.GetRemainingActions() <= 1 && state.GetNextPlayer().GetSlimes().Count > 3))
        {
            depth = 2;
        }

        /*if(playerSlimes > 3 ||
         * (state.GetRemainingActions() <= 1 && state.GetNextPlayer().GetSlimes().Count > 4)) depth = 2;*/

        //Debug.Log("DEPTH: " + depth);

        return(GetMaxValueAction(state, 0, double.MinValue, double.MaxValue).Key);
    }