private void PopulateBoard() { controller = new ChessController("../../../ChessTest/test_data/start.txt"); gridBoard.Columns = 8; gridBoard.Rows = 8; // Set-up events for when pieces are moved or placed. controller.game.ChessBoard.OnPieceMoved += ChessBoard_OnPieceMoved; controller.game.ChessBoard.OnPiecePlaced += ChessBoard_OnPiecePlaced; controller.game.OnMoveFailure += Game_OnMoveFailure; controller.game.OnCheckMate += Game_OnCheckMate; // Bind player's move to label. lblTurn.DataContext = controller.game; Binding binding = new Binding("WhiteToMove"); binding.Converter = new BoolToMessageConverter(); lblTurn.SetBinding(Label.ContentProperty, binding); // Populate grid with tiles for (int i = 7; i >= 0; i--) { for (int j = 0; j < 8; j++) { Color color = (i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1) ? darkSlate : softWhite; Tuple <int, int> position = new Tuple <int, int>(i, j); Tile tile = new Tile(color); tiles.Add(position, tile); gridBoard.Children.Add(tile.Grid); } } controller.PlayFromFile(); }
static void Main(string[] args) { ChessController chess = new ChessController(args[0]); chess.PlayFromFile(); }