GetInnerValue() public method

public GetInnerValue ( ) : ulong
return ulong
示例#1
0
        public void FromStringComplexTest()
        {
            int count = 100;
            var rand = new Random(DateTime.Now.Millisecond);

            while ((count--) > 0)
            {
                var board = new BitBoard();
                var str = new StringBuilder(64);
                str.Append('0', 64);

                var indices = GetRandomBits(rand.Next(64));
                foreach (var point in indices)
                {

                    board.SetBit((Square)(point.Item1*8 + point.Item2));

                    int index = (7 - point.Item1)*8 + point.Item2;
                    str[index] = '1';
                }

                Assert.AreEqual(
                    board.GetInnerValue(),
                    BitBoardHelper.FromString(str.ToString()));
            }
        }
示例#2
0
        public void Test1ByteMoves()
        {
            int count = 100000;

            while ((count--) > 0)
            {
                Square start = (Square)rand.Next(64);

                var board = new BitBoard();
                var randomSquares = GetRandomSquaresList(rand.Next(64));
                var moves = new List<Move>();

                foreach (var sq in randomSquares)
                {
                    board.SetBit(sq);
                    moves.Add(new Move(start, sq));
                }

                var serializedMoves = BitBoardSerializer.GetMoves(start, board.GetInnerValue()).ToList();

                bool isOk = true;

                if (serializedMoves.Count != moves.Count)
                    isOk = false;

                if (isOk)
                    for (int i = 0; i < serializedMoves.Count; ++i)
                        if ((moves[i].From != serializedMoves[i].From) ||
                            (moves[i].To != serializedMoves[i].To))
                        {
                            isOk = false;
                            break;
                        }

                Assert.IsTrue(isOk);
            }
        }
示例#3
0
        public void Test1ByteSquares()
        {
            int count = 100000;

            while ((count--) > 0)
            {
                var board = new BitBoard();
                var randomSquares = GetRandomSquaresList(rand.Next(64));

                foreach (var sq in randomSquares)
                    board.SetBit(sq);

                var serializedSquares = BitBoardSerializer.GetSquares(board.GetInnerValue()).Distinct().ToList();
                serializedSquares.Sort();
                Assert.IsTrue(
                     Enumerable.SequenceEqual(
                     	serializedSquares,
                     	randomSquares));
            }
        }