public override bool[,] possibleMoves() { bool[,] mat = new bool[Board.RowBoard, Board.ColumnBoard]; Position pos = new Position(0, 0); //north pos.defineValue(Position.Row - 1, Position.Column); while (Board.positionValue(pos) && canMove(pos)) { mat[pos.Row, pos.Column] = true; if (Board.piece(pos) != null && Board.piece(pos).Color != Color) { break; } pos.Row = pos.Row - 1; } //south pos.defineValue(Position.Row + 1, Position.Column); while (Board.positionValue(pos) && canMove(pos)) { mat[pos.Row, pos.Column] = true; if (Board.piece(pos) != null && Board.piece(pos).Color != Color) { break; } pos.Row = pos.Row + 1; } //east pos.defineValue(Position.Row, Position.Column + 1); while (Board.positionValue(pos) && canMove(pos)) { mat[pos.Row, pos.Column] = true; if (Board.piece(pos) != null && Board.piece(pos).Color != Color) { break; } pos.Column = pos.Column + 1; } //west pos.defineValue(Position.Row, Position.Column - 1); while (Board.positionValue(pos) && canMove(pos)) { mat[pos.Row, pos.Column] = true; if (Board.piece(pos) != null && Board.piece(pos).Color != Color) { break; } pos.Column = pos.Column - 1; } return(mat); }
public override bool[,] possibleMoves() { bool[,] mat = new bool[Board.RowBoard, Board.ColumnBoard]; Position pos = new Position(0, 0); //north pos.defineValue(Position.Row - 1, Position.Column); if (Board.positionValue(pos) && canMove(pos)) { mat[pos.Row, pos.Column] = true; } //northeast pos.defineValue(Position.Row - 1, Position.Column + 1); if (Board.positionValue(pos) && canMove(pos)) { mat[pos.Row, pos.Column] = true; } //east pos.defineValue(Position.Row, Position.Column + 1); if (Board.positionValue(pos) && canMove(pos)) { mat[pos.Row, pos.Column] = true; } //southeast pos.defineValue(Position.Row + 1, Position.Column + 1); if (Board.positionValue(pos) && canMove(pos)) { mat[pos.Row, pos.Column] = true; } //south pos.defineValue(Position.Row + 1, Position.Column); if (Board.positionValue(pos) && canMove(pos)) { mat[pos.Row, pos.Column] = true; } //southwest pos.defineValue(Position.Row + 1, Position.Column - 1); if (Board.positionValue(pos) && canMove(pos)) { mat[pos.Row, pos.Column] = true; } //west pos.defineValue(Position.Row, Position.Column - 1); if (Board.positionValue(pos) && canMove(pos)) { mat[pos.Row, pos.Column] = true; } //northweast pos.defineValue(Position.Row - 1, Position.Column - 1); if (Board.positionValue(pos) && canMove(pos)) { mat[pos.Row, pos.Column] = true; } return(mat); }