示例#1
0
        public string getBoardText()
        {
            string t = "";

            for (int y = 0; y < board.getHeight(); y++)
            {
                for (int x = 0; x < board.getWidth(); x++)
                {
                    Piece p = board.getCellContents(y, x);
                    if (p == null)
                    {
                        t += "n";
                    }
                    else
                    {
                        if (p.getColor() == PieceColor.BLACK)
                        {
                            t += "b";
                        }
                        else
                        {
                            t += "r";
                        }
                    }
                }
                t += "\n";
            }
            return(t);
        }
 public static Board deepCopy(Board b)
 {
     Board newB = new Board(b.getHeight(), b.getWidth());
     for (int y = 0; y < newB.getHeight(); y++) {
         for (int x = 0; x < newB.getWidth(); x++) {
             Piece p = b.getCellContents(y, x);
             if (p != null) {
                 newB.addPieceToCell(new Piece(p));
             }
         }
     }
     return newB;
 }
示例#3
0
        public static Board deepCopy(Board b)
        {
            Board newB = new Board(b.getHeight(), b.getWidth());

            for (int y = 0; y < newB.getHeight(); y++)
            {
                for (int x = 0; x < newB.getWidth(); x++)
                {
                    Piece p = b.getCellContents(y, x);
                    if (p != null)
                    {
                        newB.addPieceToCell(new Piece(p));
                    }
                }
            }
            return(newB);
        }