private void calculateColumns(XOSymbol xoSymbol, GamePadNode gamePadNode)
        {
            for (int column = 0; column < gamePadNode.GamePad.GetLength(0); column++)
            {
                List <XOSymbol> xoSymbolLine = new List <XOSymbol>();
                for (int row = 0; row < gamePadNode.GamePad.GetLength(0); row++)
                {
                    xoSymbolLine.Add((XOSymbol)gamePadNode.GamePad.GetValue(row, column));
                }
                if (isWinningMove(xoSymbol, xoSymbolLine))
                {
                    gamePadNode.IsWinning = true;
                    return;
                }
                if (hasPotential(xoSymbol, xoSymbolLine))
                {
                    switch (xoSymbol)
                    {
                    case XOSymbol.X:
                        gamePadNode.XFunction++;
                        break;

                    case XOSymbol.O:
                        gamePadNode.OFunction++;
                        break;
                    }
                }
            }
        }
 private void calculateColumns(XOSymbol xoSymbol, GamePadNode gamePadNode)
 {
     for (int column = 0; column < gamePadNode.GamePad.GetLength(0); column++)
     {
         List<XOSymbol> xoSymbolLine = new List<XOSymbol>();
         for (int row = 0; row < gamePadNode.GamePad.GetLength(0); row++)
         {
             xoSymbolLine.Add((XOSymbol)gamePadNode.GamePad.GetValue(row, column));
         }
         if (isWinningMove(xoSymbol, xoSymbolLine))
         {
             gamePadNode.IsWinning = true;
             return;
         }
         if (hasPotential(xoSymbol, xoSymbolLine))
         {
             switch (xoSymbol)
             {
                 case XOSymbol.X:
                     gamePadNode.XFunction++;
                     break;
                 case XOSymbol.O:
                     gamePadNode.OFunction++;
                     break;
             }
         }
     }
 }
 public void SetGamePad(GamePadNode gamePadNode)
 {
     this.GamePad = gamePadNode.GamePad;
     lblHeuristicValue.Text = gamePadNode.Heurisitic + "";
     lblFOValue.Text = gamePadNode.OFunction + "";
     lblFXValue.Text = gamePadNode.XFunction + "";
 }
        private void oFunction(GamePadNode gamePadNode)
        {
            XOSymbol xoSymbol = XOSymbol.O;

            calculateRows(xoSymbol, gamePadNode);
            calculateColumns(xoSymbol, gamePadNode);
            calculateDiagonals(xoSymbol, gamePadNode);
        }
        private List <GamePadNode> generateChilds(GamePadNode gamePadNode)
        {
            List <int>         listEmptyCellsIndex;
            List <GamePadNode> listGamePadNode = new List <GamePadNode>();

            listEmptyCellsIndex = countEmptyCells(gamePadNode.GamePad);
            foreach (int currentIndex in listEmptyCellsIndex)
            {
                GamePadNode childGamePad = new GamePadNode();
                childGamePad.GamePad = (XOSymbol[, ])gamePadNode.GamePad.Clone();
                childGamePad.GamePad.SetValue(playerSymbol, getRowIndex(currentIndex), getColumnIndex(currentIndex));
                childGamePad.GameMove = new GameMove(currentIndex, playerSymbol);
                listGamePadNode.Add(childGamePad);
            }
            return(listGamePadNode);
        }
        private void calculateDiagonals(XOSymbol xoSymbol, GamePadNode gamePadNode)
        {
            for (int diagonal = 0; diagonal < 2; diagonal++)
            {
                List <XOSymbol> xoSymbolLine = new List <XOSymbol>();
                for (int row = 0; row < gamePadNode.GamePad.GetLength(0); row++)
                {
                    int column = 0;

                    switch (diagonal)
                    {
                    case 0: column = row;
                        break;

                    case 1: column = (gamePadNode.GamePad.GetLength(0) - 1) - row;
                        break;
                    }
                    xoSymbolLine.Add((XOSymbol)gamePadNode.GamePad.GetValue(row, column));
                }
                if (isWinningMove(xoSymbol, xoSymbolLine))
                {
                    gamePadNode.IsWinning = true;
                    return;
                }
                if (hasPotential(xoSymbol, xoSymbolLine))
                {
                    switch (xoSymbol)
                    {
                    case XOSymbol.X:
                        gamePadNode.XFunction++;
                        break;

                    case XOSymbol.O:
                        gamePadNode.OFunction++;
                        break;
                    }
                }
            }
        }
 private void calculateHeuristic(GamePadNode gamePadNode)
 {
     xFunction(gamePadNode);
     oFunction(gamePadNode);
 }
 private void xFunction(GamePadNode gamePadNode)
 {
     XOSymbol xoSymbol = XOSymbol.X;
     calculateRows(xoSymbol, gamePadNode);
     calculateColumns(xoSymbol, gamePadNode);
     calculateDiagonals(xoSymbol, gamePadNode);
 }
 private List<GamePadNode> generateChilds(GamePadNode gamePadNode)
 {
     List<int> listEmptyCellsIndex;
     List<GamePadNode> listGamePadNode = new List<GamePadNode>();
     listEmptyCellsIndex = countEmptyCells(gamePadNode.GamePad);
     foreach (int currentIndex in listEmptyCellsIndex)
     {
         GamePadNode childGamePad = new GamePadNode();
         childGamePad.GamePad = (XOSymbol[,])gamePadNode.GamePad.Clone();
         childGamePad.GamePad.SetValue(playerSymbol, getRowIndex(currentIndex), getColumnIndex(currentIndex));
         childGamePad.GameMove = new GameMove(currentIndex, playerSymbol);
         listGamePadNode.Add(childGamePad);
     }
     return listGamePadNode;
 }
 private void calculateHeuristic(GamePadNode gamePadNode)
 {
     xFunction(gamePadNode);
     oFunction(gamePadNode);
 }
        private void calculateDiagonals(XOSymbol xoSymbol, GamePadNode gamePadNode)
        {
            for (int diagonal = 0; diagonal < 2; diagonal++)
            {
                List<XOSymbol> xoSymbolLine = new List<XOSymbol>();
                for (int row = 0; row < gamePadNode.GamePad.GetLength(0); row++)
                {
                    int column = 0;

                    switch (diagonal)
                    {
                        case 0: column = row;
                            break;
                        case 1: column = (gamePadNode.GamePad.GetLength(0) - 1) - row;
                            break;
                    }
                    xoSymbolLine.Add((XOSymbol)gamePadNode.GamePad.GetValue(row, column));
                }
                if (isWinningMove(xoSymbol, xoSymbolLine))
                {
                    gamePadNode.IsWinning = true;
                    return;
                }
                if (hasPotential(xoSymbol, xoSymbolLine))
                {
                    switch (xoSymbol)
                    {
                        case XOSymbol.X:
                            gamePadNode.XFunction++;
                            break;
                        case XOSymbol.O:
                            gamePadNode.OFunction++;
                            break;
                    }
                }
            }
        }
Beispiel #12
0
 public void AddGamePad(GamePadNode gamePadNode)
 {
     pnlGamePads.Controls.Add(new TracingGamePadUC(gamePadNode));
 }
 public TracingGamePadUC(GamePadNode gamePadNode)
     : this()
 {
     SetGamePad(gamePadNode);
 }