Unity – Multithreading Errors – Game Development Stack Exchange

I'm following Sebastian Lague's video tutorials on creating a procedurally generated world. I followed his tutorial in full except for the fact that I created a double-precision algorithm for Perlin noise. My only problem is the fact that I don't think it is thread safe and returns strange values, any ideas?


 using UnityEngine;
using System.Collections;
using System;

public static class Noise {
    static int() p = new int(Convert.ToInt32(Math.Pow(2,12)));

    public static double(,) GenerateNoiseMap(int mapWidth, int mapHeight, int seed, float scale, int octaves, float persistance, float lacunarity, Vector2 offset) {
        double(,) noiseMap = new double(mapWidth, mapHeight);

        if (scale <= 0) { scale = 1; }

        System.Random prng = new System.Random(seed);
        Vector2() octaveOffsets = new Vector2(octaves);
        for (int i = 0; i < octaves; i++) {
            float offsetX = prng.Next(-100000, 100000) + offset.x;
            float offsetY = prng.Next(-100000, 100000) + offset.y;
            octaveOffsets(i) = new Vector2(offsetX, offsetY);

        if (scale <= 0) {
            scale = 0.0001f;

        float maxNoiseHeight = float.MinValue;
        float minNoiseHeight = float.MaxValue;

        float halfWidth = mapWidth / 2f;
        float halfHeight = mapHeight / 2f;

        Noise2d _noise = new Noise2d();

        for (int y = 0; y < mapHeight; y++) {
            for (int x = 0; x < mapWidth; x++) {

                float amplitude = 1;
                float frequency = 1;
                double noiseHeight = 0;

                for (int i = 0; i < octaves; i++) {
                    double sampleX = (double)(x - halfWidth) / scale * frequency + octaveOffsets(i).x + 0.001;
                    double sampleY = (double)(y - halfHeight) / scale * frequency + octaveOffsets(i).y + 0.001;

                    double perlinValue = _noise.Noise(sampleX, sampleY);
                    noiseHeight += perlinValue * amplitude;

                    amplitude *= persistance;
                    frequency *= lacunarity;

                if (noiseHeight > maxNoiseHeight) {
                    maxNoiseHeight = (float)noiseHeight;
                else if (noiseHeight < minNoiseHeight) {
                    minNoiseHeight = (float)noiseHeight;
                noiseMap(x, y) = noiseHeight;

        for (int y = 0; y < noiseMap.GetLength(1); y++) {
            for (int x = 0; x < noiseMap.GetLength(0); x++) {
                noiseMap(x, y) = (double)Mathf.InverseLerp(minNoiseHeight, maxNoiseHeight, (float)noiseMap(x, y));

        return noiseMap;

    public static void init(int seed) {
        createGradients(p, seed);

    public static int() createGradients(int() p, int seed) {
        System.Random prng = new System.Random(seed);
        for (int i = 0; i < p.GetLength(0) / 2; i++) {
            p(i) = prng.Next(0, 256);
            p(i + ((int)p.GetLength(0) / 2)) = p(i);

        return p;

    static vector2dDouble generateGradient(int val) {
        int hash = val & 7;
        switch (hash) {
            case 0:
                return new vector2dDouble(1.0, 1.0);
            case 1:
                return new vector2dDouble(-1.0, 1.0);
            case 2:
                return new vector2dDouble(-1.0, -1.0);
            case 3:
                return new vector2dDouble(1.0, -1.0);
            case 4:
                return new vector2dDouble(0, 1.41);
            case 5:
                return new vector2dDouble(0, -1.41);
            case 6:
                return new vector2dDouble(-1.41, 0);
            case 7:
                return new vector2dDouble(1.0, 0);
            default: return new vector2dDouble(0, 0);

    public class Noise2d {

        public double Noise(double x, double y) {

            int ix = Convert.ToInt32(Math.Floor(x)) & (p.GetLength(0) / 2 - 1);
            int iy = Convert.ToInt32(Math.Floor(y)) & (p.GetLength(0) / 2 - 1);

            x -= Math.Floor(x);
            y -= Math.Floor(y);

            vector2dDouble v1 = new vector2dDouble(x - 1, y - 1),
                           v2 = new vector2dDouble(x, y - 1),
                           v3 = new vector2dDouble(x - 1, y),
                           v4 = new vector2dDouble(x, y);

            int g1 = p(p(ix + 1) + iy + 1),
                g2 = p(p(ix) + iy + 1),
                g3 = p(p(ix + 1) + iy),
                g4 = p(p(ix) + iy);

            double u = fade(x);
            double v = fade(y);

            double f1 = v1.dot(generateGradient(g1)),
                   f2 = v2.dot(generateGradient(g2)),
                   f3 = v3.dot(generateGradient(g3)),
                   f4 = v4.dot(generateGradient(g4));

            return lerp(u, lerp(v, f4, f2), lerp(v, f3, f1));
        double lerp(double t, double argc, double argv) { return argc + t * (argv - argc); }

        double fade(double t) { return t * t * t * (t * (t * 6 - 15) + 10); }

public struct vector2dDouble {
    public double x, y;

    public vector2dDouble(double argx, double argy) {
        x = argx;
        y = argy;

    public double dot(vector2dDouble argc) {
        argc.x *= x;
        argc.y *= y;

        return argc.x + argc.y;

    public void print() {
        Debug.Log(x + "," + y);

Enter the image description here

What do these import errors mean? How can I fix it?

These are the mistakes:

  • Error importing pa_color Black
  • Error importing pa_color Blue
  • Error importing pa_color Green
  • Error importing action group wc_update_product_lookup_tables
  • Error importing Woocommerce DB updates for action groups
  • Media import "woocommerce-placeholder" failed
  • Media template import failed

I installed and activated Woocommerce before the import.

Functional construction – detection of errors in Mathematica

Is it possible to define a function that will receive and return any Mathematica expression? True If an error is detected, in the sense that we receive an error message, and False Otherwise?

To put it simply, I want to define that ErrorQ Function that results in every Mathematica expression False once the symbol
Enter the image description here is recognized and, for example, stops the evaluation. Any idea how to do that?

Possibly errors in the ESTA question "Have you ever been issued with a passport or ID card for travel to another country?"

A simplified version of the question would be:

Have you ever been issued a passport from another country?

This should be easier to answer. It sounds like the answer is in your case where you are a French citizen and have always been a French citizen No, (If your husband was issued a French passport in Australia, it would not be considered a different country. If he was issued an Australian passport because he became an Australian citizen, it would be completely different.)

The reason why the "or travel document" is also an option is because there are other types of documents (such as those issued to refugees) that are commonly referred to as "travel documents". These are documents that you can use for international travel instead of a passport.

quicktime – How To Fix Quickbooks Errors H202

Although QuickBooks does wonders in managing your finances, you may encounter some problems occasionally. If you encounter QuickBooks error H202, you can follow these suggestions to fix the problem:
 Create a new folder for the company file
 You can try adding your server to the Windows host file
 Make sure you allow access for QuickBooks services
 Run the network diagnostics tool on the host system
 Make sure you have a reliable network connection
 You can also use QuickBooks File Doctor
If you need third-party support, contact QuickBooks Customer Service for the best solution to your problem.
Solved: Accelerate customer care

build system – monitoring service for errors and successes

I have a service that runs some rules for projects in the build pipeline.

I am looking for a service that is able to collect errors and successes of this service for each of the projects and to store metadata for each result: project name, result etc.

The service should have a dashboard or a remainder API so that I can create the dashboard.

I've been thinking about Sentry, but only bugs can be fixed. Is there an online service (or an on-site service) that will solve my problem?

aws – Prevents errors when conditionally inserting into the MySQL database

The infrastructure of our system looks like this.

An AWS Lambda function receives requests such as (accountId, …..). It creates an entry in the MySQL database using a newly generated UUID as the caseId. (caseId, accountId, ….).

The insert is a conditional insert operation, which is discussed in detail below.

I can avoid race condition by setting transaction isolation to SERIALIZABLE. The problem, however, is that I have no control over how many concurrent requests are successfully processed.

For example, consider the following simultaneous requirements.

request  | accountId | field1 | ...  
 1         a1          value1   ....   true     --- create a new entry with caseId Idxxx
 2         a1          value2   ....   false    --- update existing entry with caseId Idxxx 
 3         a1          value3   ....   false    --- update existing entry with caseId Idxxx 
 4         a1          value4   ....   false    --- update existing entry with caseId Idxxx 

With our current implementation we get CannotAquireLockException.
How can I avoid repeat errors (CannotAquireLockException)?

The detailed table scheme and the condition are described below:

The database is a MySQL database system with the following table scheme.

Table1: case table

|caseId(PK) | accountId | status |  .....

Table2: case reopen table

|caseId(FK)| casereopenId(PK)| caseReopenTime|

Table3: Alert table

Id (incrementing id) | alertId | accountId | 

The Lambda function tries to "create" a case in the database.

The create wrapper generates a UUID for caseId.

The aim is :

  • Check whether an accountId already exists in the case table.
  • if it does, then
    • Check if the status is OPEN
    • Get the caseId for the accountId.
    • Check whether the caseId is present if the table is opened again.
      • If the above condition is incorrect, add an entry to the case table.

Thanks a lot!

POST request in R (400 BAD request errors)

When trying to create a POST request in R, an error of 400 BAD is displayed. To give a little insight, a DAG must be carried out automatically.
I have this:

url <-"http://xxxxx/api/experimental/dags/fire/dag_runs"
data <-'{"conf":"{\"DLP\":\"test\"}"}'

and first tried some methods found online:

result <- POST("http://xxxxx/api/experimental/dags/fire/dag_runs",add_headers(.headers = c('Cache-Control' = "no-cache","content-type"="application/json")))

Then I tried:

httr::POST("http://xxxxx/api/experimental/dags/fire/dag_runs",add_headers('Cache-Control' = "no-cache"))

And finally:

httr::POST(url = url, data = data, httr::add_headers('Cache-Control' = "no-cache"), httr::content_type("application/json"))

but no luck. I am new to this area, so a thorough explanation would be very welcome 🙂

caching – clear cache errors

I have a problem with a website I'm working on. If I clear the cache on my local site, the deployment will be interrupted. If I clear the cache there, it will work again, but this time the restaurant will no longer work …

Any ideas what is causing this error?

I get this error message in my local site terminal:

Uncaught PHP Exception DrupalComponentPluginExceptionPluginNotFoundException: "The "path_alias" entity type does not exist." at .../web/core/lib/Drupal/Core/Entity/EntityTypeManager.php line 150