Ejemplo n.º 1
0
        public static NeuralBrain LoadANN(string name)
        {
            FileInfo     file    = new FileInfo(Path.ChangeExtension(name, EXT));
            BasicNetwork network = (BasicNetwork)EncogDirectoryPersistence.LoadObject(file);
            NeuralBrain  brain   = new NeuralBrain(network);

            brain.Name = name;
            return(brain);
        }
Ejemplo n.º 2
0
        public static NeuralBrain CreateANN(string name)
        {
            NeuralBrain brain = new NeuralBrain();

            brain.Name = name;
            FileInfo file = new FileInfo(Path.ChangeExtension(name, EXT));

            EncogDirectoryPersistence.SaveObject(file, brain.network);
            return(brain);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            IPlayer playerOne;
            IPlayer playerTwo;

            Console.WriteLine("1 - Single game.");
            Console.WriteLine("2 - Multiple games");
            Console.WriteLine("3 - Train ANN");
            string decision = Console.ReadLine();

            switch (decision)
            {
            case "1":
                playerOne = ChoosePlayer();
                playerTwo = ChoosePlayer();
                GameTable table = new GameTable(playerOne, playerTwo);
                table.Run();
                break;

            case "2":
                playerOne = ChooseCType();
                playerTwo = ChooseCType();
                AutoTestingTable auto = new AutoTestingTable(playerOne, playerTwo);
                auto.Run();
                break;

            case "3":
                NeuralBrain brain = ChooseNetwork();
                // use same brain for training
                playerOne = new Comp(brain.GetBestMove);
                playerTwo = new Comp(brain.GetBestMove);
                TrainingTable train = new TrainingTable(playerOne, playerTwo, brain);
                train.Run();
                IO.SaveANN(brain);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 4
0
        static IPlayer ChooseCType()
        {
            do
            {
                Console.WriteLine("Select type:");
                Console.WriteLine("R - Random");
                Console.WriteLine("M - Minimax");
                Console.WriteLine("NM - Negamax");
                Console.WriteLine("AB - AB pruning");
                Console.WriteLine("MC - Monte Carlo Tree Search");
                Console.WriteLine("NN - Neural network");
                string result = Console.ReadLine();
                switch (result)
                {
                case "R":
                    return(new Comp(Brain.GetRandomMove));

                case "M":
                    return(new Comp(Brain.GetBestMoveMiniMax));

                case "NM":
                    return(new Comp(Brain.GetBestMoveNegaMax));

                case "AB":
                    return(new Comp(Brain.GetBestMoveABMiniMax));

                case "MC":
                    return(new Comp(Brain.GetBestMoveMCTS));

                case "NN":
                    NeuralBrain brain = ChooseNetwork();
                    return(new Comp(brain.GetBestMove));

                default:
                    Console.WriteLine("Something went wrong");
                    break;
                }
            } while (true);
        }
Ejemplo n.º 5
0
        public static void SaveANN(NeuralBrain brain)
        {
            FileInfo file = new FileInfo(Path.ChangeExtension(brain.Name, EXT));

            EncogDirectoryPersistence.SaveObject(file, brain.network);
        }
Ejemplo n.º 6
0
 public TrainingTable(IPlayer playerOne, IPlayer playerTwo, NeuralBrain network)
 {
     this.playerOne = playerOne;
     this.playerTwo = playerTwo;
     this.network   = network;
 }