Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
private static int[][] q = new int[][]{{1, 1, 'P', 'b'}, {-1, 1, 'P'}, {1, -1, 'p'}, {-1, -1, 'p'}}; private static int[][] o = new int[][]{{0, 1, '.', 'r'}, {0, -1, '.'}, {1, 0, '.'}, {-1, 0, '.'}}; private static int[][][] all = {q, o}; public static boolean canBeCaptured(int x, int y, char[][] board) { char color = color(board[y][x]); for (int[][] q_o : all) { for (int[] dir : q_o) { for (int i = 1; i < 8; i++) { char square = get(x + i * dir[0], y + i * dir[1], board); if (square == ' ') { continue; } if (color(square) == color|| square=='x') { break; } if (sameLtr(square, 'q') || sameLtr(square, (char) q_o[0][3]) || (i == 1 && (square == dir[2] || sameLtr(square, 'k')))) { return true; } break; } } } for (int[] dir : q) { for (int[] n : new int[][]{{2, 1}, {1, 2}}) { char square = get(x + n[0] * dir[0], y + n[1] * dir[1], board); if (sameLtr(square, 'n') && color(square) != color) { return true; } } } return false; }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)