private static int subsequentCoins(int[][] board, int x, int y, int dx, int dy, int playerID) {
        int newX = x + dx;
        int newY = y + dy;
        if ((newX >= 0 && newX < board.length) && (newY >= 0 && newY < board[0].length) && board[newX][newY] == playerID) {
            return 1 + subsequentCoins(board, newX, newY, dx, dy, playerID);
        } else {
            return 0;
        }
    }