Example #1
0
        public double score()
        {
            int win = 0;
            int lose = 0;
            int draw = 0;

            for (int i = 0; i < NeuralTicTacToe.SCORE_SAMPLE; i++) {

                Player[] players = new Player[2];
                players [0] = this.player;
                players [1] = this.aganst;
                Game game = new Game (players);
                Player winner = game.play ();

                if (this.verbose) {
                    Console.WriteLine ("Game #" + i + ":" + winner);
                    game.printBoard ();
                }

                if (winner == this.player) {
                    win++;
                } else if (winner == this.aganst) {
                    lose++;
                } else {
                    draw++;
                }
            }

            if (this.verbose) {
                Console.WriteLine ("Win:" + win);
                Console.WriteLine ("Lose:" + lose);
                Console.WriteLine ("Draw:" + draw);
            }

            double score = (win * WIN_POINTS) + (lose * LOSE_POINTS)
                           + (draw * DRAW_POINTS);

            double s = (PERFECT_SCORE - score) / PERFECT_SCORE;

            if (s < 0) {
                return -1;
            }
            return s;
        }
Example #2
0
        public void singleGame()
        {
            Game.Game game = null;

            Player[] players = new Player[2];
            players [0] = this.player1;
            players [1] = this.player2;
            game = new Game.Game (players);
            Player winner = game.play ();
            Console.WriteLine ("Winner is:" + winner);
        }