private void repaint(int row1, int col1, int playerID)
        {
            upDateGameStatus(row1, col1, playerID);
            List<Object> visualItems = new List<Object>();
            foreach (var item in UIBoard.Children)
                visualItems.Add(item);
            UIBoard.Children.Clear();
            foreach (var item in visualItems)
            {

                if (item is Square)
                {

                    Square square = item as Square;
                    int row = (int)square.GetValue(Grid.RowProperty);
                    int col = (int)square.GetValue(Grid.ColumnProperty);
                    switch (board.GetPieceColor(row, col))
                    {
                        case 0:
                            if (board.IsValidMove(row, col) && board.GetCurrentPlayerID() != alg.ComputerPlayerID)
                            {
                                square.rectangle.Fill = Brushes.Red;
                                UIBoard.Children.Add(square);
                            }
                            else
                            {
                                square.rectangle.Fill = sqareBaseColor;
                                UIBoard.Children.Add(square);
                            }
                            break;

                        case 1:
                            WhiteReversiSquare ws = new WhiteReversiSquare();
                            ws.SetValue(Grid.ColumnProperty, col);
                            ws.SetValue(Grid.RowProperty, row);
                            ws.Tag = 1;
                            UIBoard.Children.Add(ws);
                            break;
                        case -1:
                            BlackReversiSquare bs = new BlackReversiSquare();
                            bs.Tag = -1;
                            bs.SetValue(Grid.ColumnProperty, col);
                            bs.SetValue(Grid.RowProperty, row);
                            UIBoard.Children.Add(bs);
                            break;

                    }
                }
                if (item is BlackReversiSquare)
                {
                    BlackReversiSquare bs = item as BlackReversiSquare;
                    int row = (int)bs.GetValue(Grid.RowProperty);
                    int col = (int)bs.GetValue(Grid.ColumnProperty);
                    int oldColor = int.Parse(bs.Tag.ToString());
                    int newColor = board.GetPieceColor(row,col);
                    UIBoard.Children.Add(bs);
                    if (newColor != oldColor)
                    {
                        bs.Tag = newColor.ToString();
                        if (oldColor == 1)
                        {
                            Storyboard story = bs.FindResource("SpinWhiteBlack") as Storyboard;
                            story.Begin();

                        }
                        else
                        {
                            Storyboard story = bs.FindResource("SpinBlackWhite") as Storyboard;
                            story.Begin();
                        }
                    }
                }
                if (item is WhiteReversiSquare)
                {
                    WhiteReversiSquare ws = item as WhiteReversiSquare;
                    int row = (int)ws.GetValue(Grid.RowProperty);
                    int col = (int)ws.GetValue(Grid.ColumnProperty);
                    int oldColor = int.Parse(ws.Tag.ToString());
                    int newColor = board.GetPieceColor(row, col);
                    UIBoard.Children.Add(ws);
                    if (newColor != oldColor)
                    {
                        ws.Tag = newColor.ToString();
                        if (oldColor == 1)
                        {
                            Storyboard story = ws.FindResource("SpinWhiteBlack") as Storyboard;
                            story.Begin();

                        }
                        else
                        {
                            Storyboard story = ws.FindResource("SpinBlackWhite") as Storyboard;
                            story.Begin();
                        }
                    }
                }

            }
        }
        private void intializeVisualBoard()
        {
            UIBoard.Children.Clear();
            for (int row = 0; row < 8; ++row)
                for (int col = 0; col < 8; ++col)
                {

                    switch (board.GetPieceColor(row, col))
                    {
                        case 0:
                            Square square = new Square();
                            square.SetValue(Grid.ColumnProperty, col);
                            square.SetValue(Grid.RowProperty, row);
                            square.MouseDown += new MouseButtonEventHandler(square_MouseDown);
                            square.Tag = 6;
                            sqareBaseColor = square.rectangle.Fill;
                            if (board.IsValidMove(row, col))
                                square.rectangle.Fill = Brushes.Red;

                            UIBoard.Children.Add(square);
                            break;
                        case 1:
                            WhiteReversiSquare ws = new WhiteReversiSquare();
                            ws.SetValue(Grid.ColumnProperty, col);
                            ws.SetValue(Grid.RowProperty, row);
                            ws.Tag = 1;
                            UIBoard.Children.Add(ws);
                            break;
                        case -1:
                            BlackReversiSquare bs = new BlackReversiSquare();
                            bs.Tag = -1;
                            bs.SetValue(Grid.ColumnProperty, col);
                            bs.SetValue(Grid.RowProperty, row);
                            UIBoard.Children.Add(bs);
                            break;

                    }

                }
        }