示例#1
0
        static void test_2()
        {
            SimplePlayer player = new SimplePlayer(Side.Zero, 2);
            player.EnemyTurn(new Position(4, 5));
            Position p = player.MakeNextTurn();

            Console.WriteLine("Turn found {0},{1}", p.X, p.Y);
        }
示例#2
0
 public MachinePlayer(Board board, Side side, int level  )
 {
     playerAI = new SimplePlayer(side, board, level);
     timeToMakeTheTurn = ( side == CoreCZ.Side.Cross );
     this.board = board;
     this.side = side;
     this.level = level;
 }
示例#3
0
        static void test_performance(int runs = 10)
        {
            CoreCZ.AI.SimpleCostFuntcion.startProfiling = start;
            CoreCZ.AI.SimpleCostFuntcion.endProfiling = stop;

            double[] times = new double[runs];

            for (int i = 0; i < runs; ++i)
            {
                Board board = new Board();
                SimplePlayer cross = new SimplePlayer(Side.Cross, 2);
                SimplePlayer zero = new SimplePlayer(Side.Zero, 2);

                int counter = 0;
                Console.Write("{0:D2}", i);
                var start_time = DateTime.Now;
                while (counter < 12)
                {

                    Position p = cross.MakeNextTurn();
                    board[p] = Side.Cross;
                    counter++;
                    Console.Write(".");
                    if (board.Winner) break;
                    zero.EnemyTurn(p);

                    p = zero.MakeNextTurn();
                    board[p] = Side.Zero;
                    counter++;
                    Console.Write(".");
                    if (board.Winner) break;
                    cross.EnemyTurn(p);
                }
                Console.WriteLine();
                times[i] = (DateTime.Now - start_time).TotalMilliseconds;
            }

            var max_time = times.Max() / 1000;
            var min_time = times.Min() / 1000;
            var avg_time = times.Average() / 1000;

            Console.WriteLine("Average time: {0:F3}", avg_time);
            Console.WriteLine("    max time: {0:F3}", max_time);
            Console.WriteLine("    min time: {0:F3}", min_time);

            Console.WriteLine("SimpleCostFunction: {0:F3}", costFunctionTimer.ElapsedMilliseconds/1000.0);
            Console.WriteLine("SimpleCostFunction: {0} calls, {1} cache hits", SimpleCostFuntcion.calls, SimpleCostFuntcion.cache_hits);
        }
示例#4
0
        static void test_scenario()
        {
            var board = @"
            o_x_
            _xxx
            _ox_
            o_o_";

            Scenario s = new Scenario(board);

            var player = new SimplePlayer(s.Play(), Side.Zero, 2);
            Position p = player.MakeNextTurn();
        }
示例#5
0
 public override void Reset()
 {
     playerAI = new SimplePlayer(side, level);
 }