示例#1
0
        //Függvény, ami létrehozza a játékhoz tartozó Markov osztály példányt, amennyiben az még nem létezett,
        //majd Markov osztály transitionMatrix változójának másolatát (steps-1)-ik hatványára emeli.
        //Ennek adja vissza a startingStateIndex állapotnak megfelelő sorát
        //(Emlékeztető: Markov létrehozásakor a sorok és oszlopok sorrendje változott!)
        public double[] Markov1(int startingStateIndex, int steps)
        {
            //check if too big?

            double[] resultVector = new double[gameStates.Count];

            if (actualMarkov == null)
            {
                CreateMarkov();
            }

            double[,] currentMatrix = new double[gameStates.Count, gameStates.Count];
            for (int i = 0; i < gameStates.Count; i++)
            {
                currentMatrix[i, i] = 1.0;
            }


            for (int i = 0; i < steps; i++)
            {
                currentMatrix = Markov.MultiplyMatrices(ref currentMatrix, ref actualMarkov.transitionMatrix);
            }

            //try to find where our starting state ended up after the markov class switched rows and columns
            int startingStateNewIndex = -1;

            for (int i = 0; i < gameStates.Count; i++)
            {
                if (actualMarkov.originalOrder[i] == startingStateIndex)
                {
                    startingStateNewIndex = i;
                    break;
                }
            }

            for (int i = 0; i < gameStates.Count; i++)
            {
                resultVector[actualMarkov.originalOrder[i]] = currentMatrix[startingStateNewIndex, i];
            }

            return(resultVector);
        }
示例#2
0
        //Függvény, ami létrehozza a játékhoz és a tacticUsed-hoz tartozó Markov osztály példányt, amennyiben az még nem létezett,
        //majd Markov osztály transitionMatrix változójának másolatát (steps-1)-ik hatványára emeli.
        //Ennek adja vissza a startingStateIndex állapotnak megfelelő sorát
        //(Emlékeztető: Markov létrehozásakor a sorok és oszlopok sorrendje változott!)
        public double[] Markov1(int startingStateIndex, int steps, int tacticUsed)
        {
            double[] resultVector = new double[gameStates.Count * 2];

            if (analysisMarkov == null || lastTacticUsed != tacticUsed)
            {
                CreateMarkov(tacticUsed);
            }

            double[,] currentMatrix = new double[gameStates.Count * 2, gameStates.Count * 2];
            for (int i = 0; i < gameStates.Count * 2; i++)
            {
                currentMatrix[i, i] = 1.0;
            }


            for (int i = 0; i < steps; i++)
            {
                currentMatrix = Markov.MultiplyMatrices(ref currentMatrix, ref analysisMarkov.transitionMatrix);
            }

            //try to find where our starting state ended up after the markov class switched rows and columns
            int startingStateNewIndex = -1;

            for (int i = 0; i < gameStates.Count; i++)
            {
                if (analysisMarkov.originalOrder[i] == startingStateIndex)
                {
                    startingStateNewIndex = i;
                    break;
                }
            }

            for (int i = 0; i < gameStates.Count; i++)
            {
                resultVector[analysisMarkov.originalOrder[i]] = currentMatrix[startingStateNewIndex, i];
            }

            return(resultVector);
        }