Ejemplo n.º 1
0
        //public PieceMap<int, IPiece> PieceList
        //{
        //    get => _pieceList;
        //    private set => _pieceList = value;
        //}



        public static void InitializePieceStateList()
        {
            if (InitIntList == null)
            {
                return;
            }
            var iterator = InitIntList.GetEnumerator();

            for (var y = 0; y <= 9; y++)
            {
                for (var x = 0; x <= 8; x++)
                {
                    if (!iterator.MoveNext())
                    {
                        continue;
                    }
                    var    i     = iterator.Current;
                    IPiece piece = PieceFactory.GetPiece(i, x, y);
                    if (i != 0)
                    {
                        InitPieceList.GetOrAdd(piece.GetK(), piece);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private PieceMap <int, IPiece> ClonePieceList()
        {
            var list = new PieceMap <int, IPiece>(PieceFactory.GetPiece(0, 10, 10));

            var pieces = _pieceList.Values;

            foreach (var piece in pieces)
            {
                list.TryAdd(piece.GetK(), (IPiece)piece.Clone());
            }
            return(list);
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 4
0
        public void TestGetEmptyPiece()
        {
            var piece = PieceFactory.GetPiece(0, 0, 9);

            Assert.AreEqual(typeof(Empty), piece.GetType());
        }
Ejemplo n.º 5
0
        public void TestGetRookPiece()
        {
            var piece = PieceFactory.GetPiece(23, 1, 9);

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