Exemplo n.º 1
0
 public ChessBoard(ChessBoard c)
 {
     for (int i = 0; i <= pieceIndex.FLAGS; i++)
     {
         white[i] = new BitboardLayer(c.getDict(true)[i]);
         black[i] = new BitboardLayer(c.getDict(false)[i]);
     }
     white_ep = c.getEP(true);
     black_ep = c.getEP(false);
     moveList = new List<int[]>(c.getMoveList());
     moveNum = c.getMoveNum();
     ASG = c.getASG();
 }
Exemplo n.º 2
0
        List<int[]> getPossibleMoves(ChessBoard c, bool isWhite)
        {
            var retVal = new List<int[]>();
            BitboardLayer[] dict = c.getDict(isWhite);
            BitboardLayer[] enemyDict = c.getDict(!isWhite);

            foreach (int i in dict[pieceIndex.ALL_LOCATIONS].getTrueIndicies()) {
                BitboardLayer pieceMoves = c.getValidMoves(isWhite, i);
                foreach (int j in pieceMoves.getTrueIndicies())
                {
                    retVal.Add(new int[] { i, j });
                }
            }
            return retVal;
        }
Exemplo n.º 3
0
 public bool equals(ChessBoard c)
 {
     BitboardLayer[] test_white = c.getDict(true);
     BitboardLayer[] test_black = c.getDict(false);
     for (int i = 0; i <= pieceIndex.FLAGS; i++)
     {
         if (test_white[i].getLayerData() != white[i].getLayerData()) return false;
         if (test_black[i].getLayerData() != black[i].getLayerData()) return false;
     }
     return true;
 }
Exemplo n.º 4
0
        public string displayBoard(ChessBoard c)
        {
            //for debugging purposes
            //capital letters are white, n's are knights
            char[] whiteLetters = new char[] { 'P', 'R', 'N', 'B', 'Q', 'K' };
            char[] blackLetters = new char[] {  'p', 'r', 'n', 'b', 'q', 'k' };

            char[] retVal = new char[64];
            for (int i = 0; i < 64; i++) retVal[i] = Convert.ToChar("+");
            BitboardLayer[] white = c.getDict(true);
            BitboardLayer[] black = c.getDict(false);
            for (int i = 0; i <= pieceIndex.KING; i++){
                foreach (int j in white[i].getTrueIndicies()) retVal[j] = whiteLetters[i];
                foreach (int j in black[i].getTrueIndicies()) retVal[j] = blackLetters[i];
            }
            string s = "";
            for (int i = 0; i < 64; i++){
                s += retVal[i];
                if (i % 8 == 7) s += "\n";
            }
            var ml = c.getMoveList();
            for (int i = 0; i < ml.Count; i++)
            {
                s += (i % 2 == 0 ? "White" : "Black") + ": [" + ml[i][0] + ", " + ml[i][1] + "]\n";
            }
            return s;
        }