public override bool[,] PossibleMoves() { bool[,] mat = new bool[Bd.Linhas, Bd.Colunas]; Position pos = new Position(0, 0); // up pos.DefineValue(Position.Linha - 1, Position.Coluna - 2); if (Bd.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } // ne pos.DefineValue(Position.Linha - 2, Position.Coluna - 1); if (Bd.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } pos.DefineValue(Position.Linha - 2, Position.Coluna + 1); if (Bd.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } pos.DefineValue(Position.Linha - 1, Position.Coluna + 2); if (Bd.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } pos.DefineValue(Position.Linha + 1, Position.Coluna + 2); if (Bd.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } pos.DefineValue(Position.Linha + 2, Position.Coluna + 1); if (Bd.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } pos.DefineValue(Position.Linha + 2, Position.Coluna - 1); if (Bd.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } pos.DefineValue(Position.Linha + 1, Position.Coluna - 2); if (Bd.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } return(mat); }
public override bool[,] PossibleMoves() { bool[,] mat = new bool[Bd.Linhas, Bd.Colunas]; Position pos = new Position(0, 0); // no pos.DefineValue(Position.Linha - 1, Position.Coluna - 1); while (Bd.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; if (Bd.Piece(pos) != null && Bd.Piece(pos).Color != Color) { break; } pos.DefineValue(pos.Linha - 1, pos.Coluna - 1); } // ne pos.DefineValue(Position.Linha - 1, Position.Coluna + 1); while (Bd.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; if (Bd.Piece(pos) != null && Bd.Piece(pos).Color != Color) { break; } pos.DefineValue(pos.Linha - 1, pos.Coluna + 1);; } // se pos.DefineValue(Position.Linha + 1, Position.Coluna + 1); while (Bd.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; if (Bd.Piece(pos) != null && Bd.Piece(pos).Color != Color) { break; } pos.DefineValue(pos.Linha + 1, pos.Coluna + 1); } // so pos.DefineValue(Position.Linha + 1, Position.Coluna - 1); while (Bd.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; if (Bd.Piece(pos) != null && Bd.Piece(pos).Color != Color) { break; } pos.DefineValue(pos.Linha + 1, pos.Coluna - 1); } return(mat); }
public override bool[,] PossibleMoves() { bool[,] mat = new bool[Bd.Linhas, Bd.Colunas]; Position pos = new Position(0, 0); if (Color == Color.White) { pos.DefineValue(Position.Linha - 1, Position.Coluna); if (Bd.ValidPosition(pos) && Free(pos)) { mat[pos.Linha, pos.Coluna] = true; } pos.DefineValue(Position.Linha - 2, Position.Coluna); Position p2 = new Position(Position.Linha - 1, Position.Coluna); if (Bd.ValidPosition(p2) && Free(p2) && Bd.ValidPosition(pos) && Free(pos) && QtMovies == 0) { mat[pos.Linha, pos.Coluna] = true; } pos.DefineValue(Position.Linha - 1, Position.Coluna - 1); if (Bd.ValidPosition(pos) && ExistEnemie(pos)) { mat[pos.Linha, pos.Coluna] = true; } pos.DefineValue(Position.Linha - 1, Position.Coluna + 1); if (Bd.ValidPosition(pos) && ExistEnemie(pos)) { mat[pos.Linha, pos.Coluna] = true; } //# Jogada especial enPassant if (Position.Linha == 3) { Position left = new Position(Position.Linha, Position.Coluna - 1); if (Bd.ValidPosition(left) && ExistEnemie(left) && Bd.Piece(left) == match.vulnerableEnPassant) { mat[left.Linha - 1, left.Coluna] = true; } Position right = new Position(Position.Linha, Position.Coluna + 1); if (Bd.ValidPosition(right) && ExistEnemie(right) && Bd.Piece(right) == match.vulnerableEnPassant) { mat[right.Linha - 1, right.Coluna] = true; } } } else { pos.DefineValue(Position.Linha + 1, Position.Coluna); if (Bd.ValidPosition(pos) && Free(pos)) { mat[pos.Linha, pos.Coluna] = true; } pos.DefineValue(Position.Linha + 2, Position.Coluna); Position p2 = new Position(Position.Linha + 1, Position.Coluna); if (Bd.ValidPosition(p2) && Free(p2) && Bd.ValidPosition(pos) && Free(pos) && QtMovies == 0) { mat[pos.Linha, pos.Coluna] = true; } pos.DefineValue(Position.Linha + 1, Position.Coluna - 1); if (Bd.ValidPosition(pos) && ExistEnemie(pos)) { mat[pos.Linha, pos.Coluna] = true; } pos.DefineValue(Position.Linha + 1, Position.Coluna + 1); if (Bd.ValidPosition(pos) && ExistEnemie(pos)) { mat[pos.Linha, pos.Coluna] = true; } //# Jogada especial enPassant if (Position.Linha == 4) { Position left = new Position(Position.Linha, Position.Coluna - 1); if (Bd.ValidPosition(left) && ExistEnemie(left) && Bd.Piece(left) == match.vulnerableEnPassant) { mat[left.Linha + 1, left.Coluna] = true; } Position right = new Position(Position.Linha, Position.Coluna + 1); if (Bd.ValidPosition(right) && ExistEnemie(right) && Bd.Piece(right) == match.vulnerableEnPassant) { mat[right.Linha + 1, right.Coluna] = true; } } } return(mat); }
public override bool[,] PossibleMoves() { bool[,] mat = new bool[Bd.Linhas, Bd.Colunas]; Position pos = new Position(0, 0); // up pos.DefineValue(Position.Linha - 1, Position.Coluna); if (Bd.ValidPosition(pos) && CanMove(pos)) { mat [pos.Linha, pos.Coluna] = true; } // ne pos.DefineValue(Position.Linha - 1, Position.Coluna + 1); if (Bd.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } //right pos.DefineValue(Position.Linha, Position.Coluna + 1); if (Bd.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } //se pos.DefineValue(Position.Linha + 1, Position.Coluna + 1); if (Bd.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } //down pos.DefineValue(Position.Linha + 1, Position.Coluna); if (Bd.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } //sw pos.DefineValue(Position.Linha + 1, Position.Coluna - 1); if (Bd.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } //left pos.DefineValue(Position.Linha, Position.Coluna - 1); if (Bd.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } //nw pos.DefineValue(Position.Linha - 1, Position.Coluna - 1); if (Bd.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } //# Jogada especial Roque if (QtMovies == 0 && !match.Check) { //# Jogada especial roque pequeno Position PosT1 = new Position(Position.Linha, Position.Coluna + 3); if (TestTowerforRoque(PosT1)) { Position p1 = new Position(Position.Linha, Position.Coluna + 1); Position p2 = new Position(Position.Linha, Position.Coluna + 2); if (Bd.Piece(p1) == null && Bd.Piece(p2) == null) { mat[Position.Linha, Position.Coluna + 2] = true; } } //# Jogada especial roque grande Position PosT2 = new Position(Position.Linha, Position.Coluna - 4); if (TestTowerforRoque(PosT2)) { Position p1 = new Position(Position.Linha, Position.Coluna - 1); Position p2 = new Position(Position.Linha, Position.Coluna - 2); Position p3 = new Position(Position.Linha, Position.Coluna - 3); if (Bd.Piece(p1) == null && Bd.Piece(p2) == null && Bd.Piece(p3) == null) { mat[Position.Linha, Position.Coluna - 2] = true; } } } return(mat); }