Ejemplo n.º 1
0
        public override void WriteResults(System.IO.TextWriter tw)
        {
            var arr = this.data as ulong[];

            foreach (var item in arr)
            {
                tw.WriteLine(BitBoardHelper.ToString(item, "\n"));
                tw.WriteLine();
            }

            //tw.WriteLine(BitBoardHelper.ToString(0x0000000080402000UL, "\n"));
        }
Ejemplo n.º 2
0
        public void TestReverseUlong()
        {
            int count = 10000;

            while ((count--) > 0)
            {
                string str        = Get64CharsString();
                ulong  board      = BitBoardHelper.FromString(str);
                ulong  reversed   = Int64Helper.GetReversedUlong(board);
                ulong  rereversed = Int64Helper.GetReversedUlong(reversed);

                Assert.AreEqual(str.MyReverse(), BitBoardHelper.ToString(reversed, string.Empty).LJust(64, '0'));
                Assert.AreEqual(board, rereversed);
            }
        }
Ejemplo n.º 3
0
        public void FromStringTest()
        {
            string boardString =
                "00000000" +
                "00101110" +
                "00001000" +
                "00010000" +
                "00010000" +
                "01000000" +
                "00100010" +
                "00100010";

            var board     = BitBoardHelper.FromString(boardString);
            var newString = BitBoardHelper.ToString(board, string.Empty);

            Assert.AreEqual(boardString, newString);
        }
Ejemplo n.º 4
0
        public void ToStringComplexTest()
        {
            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)
                {
                    Square sq = (Square)(point.Item1 * 8 + point.Item2);
                    board.SetBit(sq);
                    int index = (7 - point.Item1) * 8 + point.Item2;
                    str[index] = '1';
                }

                Assert.AreEqual(str.ToString(),
                                BitBoardHelper.ToString(board.GetInnerValue(), string.Empty));
            }
        }
Ejemplo n.º 5
0
 public override string ToString()
 {
     return(BitBoardHelper.ToString(this.board, "\n"));
 }
Ejemplo n.º 6
0
 protected string GetBoardString(ulong board)
 {
     return(BitBoardHelper.ToString(board, "\n"));
 }