Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- public static void main(String[] args) {
- // false - BLACK, true - WHITE, null - NO PIECE
- final Boolean[] pieces = new Boolean[64];
- pieces[0] = false;
- pieces[0 + 7] = false;
- pieces[7 * 8] = true;
- pieces[7 * 8 + 7] = true;
- for (int i = 0; i < pieces.length; i++) {
- if (pieces[i] == null) {
- continue;
- }
- for (int k = 0; k < 8; k++) {
- final Boolean horizontalCheck = pieces[i / 8 + k];
- final Boolean verticalCheck = pieces[k * 8 + i % 8];
- if (verticalCheck != null && verticalCheck != pieces[i]) {
- System.out.println(i / 8 + ", " + i % 8 + " has attacking rook");
- break;
- }
- if (horizontalCheck != null && horizontalCheck != pieces[i]) {
- System.out.println(i / 8 + ", " + i % 8 + " has attacking rook");
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement