Advertisement
gasaichan

Untitled

May 8th, 2022
1,171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.06 KB | None | 0 0
  1. public class Main {
  2.     public static void main(String[] args) {
  3.         // false - BLACK, true - WHITE, null - NO PIECE
  4.         final Boolean[] pieces = new Boolean[64];
  5.  
  6.         pieces[0] = false;
  7.         pieces[0 + 7] = false;
  8.  
  9.         pieces[7 * 8] = true;
  10.         pieces[7 * 8 + 7] = true;
  11.  
  12.         for (int i = 0; i < pieces.length; i++) {
  13.             if (pieces[i] == null) {
  14.                 continue;
  15.             }
  16.  
  17.             for (int k = 0; k < 8; k++) {
  18.                 final Boolean horizontalCheck = pieces[i / 8 + k];
  19.                 final Boolean verticalCheck = pieces[k * 8 + i % 8];
  20.  
  21.                 if (verticalCheck != null && verticalCheck != pieces[i]) {
  22.                     System.out.println(i / 8 + ", " + i % 8 + " has attacking rook");
  23.                     break;
  24.                 }
  25.  
  26.                 if (horizontalCheck != null && horizontalCheck != pieces[i]) {
  27.                     System.out.println(i / 8 + ", " + i % 8 + " has attacking rook");
  28.                     break;
  29.                 }
  30.             }
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement