public override bool[,] PossibleMoviments() { bool[,] mat = new bool[Board.Lines, Board.Columns]; Position pos = new Position(0, 0); pos.SetValues(Position.Line + 2, Position.Column + 1); if (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; } pos.SetValues(Position.Line + 1, Position.Column + 2); if (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; } pos.SetValues(Position.Line - 2, Position.Column + 1); if (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; } pos.SetValues(Position.Line - 1, Position.Column + 2); if (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; } pos.SetValues(Position.Line - 2, Position.Column - 1); if (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; } pos.SetValues(Position.Line - 1, Position.Column - 2); if (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; } pos.SetValues(Position.Line + 2, Position.Column - 1); if (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; } pos.SetValues(Position.Line + 1, Position.Column - 2); if (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; } return(mat); }
public override bool[,] PossibleMoviments() { bool[,] mat = new bool[Board.Lines, Board.Columns]; Position pos = new Position(0, 0); //Above pos.SetValues(Position.Line - 1, Position.Column); while (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; if (Board.Piece(pos) != null && Board.Piece(pos).Color != this.Color) { break; } pos.Line = pos.Line - 1; } //Right pos.SetValues(Position.Line, Position.Column + 1); while (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; if (Board.Piece(pos) != null && Board.Piece(pos).Color != this.Color) { break; } pos.Column = pos.Column + 1; } //Below pos.SetValues(Position.Line + 1, Position.Column); while (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; if (Board.Piece(pos) != null && Board.Piece(pos).Color != this.Color) { break; } pos.Line = pos.Line + 1; } //Left pos.SetValues(Position.Line, Position.Column - 1); while (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; if (Board.Piece(pos) != null && Board.Piece(pos).Color != this.Color) { break; } pos.Column = pos.Column - 1; } return(mat); }
public override bool[,] PossibleMoviments() { bool[,] mat = new bool[Board.Lines, Board.Columns]; Position pos = new Position(0, 0); //northeast pos.SetValues(Position.Line - 1, Position.Column + 1); while (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; if (Board.Piece(pos) != null && Board.Piece(pos).Color != Color) { break; } pos.SetValues(pos.Line - 1, pos.Column + 1); } //Southeast pos.SetValues(Position.Line + 1, Position.Column + 1); while (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; if (Board.Piece(pos) != null && Board.Piece(pos).Color != Color) { break; } pos.SetValues(pos.Line + 1, pos.Column + 1); } //south-west pos.SetValues(Position.Line + 1, Position.Column - 1); while (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; if (Board.Piece(pos) != null && Board.Piece(pos).Color != Color) { break; } pos.SetValues(pos.Line + 1, pos.Column - 1); } //northwest pos.SetValues(Position.Line - 1, Position.Column - 1); while (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; if (Board.Piece(pos) != null && Board.Piece(pos).Color != Color) { break; } pos.SetValues(pos.Line - 1, pos.Column - 1); } return(mat); }
public override bool[,] PossibleMoviments() { bool[,] mat = new bool[Board.Lines, Board.Columns]; Position pos = new Position(0, 0); if (Color == Color.white) { pos.SetValues(Position.Line - 1, Position.Column); if (Board.validPositionTest(pos) && Free(pos)) { mat[pos.Line, pos.Column] = true; } pos.SetValues(Position.Line - 2, Position.Column); if (Board.validPositionTest(pos) && Free(pos) && MoveQuantity == 0) { mat[pos.Line, pos.Column] = true; } pos.SetValues(Position.Line - 1, Position.Column - 1); if (Board.validPositionTest(pos) && EnemyExist(pos)) { mat[pos.Line, pos.Column] = true; } pos.SetValues(Position.Line - 1, Position.Column + 1); if (Board.validPositionTest(pos) && EnemyExist(pos)) { mat[pos.Line, pos.Column] = true; } //#EspecialPlay en passant if (Position.Line == 3) { Position left = new Position(Position.Line, Position.Column - 1); if (Board.validPositionTest(left) && EnemyExist(left) && Board.Piece(left) == Match.VulnerableEnPassant) { mat[left.Line - 1, left.Column] = true; } Position right = new Position(Position.Line, Position.Column + 1); if (Board.validPositionTest(right) && EnemyExist(right) && Board.Piece(right) == Match.VulnerableEnPassant) { mat[right.Line - 1, right.Column] = true; } } } else { pos.SetValues(Position.Line + 1, Position.Column); if (Board.validPositionTest(pos) && Free(pos)) { mat[pos.Line, pos.Column] = true; } pos.SetValues(Position.Line + 2, Position.Column); if (Board.validPositionTest(pos) && Free(pos) && MoveQuantity == 0) { mat[pos.Line, pos.Column] = true; } pos.SetValues(Position.Line + 1, Position.Column - 1); if (Board.validPositionTest(pos) && EnemyExist(pos)) { mat[pos.Line, pos.Column] = true; } pos.SetValues(Position.Line + 1, Position.Column + 1); if (Board.validPositionTest(pos) && EnemyExist(pos)) { mat[pos.Line, pos.Column] = true; } //#EspecialPlay en passant if (Position.Line == 4) { Position left = new Position(Position.Line, Position.Column - 1); if (Board.validPositionTest(left) && EnemyExist(left) && Board.Piece(left) == Match.VulnerableEnPassant) { mat[left.Line + 1, left.Column] = true; } Position right = new Position(Position.Line, Position.Column + 1); if (Board.validPositionTest(right) && EnemyExist(right) && Board.Piece(right) == Match.VulnerableEnPassant) { mat[right.Line + 1, right.Column] = true; } } } return(mat); }
public override bool[,] PossibleMoviments() { bool[,] mat = new bool[Board.Lines, Board.Columns]; Position pos = new Position(0, 0); //Above pos.SetValues(Position.Line - 1, Position.Column); if (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; } //northeast pos.SetValues(Position.Line - 1, Position.Column + 1); if (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; } //right pos.SetValues(Position.Line, Position.Column + 1); if (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; } //Southeast pos.SetValues(Position.Line + 1, Position.Column + 1); if (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; } //below pos.SetValues(Position.Line + 1, Position.Column); if (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; } //south-west pos.SetValues(Position.Line + 1, Position.Column - 1); if (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; } //left pos.SetValues(Position.Line, Position.Column - 1); if (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; } //northwest pos.SetValues(Position.Line - 1, Position.Column - 1); if (Board.validPositionTest(pos) && CanMove(pos)) { mat[pos.Line, pos.Column] = true; } //#EspecialPlay rock if (MoveQuantity == 0 && !Match.Check) { //#EspecialPlay Small-Rock Position posT1 = new Position(Position.Line, Position.Column + 3); if (TestTowerRock(posT1)) { Position p1 = new Position(Position.Line, Position.Column + 1); Position p2 = new Position(Position.Line, Position.Column + 2); if (Board.Piece(p1) == null && Board.Piece(p2) == null) { mat[Position.Line, Position.Column + 2] = true; } } //#EspecialPlay Big-Rock Position posT2 = new Position(Position.Line, Position.Column - 4); if (TestTowerRock(posT2)) { Position p1 = new Position(Position.Line, Position.Column - 1); Position p2 = new Position(Position.Line, Position.Column - 2); Position p3 = new Position(Position.Line, Position.Column - 3); if (Board.Piece(p1) == null && Board.Piece(p2) == null && Board.Piece(p3) == null) { mat[Position.Line, Position.Column + 2] = true; } } } return(mat); }