public override bool[,] PossibleMovments() { bool[,] mat = new bool[Chess.Linhas, Chess.Colunas]; Posicao pos = new Posicao(0, 0); pos.DefinaValues(Position.Linha - 1, Position.Coluna - 2); if (Chess.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } pos.DefinaValues(Position.Linha - 2, Position.Coluna - 1); if (Chess.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } pos.DefinaValues(Position.Linha - 2, Position.Coluna + 1); if (Chess.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } pos.DefinaValues(Position.Linha - 1, Position.Coluna + 2); if (Chess.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } pos.DefinaValues(Position.Linha - 2, Position.Coluna + 1); if (Chess.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } pos.DefinaValues(Position.Linha - 1, Position.Coluna + 2); if (Chess.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } pos.DefinaValues(Position.Linha + 1, Position.Coluna + 2); if (Chess.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } pos.DefinaValues(Position.Linha + 2, Position.Coluna + 1); if (Chess.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } pos.DefinaValues(Position.Linha + 2, Position.Coluna - 1); if (Chess.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } pos.DefinaValues(Position.Linha + 1, Position.Coluna - 2); if (Chess.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } return(mat); }
public override bool[,] PossibleMovments() { bool[,] mat = new bool[Chess.Linhas, Chess.Colunas]; Posicao pos = new Posicao(0, 0); //ACIMA pos.DefinaValues(Position.Linha - 1, Position.Coluna); while (Chess.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; if (Chess.Piece(pos) != null && Chess.Piece(pos).Cor != Cor) { break; } pos.Linha = pos.Linha - 1; } //Down pos.DefinaValues(Position.Linha + 1, Position.Coluna); while (Chess.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; if (Chess.Piece(pos) != null && Chess.Piece(pos).Cor != Cor) { break; } pos.Linha = pos.Linha + 1; } //RIGHT pos.DefinaValues(Position.Linha, Position.Coluna + 1); while (Chess.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; if (Chess.Piece(pos) != null && Chess.Piece(pos).Cor != Cor) { break; } pos.Coluna = pos.Coluna + 1; } //LEFT pos.DefinaValues(Position.Linha, Position.Coluna - 1); while (Chess.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; if (Chess.Piece(pos) != null && Chess.Piece(pos).Cor != Cor) { break; } pos.Coluna = pos.Coluna - 1; } return(mat); }
public override bool[,] PossibleMovments() { bool[,] mat = new bool[Chess.Linhas, Chess.Colunas]; Posicao pos = new Posicao(0, 0); if (Cor == Color.White) { pos.DefinaValues(Position.Linha - 1, Position.Coluna); if (Chess.ValidPosition(pos) && Open(pos)) { mat[pos.Linha, pos.Coluna] = true; } pos.DefinaValues(Position.Linha - 2, Position.Coluna); if (Chess.ValidPosition(pos) && Open(pos) && QuantidadeMovimentos == 0) { mat[pos.Linha, pos.Coluna] = true; } pos.DefinaValues(Position.Linha - 1, Position.Coluna - 1); if (Chess.ValidPosition(pos) && ExistsEnemy(pos)) { mat[pos.Linha, pos.Coluna] = true; } pos.DefinaValues(Position.Linha - 1, Position.Coluna + 1); if (Chess.ValidPosition(pos) && ExistsEnemy(pos)) { mat[pos.Linha, pos.Coluna] = true; } //EN PASSANT if (Position.Linha == 3) { Posicao left = new Posicao(Position.Linha, Position.Coluna - 1); if (Chess.ValidPosition(left) && ExistsEnemy(left) && Chess.Piece(left) == Game.VulnerablyEnPassant) { mat[left.Linha - 1, left.Coluna] = true; } Posicao right = new Posicao(Position.Linha, Position.Coluna + 1); if (Chess.ValidPosition(right) && ExistsEnemy(right) && Chess.Piece(right) == Game.VulnerablyEnPassant) { mat[right.Linha - 1, right.Coluna] = true; } } } else { pos.DefinaValues(Position.Linha + 1, Position.Coluna); if (Chess.ValidPosition(pos) && Open(pos)) { mat[pos.Linha, pos.Coluna] = true; } pos.DefinaValues(Position.Linha + 2, Position.Coluna); if (Chess.ValidPosition(pos) && Open(pos) && QuantidadeMovimentos == 0) { mat[pos.Linha, pos.Coluna] = true; } pos.DefinaValues(Position.Linha + 1, Position.Coluna - 1); if (Chess.ValidPosition(pos) && ExistsEnemy(pos)) { mat[pos.Linha, pos.Coluna] = true; } pos.DefinaValues(Position.Linha + 1, Position.Coluna + 1); if (Chess.ValidPosition(pos) && ExistsEnemy(pos)) { mat[pos.Linha, pos.Coluna] = true; } //EN PASSANT if (Position.Linha == 4) { Posicao left = new Posicao(Position.Linha, Position.Coluna - 1); if (Chess.ValidPosition(left) && ExistsEnemy(left) && Chess.Piece(left) == Game.VulnerablyEnPassant) { mat[left.Linha + 1, left.Coluna] = true; } Posicao right = new Posicao(Position.Linha, Position.Coluna + 1); if (Chess.ValidPosition(right) && ExistsEnemy(right) && Chess.Piece(right) == Game.VulnerablyEnPassant) { mat[right.Linha + 1, right.Coluna] = true; } } } return(mat); }
public override bool[,] PossibleMovments() { bool[,] mat = new bool[Chess.Linhas, Chess.Colunas]; Posicao pos = new Posicao(0, 0); //UP pos.DefinaValues(Position.Linha - 1, Position.Coluna); if (Chess.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } //Ne pos.DefinaValues(Position.Linha - 1, Position.Coluna + 1); if (Chess.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } //Right pos.DefinaValues(Position.Linha, Position.Coluna + 1); if (Chess.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } //Se pos.DefinaValues(Position.Linha + 1, Position.Coluna + 1); if (Chess.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } //Down pos.DefinaValues(Position.Linha + 1, Position.Coluna); if (Chess.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } //So pos.DefinaValues(Position.Linha + 1, Position.Coluna - 1); if (Chess.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } //Left pos.DefinaValues(Position.Linha, Position.Coluna - 1); if (Chess.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } //No pos.DefinaValues(Position.Linha - 1, Position.Coluna - 1); if (Chess.ValidPosition(pos) && CanMove(pos)) { mat[pos.Linha, pos.Coluna] = true; } //######Rockie if (QuantidadeMovimentos == 0 & !Game.Check) { //rockie Pequeno Posicao positionTower = new Posicao(Position.Linha, Position.Coluna + 3); if (TestTowerToRockie(positionTower)) { Posicao p1 = new Posicao(Position.Linha, Position.Coluna + 1); Posicao p2 = new Posicao(Position.Linha, Position.Coluna + 2); if (Chess.Piece(p1) == null && Chess.Piece(p2) == null) { mat[Position.Linha, Position.Coluna + 2] = true; } } //rockie Grande Posicao positionTower2 = new Posicao(Position.Linha, Position.Coluna - 4); if (TestTowerToRockie(positionTower2)) { Posicao p1 = new Posicao(Position.Linha, Position.Coluna - 1); Posicao p2 = new Posicao(Position.Linha, Position.Coluna - 2); Posicao p3 = new Posicao(Position.Linha, Position.Coluna - 3); if (Chess.Piece(p1) == null && Chess.Piece(p2) == null && Chess.Piece(p3) == null) { mat[Position.Linha, Position.Coluna - 2] = true; } } } return(mat); }