コード例 #1
0
        static void runGame()
        {
            AlgoBot a = new AlgoBot(true);

            a.myGame = new Game();
            runGame(a);
        }
コード例 #2
0
        public TrainingSet CreateTrainingsSet()
        {
            List <UnpreparedTrainingsset> result = new List <UnpreparedTrainingsset>();
            AlgoBot algobot = new AlgoBot();
            Game    i_game  = new Game();

            i_game.turn = false;
            List <String> lstr = new List <String>();

            result.AddRange(getUnpreparedTrainingssets(i_game, lstr, algobot));
            //for the other color
            Console.WriteLine("Created Testdata for first Color");
            i_game      = new Game();
            i_game.turn = true;
            result.AddRange(getUnpreparedTrainingssets(i_game, lstr, algobot));
            Console.WriteLine("Raw testdata created. " + result.Count + " sets");

            return(UnpreparedTrainingsset.toTrainingsset(result));
        }
コード例 #3
0
        private List <UnpreparedTrainingsset> getUnpreparedTrainingssets(Game i_game, List <String> lstr, AlgoBot algobot)
        {
            List <UnpreparedTrainingsset> result = new List <UnpreparedTrainingsset>();
            Game n_game;

            if (!lstr.Contains(Game.BoardToString(i_game.Gameboard, i_game.turn)))
            {
                if (!i_game.over)//only save anything if there is a playble move afterwards
                {
                    int[] bestmove            = algobot.findBestMove(i_game, i_game.turn);
                    UnpreparedTrainingsset ut = new UnpreparedTrainingsset();
                    ut.inputGame  = i_game.Gameboard;
                    ut.turn       = i_game.turn;
                    ut.outputMove = bestmove;
                    result.Add(ut);
                    List <int[]> possibleMove = this.PossibleMoves(i_game);
                    for (int i = 0; i < possibleMove.Count; i++)
                    {
                        n_game = i_game.copy();
                        bool b = n_game.MakeMove(possibleMove[i][0], possibleMove[i][1], n_game.turn);
                        if (!b)
                        {
                            throw new Exception("nana");
                        }
                        List <UnpreparedTrainingsset> lst = getUnpreparedTrainingssets(n_game, lstr, algobot);
                        foreach (UnpreparedTrainingsset l in lst)
                        {
                            result.Add(l);
                            lstr.Add(Game.BoardToString(l.inputGame, i_game.turn));
                        }
                    }
                }
            }
            return(result);
        }