예제 #1
0
 public void Run()
 {
     Console.WriteLine(CurrentState.ToString());
     while (true)
     {
         if (TestWin())
         {
             return;
         }
         Console.WriteLine(SelectTargetString);
         Console.WriteLine(XyPositionString);
         var fromX = Convert.ToInt16(Console.ReadKey().KeyChar.ToString());
         var fromY = Convert.ToInt16(Console.ReadKey().KeyChar.ToString());
         Console.WriteLine(SelecttargetLocationString);
         Console.WriteLine(XyPositionString);
         var toX        = Convert.ToInt16(Console.ReadKey().KeyChar.ToString());
         var toY        = Convert.ToInt16(Console.ReadKey().KeyChar.ToString());
         var moveStatus = this.HandleUserMove(CurrentState, fromX, fromY, toX, toY);
         if (moveStatus == Move.MoveStatus.NoError)
         {
             Console.WriteLine(CurrentState);
             if (TestWin())
             {
                 return;
             }
             Console.WriteLine("Now it's Computer's turn... ");
             CurrentState = (AlphaBetaSearch.DoSearch(CurrentState, 1));
         }
         Console.Clear();
         Console.WriteLine(CurrentState.ToString());
     }
 }
예제 #2
0
        public void TestLevel4()
        {
            var choosenState = AlphaBetaSearch.DoSearch(_state, 4);

            Console.WriteLine(choosenState.ToString());
            Assert.AreEqual(true, true);
        }
예제 #3
0
        public void TestMovePieceSimple()
        {
            var states = new State();

            states = PieceMove.MovePiece(states, 7, 7, 4, 7);//user

            Debug.WriteLine(states.ToString());
            //states = PieceMove.MovePiece(states, 1, 2, 1, 9);//com
            states = (AlphaBetaSearch.DoSearch(states, 1));
            Debug.WriteLine(states.ToString());
            states = PieceMove.MovePiece(states, 0, 9, 1, 9);//user
            Debug.WriteLine(states.ToString());
            Assert.AreEqual(30, states.GetPieceList().Count);
            var piece = PieceFactory.GetPiece(23, 1, 9);

            Assert.AreEqual(typeof(Rook), piece.GetType());
        }