google sheets – problems with form and appendRow

I created a form in Google Script and one of the fields is a Checkbox, the name of the field would be field1 ()

and to save the answers in a sheet, I am using AppendRow, but when I insert the name of the field that has (), I get an error, and if I remove them the selections are not saved correctly.

This is my code.gs

function doGet(request) {
  return HtmlService.createTemplateFromFile('Index')
      .evaluate();
}

function include(filename) {
  return HtmlService.createHtmlOutputFromFile(filename)
      .getContent();
}

/* @Process Form */
function processForm(formObject) {
  var url = "https://docs.google.com/spreadsheets/d/12CUQaajvhcQjcskDgA7YHc6EWdK67wq9LqBiauBoi4/edit#gid=0";
  var ss = SpreadsheetApp.openByUrl(url);
  var ws = ss.getSheetByName("Data");

  ws.appendRow((
 
  formObject.field1));
}

unity – Problems blending biomes together in relation to moisture/temperature

I am trying to achieve smooth biomes blending for my procedural 3D terrain.

I’ve been doing some research on this creating biomes topic and I found some good sources that talk about creating biomes by the use of generated moisture and temperature maps.

I found this table, that I use as an example.

enter image description here

So far I’ve done something like this. I’ve defined regions that are the horizontal row (temperature)

(Serializable)
public struct Region
{
    (SerializeField) string type;

    (Range(0, 1))
    public float temperature;
    public RegionBiome() biomes;
}
(Serializable)
public class RegionBiome
{
    (SerializeField) string type;

    (Range(0, 1))
    public float moisture;
    public Biome biome;
}

And biomes that are associated with the region

(CreateAssetMenu)
public class Biome : ScriptableObject
{
    (SerializeField) new string name;

    public Color color;

    (Header("Noise"))
    public float scale;
    public Wave() waves;

    public float Sample(float x, float y)
    {
        return Noise.GetPerlinNoise(x, y, scale, 0, 0, waves);
    }
}

I have set up the exact biomes table like in the picture.

enter image description here

Then to generate a heightmap I have firstly generated heat and moisture maps and looped through the entire map and sampled each coordinate to get the evaluation

void Generate()
{
    float(,) temperatureMap = GenerateNoiseMap(size, 50f, 0f, 0f, new Wave(2) { new Wave(seed * -2, 1, 2), new Wave(seed * 2, .5f, 1) });
    float(,) moistureMap = GenerateNoiseMap(size, 35f, 0f, 0f, new Wave(2) { new Wave(seed * -.5f, 1, 2), new Wave(seed * .5f, .5f, 1) });

    float(,) heightMap = new float(size, size);

    Color() colorMap = new Color(size * size); Color color;
    for (int y = 0; y < size; y++)
    {
        for (int x = 0; x < size; x++)
        {
            float heat = temperatureMap(x, y);
            float moisture = moistureMap(x, y);

            heightMap(x, y) = GetEvaluation(x, y, heat, moisture, out color);
            colorMap(x + (y * size)) = color;
        }
    }
    CreateOutput(colorMap, colorOutput, result1);
    for (int i = 0; i < colorMap.Length; i++)
    {
        float value = heightMap(i % size, i / size);
        colorMap(i) = new Color(value, value, value, 1);
    }
    CreateOutput(colorMap, noiseOutput, result2);
}

And this is the evaluation function

float GetEvaluation(float x, float y, float heat, float moisture, out Color color)
{
    int regionIndex = -1;
    for (int i = 0; i < regions.Length; i++)
    {
        if (i < regions.Length - 1)
        {
            if (heat >= regions(i).temperature && heat < regions(i + 1).temperature)
            {
                regionIndex = i;
                break;
            }
        }
        else
        {
            if (heat == 1)
            {
                regionIndex = i;
                break;
            }
            regionIndex = i - 1;
        }
    }
    int biomeIndex = -1;
    for (int i = 0; i < regions(regionIndex).biomes.Length; i++)
    {
        if (i < regions(regionIndex).biomes.Length - 1)
        {
            if (moisture >= regions(regionIndex).biomes(i).moisture && moisture < regions(regionIndex).biomes(i + 1).moisture)
            {
                biomeIndex = i;
                break;
            }
        }
        else
        {
            if (moisture == 1)
            {
                biomeIndex = i;
                break;
            }
            biomeIndex = i - 1;
        }
    }
    color = regions(regionIndex).biomes(biomeIndex).biome.color;

    float evaluation = regions(regionIndex).biomes(biomeIndex).biome.Sample(x, y);

    float currHeat = regions(regionIndex).temperature;
    float destHeat = heat == 1 ? currHeat : regions(regionIndex + 1).temperature;

    float heatBlend = 0;
    if (destHeat != currHeat)
    {
        heatBlend = Mathf.InverseLerp(currHeat, destHeat, heat);
        evaluation = Mathf.Lerp(evaluation, regions(regionIndex + 1).biomes(biomeIndex).biome.Sample(x, y), heatBlend);
    }

    float currMoisture = regions(regionIndex).biomes(biomeIndex).moisture;
    float destMoisture = moisture == 1 ? currMoisture : regions(regionIndex).biomes(biomeIndex + 1).moisture;

    float moistureBlend = 0;
    if (destMoisture != currMoisture)
    {
        moistureBlend = Mathf.InverseLerp(currMoisture, destMoisture, moisture);
        evaluation = Mathf.Lerp(evaluation, regions(regionIndex).biomes(biomeIndex + 1).biome.Sample(x, y), moistureBlend);
    }

    if (heat < 1 && moisture < 1)
    {
        float cornerBlend = Mathf.Clamp01(heatBlend + moistureBlend);
        evaluation = Mathf.Lerp(evaluation, regions(regionIndex + 1).biomes(biomeIndex + 1).biome.Sample(x, y), cornerBlend);
    }
    return evaluation;
}

And these are some utility functions that I used

private float(,) GenerateNoiseMap(int size, float scale, float offsetX, float offsetZ, Wave() waves)
{
    return Noise.GeneratePerlinNoiseMap(size, size, scale, offsetX, offsetZ, waves);
}
void CreateOutput(Color() colorMap, RawImage image, Texture2D tex)
{
    tex.SetPixels(colorMap); tex.Apply();
    image.texture = tex;
}

And the noise class for generating Perlin noise maps

public static class Noise
{
    public static float(,) GeneratePerlinNoiseMap(int mapDepth, int mapWidth, float scale, float offsetX, float offsetZ, Wave() waves)
    {
        float(,) noiseMap = new float(mapDepth, mapWidth);

        for (int zIndex = 0; zIndex < mapDepth; zIndex++)
        {
            for (int xIndex = 0; xIndex < mapWidth; xIndex++)
            {
                float sampleX = (xIndex + offsetX) / scale;
                float sampleZ = (zIndex + offsetZ) / scale;

                float noise = 0f;
                float normalization = 0f;
                foreach (Wave wave in waves)
                {
                    noise += wave.amplitude * Mathf.PerlinNoise(sampleX * wave.frequency + wave.seed, sampleZ * wave.frequency + wave.seed);
                    normalization += wave.amplitude;
                }
                noise /= normalization;

                noiseMap(zIndex, xIndex) = noise;
            }
        }
        return noiseMap;
    }
    public static float GetPerlinNoise(float x, float y, float scale, float offsetX, float offsetZ, Wave() waves)
    {
        float sampleX = (x + offsetX) / scale;
        float sampleZ = (y + offsetZ) / scale;

        float noise = 0f;
        float normalization = 0f;
        foreach (Wave wave in waves)
        {
            noise += wave.amplitude * Mathf.PerlinNoise(sampleX * wave.frequency + wave.seed, sampleZ * wave.frequency + wave.seed);
            normalization += wave.amplitude;
        }
        noise /= normalization;

        return noise;
    }
}

The way I get the final height doesn’t seem to be working correctly as the biomes noises are not interpolated correctly. Also, the color map doesn’t seem right as well…

The color map

enter image description here

The height map

enter image description here

How do I blend the biomes? I’m definitely missing something here and can’t wrap my head around it… What do I and how do I weigh the final evaluation value?

c++ – Problems with collisions (using vector of instances)

I wrote a for loop to check every instance of the class Wall, only the the last instance in the vector properly works

hybrid.h

 void reactTo(Player* other)
 {
     if (react)
     {
         if ((other->back<front && other->front > front) && (other->y > foot && other->y < head))
         {
             other->goAhead(0) = false;
         }
         else
         {
             other->goAhead(0) = true;

             if ((other->front >= back) && other->back < back && other->y > foot && other->y < head)
             {
                 other->goAhead(1) = false;
             }
             else
             {
                 other->goAhead(1) = true;
             }
         }
     }
     if (other->foot <= head && other->head >= head && other->x > back && other->x < front)
     {
         other->goAhead(2) = false;
     }
     else
     {
         other->goAhead(2) = true;
         if ((other->head >= foot) && other->foot < foot && foot && other->x > back && other->x < front)
         {
             other->goAhead(3) = false;
         }
         else
         {
             other->goAhead(3) = true;
         }
     }
     if (other->front > back && other->back <= front && other->head < head && other->foot > foot)
     {
         R = 0;
     }
     else
     {
         R = 1;
     }
 }

source.cpp

#include"hybrid/hybrid.h"

int main()
{
   setWindowSize(1500, 600);

   makeSequenceWall();//push back 5 Wall constructor

   Player p(300, 300,30,30,0.5,0,1,0);
   //------------
   slWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "HYBRID", false);
   while (!slShouldClose())
   {
               //----------
       p.move();
       p.render();//render the player

       
       for (int i = 0; i != 5; i++)//check the collision
       {
           wallSeq.at(i).reactTo(&p);
       }

       
       for (itr = wallSeq.begin(); itr != wallSeq.end();itr++)//render the wall
       {
           itr->render();
       }
       
       slRender();
   
   }
   slClose();
   return 0;
}

```

repair – Is my image exposure off due to shutter problems?

I’ve recently noticed an issue with my dslr regarding exposures. Most of my time is spent using shutter speeds under 1/100s for landscape photography but the other day I was trying to under expose a shot early on a sunny morning and found I could not do so using shutter speeds. As I am an Olympus four thirds user I’m restricted to low ISO’s (due to noise), and larger apertures (due to diffraction and depth of field) than other larger formats.
My initial experiments showed that shutter speeds faster than the camera’s flash sync speed weren’t working. The exposure didn’t change as I took shots in shutter priority mode from about 1/160s to max at 1/4000s, and I wondered if the sync speed setting was somehow stuck on despite the built in flash being set off and the display showing fast shutter speeds.
I took the camera out again recently when snow had fallen and as the light increased I started to struggle again, being forced to use small apertures and eventually ND filters to get images in the strong light.

I found that in burst mode the camera would take a sequence of four or five pictures as follows (all at f/18 1/160s ISO 100 19mm):

  1. Totally over exposed.image 1 f/18 1/160s ISO 100 19mm
  2. Correctly exposed but with an overexposed strip at the bottom of the frame.image 2 f/18 1/160s ISO 100 19mm
  3. Correctly exposed.image 3 f/18 1/160s ISO 100 19mm

Is this a sticky second curtain? It has been cold recently but I suspect this is the end for my much loved, 12 year old Olympus E-520. Are there any possible fixes I can try before finally put my hand in my pocket to replace this now defunct system (Oly gave up support before selling the imaging division to JIP)?

algorithms – “Let $Pi$ and $Pi$’ be two NP-complete problems, prove or deny $Pi ’propto_{poly}Pi$”

I am facing a proving question.

“Let $Pi$ and $Pi$’ be two NP-complete problems, prove or deny $Pi’propto_{poly}Pi$

I do not that understand the meaning of this question. Isn’t it a self-evident truth to be $Pi ’propto_{poly}Pi$ if both of them are NP-complete problems?

Problems installing pytesseract on Python for MacOs

I have tried for multiple days to install pytesseract but I get the following error:

TesseractError: (-6, 'dyld: Library not loaded: /usr/local/opt/giflib/lib/libgif.dylib   Referenced from: /usr/local/opt/leptonica/lib/liblept.5.dylib   Reason: image not found')

I think the problem is related to my tesseract installation, so I tried to do
brew update && brew upgrade && brew install tesseract but I still get the error. Among many other things, but nothing seems to work.

I’m using Python 3.8.8 and macOS Big Sur 11.2.2

SQl Server log shipping monitor security configuration and update problems

I’m setting up log shipping between instances A and B with the instance C as a monitor. The shipping itself is working fine but I’m somehow unable to make the monitoring work. The log shipping status on C is not up to date – the reports show that no backups and restores are performed. The respective reports on A and B are perfectly up to date, showing that everything is OK. The problem is pretty much obviously in the monitor connections configuration/permissions.

SQL Agents on A and B run as NT ServiceSQLSERVERAGENT.
The SA accounts on A, B and C are disabled.

  • using impersonation with A and B machine domain accounts added to sysadmins on C – doesn’t help
  • using custom SQL logins which are also sysadmins on A, B and C – doesn’t help and also keeps switching to SA login in the monitor connection window as well as in the linked server configuration on A and B

What can be the root cause? Is using SA account a requirement?
TIA

Linear Programming Problems with decimal solutions for problems requiring whole number solution

I have an LPP which asks for the maximum number of pairs of shoes that can be manufactured to maximize the profit. The LPP is:


Maximize Z=1350x + 975y
Subject to, 3x+1.5y&leq;275
     2.5x+2y&leq;300
     x, y&geq;0

The solution I obtained is x=44.45; y=94.44
Now, since x and y can only be positive integers, what will the final solution be? I’m confused about this step. Any help is welcome :-]