コード例 #1
0
 private void InitializeBoard()
 {
     board = new Board();
 }
コード例 #2
0
ファイル: computerAI.cs プロジェクト: Bang-Bang-Studios/AI
        public void MakeAIMove(Board board)
        {
            for (int i = 0; i < BOARDSIZE; i++)
                this._TempBoard[i] = board.GetPlayer(i);

            Hashtable hashTable = new Hashtable();
            Stopwatch sw = Stopwatch.StartNew();
            alphaBeta(this._TempBoard, 0, double.NegativeInfinity, double.PositiveInfinity, hashTable);
            sw.Stop();
            Console.WriteLine("Time taken: " + sw.Elapsed.TotalSeconds + " seconds.");
            //Console.WriteLine("_Choice: " + _Choice);
            //Console.WriteLine("_IsClockWise: " + _IsClockWise);
            //Console.WriteLine("_Quad: " + _Quad);
        }
コード例 #3
0
 private void InitializeBoard()
 {
     board = new Board();
     winningPoints = new List<Point>();
 }
コード例 #4
0
        public void MakeAIMove(Board board)
        {
            int enemyPieceCount = 0;
            int computerCount = 0;
            for (int i = 0; i < BOARDSIZE; i++)
            {
                this._TempBoard[i] = board.GetPlayer(i);
                if (this._TempBoard[i] == 1)
                    enemyPieceCount++;
                if (this._TempBoard[i] == 2)
                    computerCount++;
            }

            Stopwatch sw = null;
            Thread.Sleep(1000);

            if (this._DifficultyLevel == Difficulty.Hard && enemyPieceCount == 1 && computerCount == 0)
            {
                this._IsClockWise = true;
                this._Quad = (short)1;
                if (this._TempBoard[7] == 1)
                    this._Choice = 28;
                else if (this._TempBoard[10] == 1)
                    this._Choice = 25;
                else if (this._TempBoard[25] == 1)
                    this._Choice = 10;
                else if (this._TempBoard[28] == 1)
                    this._Choice = 7;
                else
                {
                    sw = Stopwatch.StartNew();
                    Hashtable hashTable = new Hashtable();
                    alphaBeta(this._TempBoard, 0, double.NegativeInfinity, double.PositiveInfinity, hashTable);
                    sw.Stop();
                    Console.WriteLine("Time taken: " + sw.Elapsed.TotalSeconds + " seconds.");
                    Console.WriteLine("Tree max: " + this._MaxTreeDepth);
                    Console.WriteLine("Computer level: " + this._DifficultyLevel);
                }

            }
            else
            {
                sw = Stopwatch.StartNew();
                Hashtable hashTable = new Hashtable();
                alphaBeta(this._TempBoard, 0, double.NegativeInfinity, double.PositiveInfinity, hashTable);
                sw.Stop();
                Console.WriteLine("Time taken: " + sw.Elapsed.TotalSeconds + " seconds.");
                Console.WriteLine("Tree max: " + this._MaxTreeDepth);
                Console.WriteLine("Computer level: " + this._DifficultyLevel);
            }
        }