## Changing sign of elements of a list on even positions

I have a list of lists of equal sizes (odd or even), e.g.

``list={{1,-2,3,1,3,4},{3,5,6,-1,9,0},{1,-2,-4,-5,1,5},{1,-1,2,3,5,4},...} ``

I would like to change signs of every element which is on even or odd position. In the example above, for the choice of change on even positions, it should give the following result:

`` listnew={{1,2,3,-1,3,-4},{3,-5,6,1,9,0},{1,2,-4,5,1,-5},{1,1,2,-3,5,-4},...} ``

What is the most effective way to achieve this? (The length of `list` may be huge here).

## Select box-shape grid between two positions on tilemap

I want to be able to click and hold on a certain point and mark it as `startPosition`. Then, while the mouse is held down and moved, mark that second position as `endPosition`.

When the mouse is finally released, I want to get all the positions between those two points.

Here is my code so far:

``for (float x = startPosition.x; x <= endPosition.x; x++)         {             for (float y = startPosition.y; y <= endPosition.y; y++)             {                 Vector3Int newPosition = Utilities.GridPosFromWorldPos(new Vector2(x, y));                 if (!selectedPositions.Contains(newPosition)) { selectedPositions.Add(newPosition); }             }         } ``

This works only when dragging up and/or to the right. As soon as I try to go to left or bottom, the `endPosition` coordinates become smaller than the `startPosition` coordinates, which breaks the for loop.

How can I solve this?

## Can you take advantage of flanking positions with a ranged weapon?

There appears to be some controversy over whether or not a ranged attacker can ever be considered to be flanking his target. Is it true that it is impossible to flank enemies with a ranged weapon? What about the first line of the flanking rules, which state:

When making a melee attack, you get a +2 flanking bonus if your opponent is threatened by another enemy character or creature on its opposite border or opposite corner.

Some people claim that this means you can only be considered flanking an enemy while you are currently making a melee attack, is that true?

In general, are you ever considered to be flanking a target while attacking with a ranged weapon and are there any situations in which this distinction could possibly matter?

## Why the random positions are not random?

``using System.Collections; using System.Collections.Generic; using UnityEngine;  [ExecuteAlways]  public class GenerateCurvedLines : MonoBehaviour {     public GameObject linesPointsPrefab;     public GameObject linesParent;     [Range(3, 100)]     public int numberOfLines;     [Range(5, 50)]     public int gap;     public bool randomLinesPositions;     public bool generateLines;     public bool clearPositions;      private List<Vector3> randomPositions = new List<Vector3>();     private GameObject instance;      // Start is called before the first frame update     void Start()     {         if (randomLinesPositions)         {             for (int i = 0; i < numberOfLines; i++)             {                 randomPositions.Add(new Vector3(UnityEngine.Random.Range(5, 50), UnityEngine.Random.Range(5, 50), UnityEngine.Random.Range(5, 50)));             }         }          GenerateLines();     }      // Update is called once per frame     void Update()     {         if (clearPositions)         {             var lr = GetComponent<LineRenderer>();             lr.positionCount = 0;              clearPositions = false;         }          if (generateLines)         {             GenerateLines();              generateLines = false;         }     }      private void GenerateLines()     {         for (int i = 0; i < numberOfLines; i++)         {             randomPositions.Add(new Vector3(UnityEngine.Random.Range(5, 50), UnityEngine.Random.Range(5, 50), UnityEngine.Random.Range(5, 50)));              if (randomLinesPositions)             {                 instance = Instantiate(                       linesPointsPrefab,                       randomPositions[i],                       Quaternion.identity                    );             }             else             {                 instance = Instantiate(                       linesPointsPrefab,                       Vector3.right * gap * i,                       Quaternion.identity                    );             }              instance.transform.parent = linesParent.transform;         }     } } ``

At this part I’m trying to Instantiate random positions of the prefabs but each time I check true the flag generateLines it’s Instantiating the prefabs at the same positions instead each time to Instantiate them in a new random positions. It’s like it’s Instantiate once random positions and then using this positions each time and not Instantiating new random positions.

``randomPositions.Add(new Vector3(UnityEngine.Random.Range(5, 50), UnityEngine.Random.Range(5, 50), UnityEngine.Random.Range(5, 50)));                      if (randomLinesPositions)                 {                     instance = Instantiate(                           linesPointsPrefab,                           randomPositions[i],                           Quaternion.identity                        );                 } ``

## Isometric tiles on wrong positions if the mouse points at a negative world coordinate

I am using this approach:

http://clintbellanger.net/articles/isometric_math/

Basically, you can calculate the iso coordinates based on the screen coordinates. What I am doing is, getting the actual world position the mouse is pointing at using get_mouse_global_position() and convert this position to isometric values.

Then I translate those coordinates back to world space coordinates to actually display the sprite.

Problem is, that when the world coordinates come from a negative position, the tiles get offset by almost an entire tile amount. Here is the relevant code.

The get_coord() function returns the actual world position of the tile used to display the Sprite

``func get_coord(pos : Vector2):     var t = Vector2()     var e = screen_to_iso(pos)     t = iso_to_screen(e)     print(pos)     print(e)     print(t)     return t     pass var buildings  func screen_to_iso(pos :Vector2):     var flipx = 0     var flipy = 0     var t = Vector2()     var x_size = size/2     var y_size = size/4     t.x = int((pos.x/x_size) + (pos.y/y_size))/2     t.y = int((pos.y/y_size) - (pos.x/x_size))/2     return t     pass  func iso_to_screen(pos : Vector2):     var t = Vector2()     var x_size = size/2     var y_size = size/4     t = Vector2((pos.x-pos.y)*x_size, (pos.x+pos.y)*y_size)     return t     pass ``

I can’t seem to figure out a way

## 2D Finding an algorithm to check pizza toppings positions

Using unity 3D I am creating a 2D pizza game and I am stuck at finding an algorithm to solve this problem which is Detecting if the pizza is half and half taking into consideration that the user can put the toppings in all rotations shown in the picture and lot more possible distributions.

I used `Physics2D.OverlapAreaAll` to get position of ingredients on the pizza and I tried getting the sumX and sumY of coordinates of all topping A and sumX and sumY of all topping B and adding A.sumX + B.sumX and A.sumY + B.sumY and if the 2 totals are between 0 and 1 then A and B are on opposite sides but the bad distribution of toppings in the second pic is also accepted by my algorithm. The toppings must be spread like in the 1st pic

I need some easier way to detect the correct distribution of ingredients maybe using collisions or something.

``if (sumX > -ErrLvl && sumX < ErrLvl && sumY > -ErrLvl && sumY < ErrLvl)               {                 Debug.Log("APPROVED HALF-HALF PIZZA");             }             else                 Debug.Log("BAD HALF-HALF PIZZA"); ``

## What is a good algorithm for generating a linear regression of positions in 3D space? (for getting the direction of a thrown object in VR)

I’m trying to get throwing to feel right in my VR game. I don’t plan on actually using physics to do this; my idea is to accurately determine the lateral direction of the throw, then move the object in the intended direction (with a doctored Y value) at a speed dependent on other factors.

The language of the code doesn’t matter too much, but I’m using Godot, so something that wouldn’t require me to import a bunch of different math libraries (by converting them to Godot’s Python-style GDScript) would be ideal. It doesn’t need to be robust.

To give you an idea of what I was thinking, my original plan was to save the position of the grabbing controller every frame while an object is being held, removing old positions if the controller is moving backwards, then averaging out the movement deltas over the last 10 or 15 frames or so before letting go (it should be consistent since Godot has a fixed-timestep “update” function available) and normalizing the vector to get the direction the object should travel in.

However, this blog post got me thinking that spending the time learning how to do the linear regression in a more robust way, then applying that to 3D/VR, might be worthwhile. I just wonder if, since I don’t need the actual linear or angular velocity, it might be overkill in terms of time spent on the feature.

## Problem with SPO Document Library default view not saving column positions

This seems like it should be a pretty easy task –

I have created a new document library in SPO and added a few columns to it. When I move the columns around, or hide various columns, and the leave the site and return, the column order that I had previously set is not maintained, and the hidden columns are visible again.

This is a new site and I have complete rights to it.

Is there something I’m just overlooking here?

## Random Teams based on Positions in Sports

I have tried to find an answer to this but haven’t found exactly what I’m looking for.

I am trying to develop a way in which I can have a random team selected based on skill set (1-5 with 5 being the strongest skilled player) as well as by position (Forward of Defense) so that the algorithm can organize the players based on skills and position.

I know I can easily do one to randomly assign based on one criteria, but whats the best way to add the second criteria at the same time?

## Poll visible windows’ positions from C++ and send to a C# client

I’m creating a C# client which shows all Windows visible windows’ bounds at real time. (this is not the main purpose, but it’s a core feature).

At the beginning, I found DLL injection. So I considered a global DLL injection so that every process with an injected DLL sends its bounds to my client. But this was far too complicated.

I quickly turned to polling. It’s important to know that I have a game loop with interpolation in order to have a “real-time display of windows’ bounds”

(I subscribed to CompositionTarget.Rendering event, I’m using WPF)

First, I used (and I still use) EnumWindows in my game loop. This was laggy, and in order to filter all the windows, I was always gathering all the information of a window with P/Invoke calls although it was not always necessary.

Anyway. To optimize this, I put all this logic in an infinite loop in a Dispatcher Thread and for each enumerated window, I get its information one at a time, only if I need it, and in the order of first exclusion.

My want is to have the smoothest polling I can have, so I’d like to switch to C++ for this poll and filter stuff to make it faster.

Note: this duo of C++ and C# “apps” would never be running separately. The C++ side is only useful to the C# side. If C# side stops, the other needs to stop too.

Now that you see the big picture of what I already did, and what I’d like to achieve, here’s my question(s):

• I’m considering using a C++ service, is it a good idea? If not, what would you advise me?
• What method would you advise me to send a relatively continuous flow of bounds information to my C# client from C++?

I say send because I think of the “from C++ to C#” way, but maybe it’s better to think the other way. For example, C++ serves a file or something which is continously updated, and I would read it with C#…

The only thing is that all of this has to be fast and look smooth.