The_Programmer_Gamer

Tic_Tac_Toe (fail and try folder)

Mar 30th, 2020 (edited)
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 29.22 KB | None | 0 0
  1. //in this page you can see the faild or not used programms I programmd for the tic_tac_toe
  2.  
  3. //if you would like to copy and paste this it will not work because it is only a test version: --> please use this link for the finished one: https://pastebin.com/Mqd9EeuY
  4. //
  5.  
  6. //using System;
  7. //using System.Collections.Generic;
  8. //using System.Linq;
  9. //using System.Text;
  10. //using System.Threading.Tasks;
  11.  
  12. //namespace Test_Tiktaktoe
  13. //{
  14. //    class Program
  15. //    {
  16. //        static void Main(string[] args)
  17. //        {
  18. //            int spieler = 2; // Spieler 1 beginnt
  19. //            int eingabe = 0;
  20. //            int pruefflag = 0;
  21. //            int spielzug = 0;
  22.  
  23. //            Ein 3x3 - Array mit den Feldnummern initialisieren
  24. //            char[,] array =
  25. //            {
  26. //                {'1','2','3'},
  27. //                {'4','5','6'},
  28. //                {'7','8','9'}
  29. //            };
  30.  
  31. //            do
  32. //            {
  33. //                #region
  34.  
  35. //                /* Spieler abwechseln */
  36. //                if (spieler == 2)
  37. //                    spieler = 1;
  38. //                else if (spieler == 1)
  39. //                    spieler = 2;
  40.  
  41. //                switch (spieler)    // Prüfen, welcher Spieler an der Reihe ist
  42. //                {
  43. //                    case 1: // Spieler 1
  44. //                        {
  45. //                            switch (eingabe) // Dem gewählten Eingabefeld ein X zuweisen
  46. //                            {
  47. //                                case 1: array[0, 0] = 'X'; break;
  48. //                                case 2: array[0, 1] = 'X'; break;
  49. //                                case 3: array[0, 2] = 'X'; break;
  50. //                                case 4: array[1, 0] = 'X'; break;
  51. //                                case 5: array[1, 1] = 'X'; break;
  52. //                                case 6: array[1, 2] = 'X'; break;
  53. //                                case 7: array[2, 0] = 'X'; break;
  54. //                                case 8: array[2, 1] = 'X'; break;
  55. //                                case 9: array[2, 2] = 'X'; break;
  56. //                            }
  57. //                            break;
  58. //                        }
  59.  
  60. //                    case 2: // Spieler 2
  61. //                        {
  62. //                            switch (eingabe) // Dem gewählten Eingabefeld ein O zuweisen
  63. //                            {
  64. //                                case 1: array[0, 0] = 'O'; break;
  65. //                                case 2: array[0, 1] = 'O'; break;
  66. //                                case 3: array[0, 2] = 'O'; break;
  67. //                                case 4: array[1, 0] = 'O'; break;
  68. //                                case 5: array[1, 1] = 'O'; break;
  69. //                                case 6: array[1, 2] = 'O'; break;
  70. //                                case 7: array[2, 0] = 'O'; break;
  71. //                                case 8: array[2, 1] = 'O'; break;
  72. //                                case 9: array[2, 2] = 'O'; break;
  73. //                            }
  74. //                            break;
  75. //                        }
  76. //                }
  77. //                #endregion
  78.  
  79. //                #region
  80. //                Console.Clear();
  81. //                /* Das 3x3-Array mit den aktuellen Werten ausgeben */
  82. //                Console.WriteLine("     |     |      ");
  83. //                Console.WriteLine("  {0}  |  {1}  |  {2}", array[0, 0], array[0, 1], array[0, 2]);
  84. //                Console.WriteLine("_____|_____|_____ ");
  85. //                Console.WriteLine("     |     |      ");
  86. //                Console.WriteLine("  {0}  |  {1}  |  {2}", array[1, 0], array[1, 1], array[1, 2]);
  87. //                Console.WriteLine("_____|_____|_____ ");
  88. //                Console.WriteLine("     |     |      ");
  89. //                Console.WriteLine("  {0}  |  {1}  |  {2}", array[2, 0], array[2, 1], array[2, 2]);
  90. //                Console.WriteLine("     |     |      ");
  91.  
  92. //                spielzug++; // Jeden gültigen Spielzug mitzählen
  93. //                #endregion
  94.  
  95.  
  96.  
  97. //                if
  98. //                (
  99. //                    ((array[0, 0] == 'O') && (array[0, 1] == 'O') && (array[0, 2] == 'O')) ||
  100. //                    ((array[1, 0] == 'O') && (array[1, 1] == 'O') && (array[1, 2] == 'O')) ||
  101. //                    ((array[2, 0] == 'O') && (array[2, 1] == 'O') && (array[2, 2] == 'O')) ||
  102. //                    ((array[0, 0] == 'O') && (array[1, 0] == 'O') && (array[2, 0] == 'O')) ||
  103. //                    ((array[0, 1] == 'O') && (array[1, 1] == 'O') && (array[2, 1] == 'O')) ||
  104. //                    ((array[0, 2] == 'O') && (array[1, 2] == 'O') && (array[2, 2] == 'O')) ||
  105. //                    ((array[0, 0] == 'O') && (array[1, 1] == 'O') && (array[2, 2] == 'O')) ||
  106. //                    ((array[0, 2] == 'O') && (array[1, 1] == 'O') && (array[2, 0] == 'O'))
  107. //                )
  108. //                {
  109. //                    Console.WriteLine("\nSpieler 2 hat gewonnen!");
  110. //                    Console.ReadLine();
  111. //                    break;
  112. //                }
  113.  
  114. //                else if
  115. //                (
  116. //                    ((array[0, 0] == 'X') && (array[0, 1] == 'X') && (array[0, 2] == 'X')) ||
  117. //                    ((array[1, 0] == 'X') && (array[1, 1] == 'X') && (array[1, 2] == 'X')) ||
  118. //                    ((array[2, 0] == 'X') && (array[2, 1] == 'X') && (array[2, 2] == 'X')) ||
  119. //                    ((array[0, 0] == 'X') && (array[1, 0] == 'X') && (array[2, 0] == 'X')) ||
  120. //                    ((array[0, 1] == 'X') && (array[1, 1] == 'X') && (array[2, 1] == 'X')) ||
  121. //                    ((array[0, 2] == 'X') && (array[1, 2] == 'X') && (array[2, 2] == 'X')) ||
  122. //                    ((array[0, 0] == 'X') && (array[1, 1] == 'X') && (array[2, 2] == 'X')) ||
  123. //                    ((array[0, 2] == 'X') && (array[1, 1] == 'X') && (array[2, 0] == 'X'))
  124. //                )
  125. //                {
  126. //                    Console.WriteLine("\nSpieler 1 hat gewonnen!");
  127. //                    Console.ReadLine();
  128. //                    break;
  129. //                }
  130. //                else if (spielzug == 10)
  131. //                {
  132. //                    Console.WriteLine("\nUnentschieden!");
  133. //                    Console.ReadLine();
  134. //                    break;
  135. //                }
  136.  
  137.  
  138.  
  139. //                #region
  140. //                /* Prüfen, ob das gewählte Feld bereits vergeben ist */
  141. //                do
  142. //                {
  143. //                    Console.Write("\nSpieler {0}: Feld auswählen! ", spieler);
  144. //                    eingabe = Convert.ToInt32(Console.ReadLine());
  145.  
  146. //                    if ((eingabe == 1) && (array[0, 0] == '1'))       // OK
  147. //                        pruefflag = 0;
  148. //                    else if ((eingabe == 2) && (array[0, 1] == '2'))  // OK
  149. //                        pruefflag = 0;
  150. //                    else if ((eingabe == 3) && (array[0, 2] == '3'))  // OK
  151. //                        pruefflag = 0;
  152. //                    else if ((eingabe == 4) && (array[1, 0] == '4'))  // OK
  153. //                        pruefflag = 0;
  154. //                    else if ((eingabe == 5) && (array[1, 1] == '5'))  // OK
  155. //                        pruefflag = 0;
  156. //                    else if ((eingabe == 6) && (array[1, 2] == '6'))  // OK
  157. //                        pruefflag = 0;
  158. //                    else if ((eingabe == 7) && (array[2, 0] == '7'))  // OK
  159. //                        pruefflag = 0;
  160. //                    else if ((eingabe == 8) && (array[2, 1] == '8'))  // OK
  161. //                        pruefflag = 0;
  162. //                    else if ((eingabe == 9) && (array[2, 2] == '9'))  // OK
  163. //                        pruefflag = 0;
  164. //                    else                                                  // Eingabefehler
  165. //                    {
  166. //                        Console.WriteLine("\nFehlerhafte Eingabe! Bitte wählen Sie ein neues Feld! ");
  167. //                        pruefflag = 1;
  168. //                    }
  169. //                } while (pruefflag == 1);
  170. //                #endregion
  171.  
  172. //            } while (true);
  173. //        }
  174. //    }
  175. //}
  176.  
  177.  
  178.  
  179.  
  180.  
  181. using System;
  182. using System.Collections.Generic;
  183. using System.Linq;
  184. using System.Text;
  185. using System.Threading.Tasks;
  186.  
  187. namespace Test_TicTacToe
  188. {
  189.     class Program
  190.     {
  191.         //        static void Main(string[] args)
  192.         //        {
  193.         //            string[] stringin = new string[9];
  194.         //            int TRY = 1;
  195.         //            bool player1 = true;
  196.         //            bool end = false;
  197.         //            for (int i = 0; i < stringin.Length; ++i)
  198.         //            {
  199.         //                stringin[i] = (i + 1).ToString();
  200.         //            }
  201.  
  202.         //            RenderBoard(stringin);
  203.  
  204.         //            int playerstringin = 0;
  205.         //            string P1orP2;
  206.         //            for (int i = 0; i < 9; ++i)
  207.         //            {
  208.         //                int round = TRY++;
  209.         //                Console.WriteLine("\n\nTRY: " + round);
  210.         //                P1orP2 = player1 ? "X" : "O";
  211.         //                bool error = false;
  212.         //                do
  213.         //                {
  214.         //                    try
  215.         //                    {
  216.         //                        playerstringin = Convert.ToInt32(Console.ReadLine());
  217.         //                        error = false;
  218.         //                    }
  219.         //                    catch
  220.         //                    {
  221.         //                        Console.WriteLine("Diese Eingabe ist falsch!");
  222.         //                        error = true;
  223.         //                    }
  224.  
  225.         //                } while (error || playerstringin > 9 || stringin[playerstringin] == "X" || stringin[playerstringin] == "O");
  226.  
  227.         //                stringin[playerstringin] = P1orP2;
  228.         //                Console.Clear();
  229.         //                RenderBoard(stringin);
  230.         //                player1 = !player1;
  231.         //                end = SomebodyWon(stringin, P1orP2);
  232.         //                if (end) break;
  233.         //            }
  234.  
  235.         //            bool player1Win = SomebodyWon(stringin, "X");
  236.         //            bool player2Win = SomebodyWon(stringin, "O");
  237.  
  238.         //            if (player1Win)
  239.         //            {
  240.         //                Console.WriteLine("Player 1 hat gewonnen!!!");
  241.         //            }
  242.         //            else if (player2Win)
  243.         //            {
  244.         //                Console.WriteLine("player2Win 2 hat gewonnen!!!");
  245.         //            }
  246.         //            else Console.WriteLine("Unentschieden");
  247.         //            Console.ReadKey();
  248.         //        }
  249.  
  250.         //        static void RenderBoard(string[] stringin)
  251.         //        {
  252.         //            Console.WriteLine("                 ||           ||            ");
  253.         //            Console.WriteLine("            {0}    ||     {1}     ||     {2}    ", stringin[1], stringin[2], stringin[3]);
  254.         //            Console.WriteLine("                 ||           ||            ");
  255.         //            Console.WriteLine("       ===================================  ");
  256.         //            Console.WriteLine("                 ||           ||            ");
  257.         //            Console.WriteLine("            {0}    ||     {1}     ||     {2}    ", stringin[4], stringin[5], stringin[6]);
  258.         //            Console.WriteLine("                 ||           ||            ");
  259.         //            Console.WriteLine("       ===================================  ");
  260.         //            Console.WriteLine("                 ||           ||            ");
  261.         //            Console.WriteLine("            {0}    ||     {1}     ||     {2}    ", stringin[7], stringin[8], stringin[9]);
  262.         //            Console.WriteLine("                 ||           ||            ");
  263.         //        }
  264.  
  265.         //        static bool SomebodyWon(string[] stringin, string searchString)
  266.         //        {
  267.         //            bool won = false;
  268.  
  269.         //            ////waagrecht
  270.         //            for (int i = 0; i < 3; ++i)
  271.         //            {
  272.         //                won = true;
  273.         //                int start = 0 + 3 * i;
  274.         //                for (int j = start; j < start + 3; ++j)
  275.         //                {
  276.         //                    if (stringin[j] != searchString) won = false;
  277.         //                }
  278.  
  279.         //                if (won) return true;
  280.         //            }
  281.  
  282.         //            ////vertikal
  283.         //            for (int i = 0; i < 3; ++i)
  284.         //            {
  285.         //                won = true;
  286.         //                for (int j = i; j < i + 7; j = j + 3)
  287.         //                {
  288.         //                    if (stringin[j] != searchString) won = false;
  289.         //                }
  290.  
  291.         //                if (won) return true;
  292.         //            }
  293.  
  294.         //           ////diagonal
  295.         //            if (DiagonalWin(stringin, searchString, 0, 4)) return true;
  296.         //            if (DiagonalWin(stringin, searchString, 2, 2)) return true;
  297.         //            return won;
  298.         //        }
  299.  
  300.         //        static bool DiagonalWin(string[] stringin, string searchString, int start, int mov)
  301.         //        {
  302.         //            bool won = true;
  303.  
  304.         //            for (int i = 0; i < 3; ++i)
  305.         //            {
  306.         //                int field = start + (i * mov);
  307.         //                if (stringin[field] != searchString) won = false;
  308.         //            }
  309.  
  310.         //            return won;
  311.         //        }
  312.         //    }
  313.         //}
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.         //using System;
  322.  
  323.         //public class Program
  324.         //{
  325.  
  326.         //    static string gameBoard = "1|2|3\n-+-+-\n4|5|6\n-+-+-\n7|8|9";
  327.  
  328.         //    public static void Main()
  329.         //    {
  330.  
  331.         //        bool keepPlaying, numbersLeft;
  332.         //        string userChoice;
  333.  
  334.         //        do
  335.         //        {
  336.         //            keepPlaying = false;
  337.         //            numbersLeft = false;
  338.  
  339.         //            Console.WriteLine(gameBoard);
  340.         //            Console.WriteLine("Type a number to place an X");
  341.         //            userChoice = Console.ReadLine();
  342.  
  343.         //            GameBoardRefresh(userChoice); // Rewrite this to make gameBoard an object & have "Refresh" be a behavior?
  344.  
  345.         //            Checks to see if there are still numbers in the board
  346.         //            for (int i = 1; i < 10; i++)
  347.         //            {
  348.         //                if (gameBoard.Contains(Convert.ToString(i)))
  349.         //                {
  350.         //                    numbersLeft = true;
  351.         //                    break;
  352.         //                }
  353.         //            }
  354.  
  355.         //            if (numbersLeft)
  356.         //                keepPlaying = true;
  357.         //            else
  358.         //                keepPlaying = false;
  359.  
  360.         //        } while (keepPlaying);
  361.  
  362.         //        GameBoardRefresh(userChoice);
  363.         //        Console.WriteLine("Good job!");
  364.  
  365.         //    }
  366.  
  367.         //    public static void GameBoardRefresh(string userIn)
  368.         //    {
  369.         //        if (gameBoard.Contains(userIn))
  370.         //        {
  371.         //            gameBoard = gameBoard.Replace(userIn, "X");
  372.         //        }
  373.         //    }
  374.  
  375.         //}
  376.  
  377.         //using System;
  378.  
  379.         //namespace Test_TicTacToeConsole
  380.         //{
  381.  
  382.         //    class Utils
  383.         //    {
  384.  
  385.         //        public static Random rnd = new Random();
  386.  
  387.         //        / <summary>
  388.         //        / Shuffle the array.
  389.         //        / </summary>
  390.         //        / <typeparam name = "T" > Array element type.</typeparam>
  391.         //        / <param name = "array" > Array to shuffle.</param>
  392.         //        / <remarks></remarks>
  393.         //        public static T[] Shuffle<T>(T[] array)
  394.         //        {
  395.         //            Random random = rnd;
  396.         //            for (int i = array.Length; i > 1; i--)
  397.         //            {
  398.         //                Pick random element to swap.
  399.         //                int j = random.Next(i); // 0 <= j <= i-1
  400.         //                Swap.
  401.         //               T tmp = array[j];
  402.         //                array[j] = array[i - 1];
  403.         //                array[i - 1] = tmp;
  404.         //            }
  405.         //            return array;
  406.         //        }
  407.         //    }
  408.  
  409.         //    class Program
  410.         //    {
  411.  
  412.         //        public static Board board;
  413.         //        public static Player[] turns;
  414.         //        public static GameTree gameTree;
  415.  
  416.         //        static void Main(string[] args)
  417.         //        {
  418.         //            int moves = 0;
  419.         //            Player turn;
  420.         //            GameTreeNode currentNode;
  421.  
  422.         //            setting up the board
  423.         //            board = new Board();
  424.  
  425.         //            and the players with their turns
  426.         //            turns = new Player[2];
  427.         //            turns[0] = new Skynet(Board.CELL_O);
  428.         //            turns[1] = new Human(Board.CELL_X);
  429.  
  430.         //            we want the first turn to be assigned randomly
  431.         //           Random rnd = new Random();
  432.         //            moves = rnd.Next(0, 10);
  433.  
  434.         //            let's decide who's to go first
  435.         //            turn = turns[moves % 2];
  436.  
  437.         //            create the game tree to drive Skynet's strategy
  438.         //            gameTree = new GameTree(board, turn.mark);
  439.         //            gameTree.Build();
  440.         //            currentNode = gameTree.root;
  441.  
  442.         //            while (!board.CheckForWin(turn.mark) && !board.CheckForTie())
  443.         //            {
  444.         //                whose turn is this ?
  445.         //                turn = turns[moves % 2];
  446.  
  447.         //                print the board status
  448.         //                Console.WriteLine(board.ToString());
  449.  
  450.         //                your move
  451.         //                currentNode = turn.NextMove(board, currentNode);
  452.  
  453.         //                moves++;
  454.         //            }
  455.  
  456.         //            Console.WriteLine(board.ToString());
  457.         //            if (board.CheckForTie())
  458.         //            {
  459.         //                it's a tie!
  460.         //                Console.WriteLine("It's a tie.");
  461.         //            }
  462.         //            else
  463.         //            {
  464.         //                somebody won!
  465.         //                Console.WriteLine(turn.name + " won!");
  466.         //            }
  467.  
  468.         //            Console.Write("Press enter to exit...");
  469.         //            Console.ReadLine();
  470.         //        }
  471.  
  472.         //    }
  473.         //}
  474.         /// <summary>
  475.         ///
  476.         ///
  477.         ///
  478.         ///
  479.         /// </summary>
  480.  
  481.  
  482.  
  483.  
  484.  
  485.         //using System;
  486.         //using System.Collections.Generic;
  487.         //using System.Linq;
  488.         //using System.Text;
  489.         //using System.Threading.Tasks;
  490.  
  491.         //namespace TicTacToe
  492.         //{
  493.  
  494.         //    class Program
  495.         //    {
  496.         //        static void Main(string[] args)
  497.         //        {
  498.         //            for (int i = 1; i <= 1; i++)
  499.         //            {
  500.         //                int min = 1;
  501.         //                int max = 10;
  502.  
  503.         //                Random random = new Random();
  504.         //                int number = random.Next(min, max);
  505.  
  506.         //                int istgleich = Convert.ToInt32(number);
  507.  
  508.         //                Console.WriteLine("Hello");
  509.         //                string ich = Console.ReadLine();
  510.         //                Console.WriteLine(istgleich);
  511.  
  512.         //            }
  513.  
  514.         //            Console.ReadLine();
  515.         //        }
  516.  
  517.         //    }
  518.         //}
  519.  
  520.  
  521.  
  522.         private static void AI()
  523.         {
  524.             Console.Clear();
  525.             Console.WriteLine("TicTacToe\n\n\nYou are P1 (X)   starts: (write in 1/2/3/4/5/6/7/8/9)");
  526.             Console.WriteLine();
  527.             Console.WriteLine();
  528.             Console.WriteLine("                 ||           ||                                                ||           ||          ");
  529.             Console.WriteLine("                 ||           ||                                           1    ||     2     ||    3     ");
  530.             Console.WriteLine("                 ||           ||                                                ||           ||          ");
  531.             Console.WriteLine("       ===================================                            ===================================");
  532.             Console.WriteLine("                 ||           ||                                                ||           ||          ");
  533.             Console.WriteLine("                 ||           ||                                           4    ||     5     ||    6     ");
  534.             Console.WriteLine("                 ||           ||                                                ||           ||          ");
  535.             Console.WriteLine("       ===================================                            ===================================");
  536.             Console.WriteLine("                 ||           ||                                                ||           ||          ");
  537.             Console.WriteLine("                 ||           ||                                           7    ||     8     ||    9     ");
  538.             Console.WriteLine("                 ||           ||                                                ||           ||          ");
  539.             Console.WriteLine();
  540.             System.Threading.Thread.Sleep(2000);
  541.             Console.Clear();
  542.             Console.WriteLine("And Start (P1/PX)!! Good Luck!");
  543.             System.Threading.Thread.Sleep(1000);
  544.             Console.Clear();
  545.  
  546.             int PorAI = 2;
  547.             int input = 0;
  548.             int checkup = 0;
  549.             int round = 0;
  550.  
  551.             char[,] array =
  552.             {
  553.                 {'1','2','3'},{'4','5','6'},{'7','8','9'}
  554.             };
  555.  
  556.             do
  557.             {
  558.  
  559.  
  560.  
  561.                 if (PorAI == 2)
  562.                     PorAI = 1;
  563.                 else if (PorAI == 1)
  564.                     PorAI = 2;
  565.  
  566.                 switch (PorAI)
  567.                 {
  568.                     case 1:
  569.                         {
  570.                             switch (input)
  571.                             {
  572.                                 case 1: array[0, 0] = 'X'; break;
  573.                                 case 2: array[0, 1] = 'X'; break;
  574.                                 case 3: array[0, 2] = 'X'; break;
  575.                                 case 4: array[1, 0] = 'X'; break;
  576.                                 case 5: array[1, 1] = 'X'; break;
  577.                                 case 6: array[1, 2] = 'X'; break;
  578.                                 case 7: array[2, 0] = 'X'; break;
  579.                                 case 8: array[2, 1] = 'X'; break;
  580.                                 case 9: array[2, 2] = 'X'; break;
  581.                             }
  582.                             break;
  583.                         }
  584.  
  585.                     case 2:
  586.                         {
  587.                             switch (input)
  588.                             {
  589.                                 case 1: array[0, 0] = 'O'; break;
  590.                                 case 2: array[0, 1] = 'O'; break;
  591.                                 case 3: array[0, 2] = 'O'; break;
  592.                                 case 4: array[1, 0] = 'O'; break;
  593.                                 case 5: array[1, 1] = 'O'; break;
  594.                                 case 6: array[1, 2] = 'O'; break;
  595.                                 case 7: array[2, 0] = 'O'; break;
  596.                                 case 8: array[2, 1] = 'O'; break;
  597.                                 case 9: array[2, 2] = 'O'; break;
  598.                             }
  599.                             break;
  600.                         }
  601.                 }
  602.  
  603.                 System.Threading.Thread.Sleep(2000);
  604.                 Console.Clear();
  605.                 Console.WriteLine("");
  606.                 Console.WriteLine("");
  607.                 Console.WriteLine("                 ||           ||            ");
  608.                 Console.WriteLine("            {0}    ||     {1}     ||     {2}    ", array[0, 0], array[0, 1], array[0, 2]);
  609.                 Console.WriteLine("                 ||           ||            ");
  610.                 Console.WriteLine("       ===================================  ");
  611.                 Console.WriteLine("                 ||           ||            ");
  612.                 Console.WriteLine("            {0}    ||     {1}     ||     {2}    ", array[1, 0], array[1, 1], array[1, 2]);
  613.                 Console.WriteLine("                 ||           ||            ");
  614.                 Console.WriteLine("       ===================================  ");
  615.                 Console.WriteLine("                 ||           ||            ");
  616.                 Console.WriteLine("            {0}    ||     {1}     ||     {2}    ", array[2, 0], array[2, 1], array[2, 2]);
  617.                 Console.WriteLine("                 ||           ||            ");
  618.  
  619.  
  620.                 round++;
  621.                 Console.WriteLine("Try: " + round);
  622.  
  623.  
  624.  
  625.                 if
  626.                 (
  627.                     ((array[0, 0] == 'O') && (array[0, 1] == 'O') && (array[0, 2] == 'O')) ||
  628.                     ((array[1, 0] == 'O') && (array[1, 1] == 'O') && (array[1, 2] == 'O')) ||
  629.                     ((array[2, 0] == 'O') && (array[2, 1] == 'O') && (array[2, 2] == 'O')) ||
  630.                     ((array[0, 0] == 'O') && (array[1, 0] == 'O') && (array[2, 0] == 'O')) ||
  631.                     ((array[0, 1] == 'O') && (array[1, 1] == 'O') && (array[2, 1] == 'O')) ||
  632.                     ((array[0, 2] == 'O') && (array[1, 2] == 'O') && (array[2, 2] == 'O')) ||
  633.                     ((array[0, 0] == 'O') && (array[1, 1] == 'O') && (array[2, 2] == 'O')) ||
  634.                     ((array[0, 2] == 'O') && (array[1, 1] == 'O') && (array[2, 0] == 'O'))
  635.                 )
  636.                 {
  637.                     Console.WriteLine("\nAIo won!");
  638.                     Console.ReadLine();
  639.                     break;
  640.                 }
  641.  
  642.                 else if
  643.                 (
  644.                     ((array[0, 0] == 'X') && (array[0, 1] == 'X') && (array[0, 2] == 'X')) ||
  645.                     ((array[1, 0] == 'X') && (array[1, 1] == 'X') && (array[1, 2] == 'X')) ||
  646.                     ((array[2, 0] == 'X') && (array[2, 1] == 'X') && (array[2, 2] == 'X')) ||
  647.                     ((array[0, 0] == 'X') && (array[1, 0] == 'X') && (array[2, 0] == 'X')) ||
  648.                     ((array[0, 1] == 'X') && (array[1, 1] == 'X') && (array[2, 1] == 'X')) ||
  649.                     ((array[0, 2] == 'X') && (array[1, 2] == 'X') && (array[2, 2] == 'X')) ||
  650.                     ((array[0, 0] == 'X') && (array[1, 1] == 'X') && (array[2, 2] == 'X')) ||
  651.                     ((array[0, 2] == 'X') && (array[1, 1] == 'X') && (array[2, 0] == 'X'))
  652.                 )
  653.                 {
  654.                     Console.WriteLine("\nPx won!");
  655.                     Console.ReadLine();
  656.                     break;
  657.                 }
  658.                 else if (round == 10)
  659.                 {
  660.                     Console.WriteLine("\nDefault!");
  661.                     Console.ReadLine();
  662.                     break;
  663.                 }
  664.  
  665.  
  666.  
  667.  
  668.  
  669.                 do
  670.                 {
  671.                     Console.Write("\nPlayer {0}: Choose Array 1/2/3/4/5/6/7/8/9! ", PorAI);
  672.  
  673.                     if (PorAI == 1)
  674.                     {
  675.                         Console.WriteLine("It's AI's turn...");
  676.                         int min = 1;
  677.                         int max = 10;
  678.  
  679.                         Random random = new Random();
  680.                         int number = random.Next(min, max);
  681.  
  682.                         input = Convert.ToInt32(number); //das erste mal wo ich verstehe warum man statt Parse Convert nimmt.
  683.                     }
  684.                     else
  685.                     {
  686.                         input = Int32.Parse(Console.ReadLine());
  687.                     }
  688.  
  689.  
  690.                     if ((input == 1) && (array[0, 0] == '1'))      
  691.                         checkup = 0;
  692.                     else if ((input == 2) && (array[0, 1] == '2'))  
  693.                         checkup = 0;
  694.                     else if ((input == 3) && (array[0, 2] == '3'))  
  695.                         checkup = 0;
  696.                     else if ((input == 4) && (array[1, 0] == '4'))  
  697.                         checkup = 0;
  698.                     else if ((input == 5) && (array[1, 1] == '5'))  
  699.                         checkup = 0;
  700.                     else if ((input == 6) && (array[1, 2] == '6'))  
  701.                         checkup = 0;
  702.                     else if ((input == 7) && (array[2, 0] == '7'))  
  703.                         checkup = 0;
  704.                     else if ((input == 8) && (array[2, 1] == '8'))  
  705.                         checkup = 0;
  706.                     else if ((input == 9) && (array[2, 2] == '9'))  
  707.                         checkup = 0;
  708.                     else                                                
  709.                     {
  710.                         Console.WriteLine("\nDoes not exist or something going wrong! ");
  711.                         checkup = 1;
  712.                     }
  713.                 } while (checkup == 1);
  714.  
  715.  
  716.             } while (true);
  717.         }
  718.     }
  719.  
  720. }
Add Comment
Please, Sign In to add comment