Esempio n. 1
0
        /**
         * Controlling method of the <code>TicTacToe</code> executable. Begins a
         * game of tic-tac-toe. Expects class names of the players as two
         * commandline arguments.
         *
         * @param args
         *            <code>String[]</code> commandline arguments. This should be
         *            the class names of the players. If the players are in the
         *            <code>net.blubones.tictactoe</code> package the qualifier
         *            can be omitted, otherwise the full class names are required.
         */
        static void Main(string[] args)
        {
            try
            {
                //args = match MinMax Random
                NeuralTicTacToe ttt = new NeuralTicTacToe();

                if (args.Length < 3)
                {
                    Console.WriteLine("Usage: NeuralTicTacToe [game/match/train] [player1] [player2]");
                    return;
                }

                Player player1 = getPlayer(args[1]);
                Player player2 = getPlayer(args[2]);

                if (player1 == null)
                {
                    Console.WriteLine("Must specify player 1.");
                    return;
                }

                if (player2 == null)
                {
                    Console.WriteLine("Must specify player 2.");
                    return;
                }

                ttt.setPlayer1(player1);
                ttt.setPlayer2(player2);

                if (string.Equals(args[0], "Game", StringComparison.CurrentCultureIgnoreCase))
                {
                    ttt.singleGame();
                }
                else if (string.Equals(args[0], "Match", StringComparison.CurrentCultureIgnoreCase))
                {
                    ttt.playMatch();
                }
                else if (string.Equals(args[0], "Train", StringComparison.CurrentCultureIgnoreCase))
                {
                    ttt.geneticNeural();
                }
                else
                {
                    Console.WriteLine("Invalid mode.");
                }
            }
            catch (Exception t)
            {
                Console.WriteLine(t);
                Console.WriteLine(t.StackTrace);
            }
        }
        /**
         * Controlling method of the <code>TicTacToe</code> executable. Begins a
         * game of tic-tac-toe. Expects class names of the players as two
         * commandline arguments.
         * 
         * @param args
         *            <code>String[]</code> commandline arguments. This should be
         *            the class names of the players. If the players are in the
         *            <code>net.blubones.tictactoe</code> package the qualifier
         *            can be omitted, otherwise the full class names are required.
         */
        static void Main(string[] args)
        {
            try
            {
                NeuralTicTacToe ttt = new NeuralTicTacToe();

                if (args.Length < 3)
                {
                    Console.WriteLine("Usage: NeuralTicTacToe [game/match/train] [player1] [player2]");
                    return;
                }

                Player player1 = getPlayer(args[1]);
                Player player2 = getPlayer(args[2]);

                if (player1 == null)
                {
                    Console.WriteLine("Must specify player 1.");
                    return;
                }

                if (player2 == null)
                {
                    Console.WriteLine("Must specify player 2.");
                    return;
                }

                ttt.setPlayer1(player1);
                ttt.setPlayer2(player2);

                if (string.Equals(args[0], "Game", StringComparison.CurrentCultureIgnoreCase))
                {
                    ttt.singleGame();
                }
                else if (string.Equals(args[0], "Match", StringComparison.CurrentCultureIgnoreCase))
                {
                    ttt.playMatch();
                }
                else if (string.Equals(args[0], "Train", StringComparison.CurrentCultureIgnoreCase))
                {
                    ttt.geneticNeural();
                }
                else
                {
                    Console.WriteLine("Invalid mode.");
                }
            }
            catch (Exception t)
            {
                Console.WriteLine(t);
                Console.WriteLine(t.StackTrace);
            }
        }