private void drawMove(Pen p, DataGridViewCellPaintingEventArgs e, Move.DIRECTION direction) { if (p.Color == Color.Blue) { Move m = new Move(e.RowIndex, e.ColumnIndex, direction); //game.getPlayer1().makeMove(m); game.getGameState().addMove(m, p.Color); richTextBox1.Text += game.map(m) + "\n"; } else { Move m = new Move(e.RowIndex, e.ColumnIndex, direction); game.getGameState().addMove(m, p.Color); //game.getPlayer2().makeMove(m); richTextBox1.Text += game.map(m) + "\n"; } }
public Board GenerateBoardByExecutingMove(Move M) { int row = M.tileRow; int cell = M.tileCell; Move.DIRECTION direction = M.Direction; int targetRow = 0; int targetCell = 0; switch (direction) { case Move.DIRECTION.UP: targetRow = row - 1; targetCell = cell; break; case Move.DIRECTION.DOWN: targetRow = row + 1; targetCell = cell; break; case Move.DIRECTION.LEFT: targetRow = row; targetCell = cell - 1; break; case Move.DIRECTION.RIGHT: targetRow = row; targetCell = cell + 1; break; } int targetValue = tiles[targetRow, targetCell]; int sourceValue = tiles[row, cell]; Board B = new Board(this.tiles.Clone() as int[, ]); // swap B.tiles.SetValue(sourceValue, new int[] { targetRow, targetCell }); B.tiles.SetValue(targetValue, new int[] { row, cell }); return(B); }