collision detection – Need help improving my Flow Field and Unit Avoidance code so that the units can properly surround a unit instead of getting stuck

My setup is like this. Every update my movement system moves all of the units on the field. They use some Boid logic to avoid eachother, and a flow field that directs them towards each other. This is the result. https://imgur.com/a/CaUpfT7

My general setup is to calculate 2 flow fields, one for each player. From every field on the map (32×32 fields) I calculate the vector that points towards the closest enemy. Now this is a fine approach but I’d like to somehow take into consideration obstacles somehow (without another round of for loops)? Or should I handle that in my movement system avoidance? I was maybe thinking of doing A* once a unit is close enough to the enemy but all of these systems together seem rather hacky and overkill.

Here is some code. Firstly how I create the flowfields (kinda costly, will look into a way to optimize it further, don’t really need every single tile, can probably merge 2 or 3 together)

func (g *Grid) Update() {
    g.entityPositions(0) = g.entityPositions(0)(:0)
    g.entityPositions(1) = g.entityPositions(1)(:0)
    entities := g.world.GetEntityManager().GetEntities()
    posComps := g.world.GetObjectPool().Components("PositionComponent")

    for _, ent := range entities {
        g.entityPositions(ent.PlayerTag) = append(g.entityPositions(ent.PlayerTag), posComps(ent.Index).(components.PositionComponent).Position)
    }

    for x := 0; x <= g.MaxWidth/FlowTileSize; x++ {
        for y := 0; y <= g.MaxHeight/FlowTileSize; y++ {

            curPosVector := engine.Vector{X: float32(x * 32), Y: float32(y * 32)}
            // find closest tile to this one for both players
            minDist := float32(100000.0)
            minIndx := -1
            for indx, pos := range g.entityPositions(0) {
                d := engine.GetDistanceIncludingDiagonal(pos, curPosVector)
                if d < minDist {
                    minIndx = indx
                    minDist = d
                }
            }

            //  fmt.Printf("CurPos : %v, enemyPos : %v,  direction %v n", curPosVector, g.entityPositions(0)(minIndx), g.entityPositions(0)(minIndx).Subtract(curPosVector).Normalize())
            g.flowTiles(1)(x)(y).Direction = g.entityPositions(0)(minIndx).Subtract(curPosVector).Normalize()

            minDist1 := float32(100000.0)
            minIndx1 := -1
            for indx, pos := range g.entityPositions(1) {
                d := engine.GetDistanceIncludingDiagonal(pos, curPosVector)
                if d < minDist1 {
                    minIndx1 = indx
                    minDist1 = d
                }
            }

            g.flowTiles(0)(x)(y).Direction = g.entityPositions(1)(minIndx1).Subtract(curPosVector).Normalize()
        }
    }
}

And my movement code. A lot of code but just basic allignnment cohesion/ separation. With added 2 look ahead vectors to steer away from the collision.

        desiredDirection := world.Grid.GetDesiredDirectionAt(positionComp.Position, tag)
        direction := movementComp.Direction
        maxSpeed = movementComp.MovementSpeed

        //Avoidance
        nearbyEntities := helper.GetNearbyEntities(100, world, index)

        avoidance := engine.Zero()
        avoidance = avoidance.Add(alignment(world, nearbyEntities, direction).MultiplyScalar(alignmentCoef))
        avoidance = avoidance.Add(cohesion(world, nearbyEntities, direction, positionComp.Position).MultiplyScalar(cohesionCoef))
        avoidance = avoidance.Add(separation(world, nearbyEntities, direction, positionComp.Position).MultiplyScalar(separationCoef))


        //Checking ahead of us whether or not we'll encounter something
        lookAheadVectorLong := direction.Add(desiredDirection).MultiplyScalar(maxSpeed * 2.5)
        lookAheadVectorShort := direction.Add(desiredDirection).MultiplyScalar(maxSpeed)
        maxAvoidanceForce := float32(1.0)

        checkPosShort := positionComp.Position.Add(lookAheadVectorShort)
        checkPosLong := positionComp.Position.Add(lookAheadVectorLong)

        collidedIndexShort := world.Grid.IsPositionFree(index, checkPosShort, positionComp.BoundingBox)
        collidedIndexLong := world.Grid.IsPositionFree(index, checkPosLong, positionComp.BoundingBox)

        if collidedIndexShort != -1 {
            direction = engine.Zero()
            avoidance = checkPosShort.Subtract(world.ObjectPool.Components("PositionComponent")(collidedIndexShort).(components.PositionComponent).Position).Normalize()
            avoidance = avoidance.MultiplyScalar(maxAvoidanceForce * 1.5)
        } else if collidedIndexLong != -1 {
            direction = direction.MultiplyScalar(breakingForce)
            avoidance = checkPosShort.Subtract(world.ObjectPool.Components("PositionComponent")(collidedIndexLong).(components.PositionComponent).Position).Normalize()
            avoidance = avoidance.MultiplyScalar(maxAvoidanceForce * 1.2)
        }

        direction = desiredDirection
        direction = direction.Add(avoidance).Normalize()

        positionComp.Position = positionComp.Position.Add(direction.MultiplyScalar(maxSpeed))

        positionComp.Position.X = engine.Constraint(positionComp.Position.X, 0, 799)
        positionComp.Position.Y = engine.Constraint(positionComp.Position.Y, 0, 511)

        movementComp.Direction = direction.Normalize()

        world.ObjectPool.Components("PositionComponent")(index) = positionComp
        world.ObjectPool.Components("MovementComponent")(index) = movementComp

        fmt.Printf("I %d am at %vn", index, positionComp.Position)
    }

}

func limit(p engine.Vector, lim float32) engine.Vector {
    if p.X > lim {
        p.X = lim
    } else if p.X < -lim {
        p.X = -lim
    }
    if p.Y > lim {
        p.Y = lim
    } else if p.Y < -lim {
        p.Y = -lim
    }
    return p
}
func alignment(world *game.World, siblings ()int, velocity engine.Vector) engine.Vector {
    avg := engine.Vector{X: 0, Y: 0}
    total := float32(0.0)

    for _, siblingIndex := range siblings {
        avg = avg.Add(world.ObjectPool.Components("MovementComponent")(siblingIndex).(components.MovementComponent).Direction)
        total++
    }
    if total > 0 {
        avg = avg.DivideScalar(total)
        avg = avg.Normalize().MultiplyScalar(maxSpeed)
        avg = avg.Subtract(velocity)
        avg = limit(avg, maxForce)
        return avg
    }
    return engine.Vector{X: 0.0, Y: 0.0}

}

func cohesion(world *game.World, siblings ()int, velocity engine.Vector, position engine.Vector) engine.Vector {
    avg := engine.Vector{X: 0, Y: 0}
    total := float32(0)

    for _, siblingindex := range siblings {

        avg = avg.Add(world.ObjectPool.Components("PositionComponent")(siblingIndex).(components.PositionComponent).Position)
        total++

    }
    if total > 0 {
        avg = avg.MultiplyScalar(1.0 / total * cohesionCoef)
        avg = avg.Subtract(position)
        avg = avg.Normalize().MultiplyScalar(maxSpeed)
        avg = avg.Subtract(velocity)
        avg = limit(avg, maxForce)
        return avg
    }
    return engine.Vector{X: 0.0, Y: 0.0}
}

func separation(world *game.World, siblings ()int, velocity engine.Vector, position engine.Vector) engine.Vector {
    avg := engine.Vector{X: 0, Y: 0}
    total := float32(0)

    for _, siblingIndex := range siblings {
        siblingPos := world.ObjectPool.Components("PositionComponent")(siblingIndex).(components.PositionComponent).Position
        d := position.Distance(siblingPos)
        if d < desiredSeperation {
            diff := position.Subtract(siblingPos)
            diff = diff.Normalize()
            diff = diff.DivideScalar(d)
            avg = avg.Add(diff)
            total++
        }
    }
    if total > 0 {
        avg.DivideScalar(total)
    }

    if total > 0 {
        avg = avg.MultiplyScalar(1.0 / total * separationCoef)
        avg = avg.Normalize().MultiplyScalar(maxSpeed)
        avg = avg.Subtract(velocity)
        avg = limit(avg, maxForce)
    }
    return avg
}

What I am trying to achieve is:

Units not mashing into each other and just positioning themselves in a free spot around their target.

What are my problems :

  1. Make the flow field direct them away from collision rather than just towards closest unit.
  2. Make it work with the current system without adding too many nested loops and awful checks.
  3. I am doing the avoidance correctly? I have a desired direction that I get from the flow field (that directs me towards closest enemy), then I add avoidance to it to avoid any other units in the area.

My units move really well up untill the point of collision/ going to a spot next to a target. I am not sure how to implemenent that behaviour yet.

(This is my forth iteration of the movement system. I went from pure boid, to grid based, to A*, to this. So I tried a lot of variations and this going surrounding behaviour has been bugging me every time.)

Custom engine (server) written in Golang and then dispatched to Godot for the visuals. Performance is not my concern, but this is a server, so I am more mindful of that, I could probably brute force it but I’d rather hear some better take on it.

Any suggestion/article/ video is greatly appreciated !!

18.04 – 5.1 surround sound settings?

I’m trying to configure my 5.1 on Ubuntu, but I’m not managing to.
I’ve followed all tutorials and explanations shown on askubuntu and arounds, changing the daemon.conf file to 6 and all, but:

  • Running speaker-test -c6 -twav now does act as if a 5.1 system was in place, but sound only comes as on a 2.0 (no bass, only two front speakers).

  • Youtube Video to test speakers do not reach to make surround experience at all (rear left, rear right, and center do not sound). Surprisingly enough, the lfe does.

  • On Sound settings, I was expecting I would be able to see the new configuration, something along the lines of the Realtek Sound driver where you have all 6 elements there… but I could only see this:
    List item

  • I am unable to understand what does alsamixer showw when I open it. Yes, a lot of bars there, but I don’t grasp how to use it. On this matter, launching alsamixer I always get Nvidia GPU HDMI as default, needing to select the proper sound card (F6). When managing to select the correct card, as I said, I only see this:

enter image description here

Could anyone please throw some insight as on what to do to get my audio working? (ideally with the proper show display on the Settings area?)

Thanks in advance!

Color – Which white balance should be selected if the photo should completely surround the viewer?

Suppose you create a cubemap to be displayed in a room where the walls, ceiling, and floor are screens that show the scene you recorded. The monitors should obviously display the images as accurately as would be "shown" by windows of the same size in the scene. This means that we shouldn't try white balance to remove hues.

However, there is no setting in the camera such as "no white balance" or "white balance as is". Similarly, raw photos (if I take Bayer "red" for red, average "green" for green, and "blue" for blue) seem to have colors after my experiments with LibRaw that are very different from reality: on my Canon EOS 1100D are far too green: even if I put a red (640 nm) laser pointer on the wall, something green is striking. The images must be corrected using coefficients provided by the camera in order to come closer to reality. I think this is the so-called neutral profile in RawTherapee.

How do I edit the photos so that they appear on the screen as exactly as possible, what actually hit the camera sensor? How can I reproduce photometrically correct colors instead of those that people assume are under certain environmental conditions?

Nvidia Surround with 27 "and 49" so it works with a laptop on the side

I apologize for a lumpy question, but I think the questions can be better answered if the full situation is understood.

I have two monitors, one is 27 "16: 9 while the other is 49" 32: 9. I also have an NVIDIA GPU and use Windows 10. I also use Display Fusion to split the 32: 9 format into two 16: 9 monitors, at least as far as the Windows window manager is concerned.

I like to play some games only on the 49 ", some only on the 27". I like to play others with nvidia surround on both.

I have a lot of problems with it and if you could help me with one of them I would appreciate it very much.

Physically, 27 "is connected to my PC via a DP cable, while the 49" is connected to the PC via HDMI AND DP cables (you will see why soon). I also have a laptop connected to the 49 "via HDMI (which is a problem since the 49" has only a single HDMI input).

My setup is currently in one of the three possible modes:

  1. Use only one PC in standard desktop mode (two monitors are treated separately, no surround)
  2. Use only one PC in surround mode (49 "in PBP mode are treated as two physical monitors, both added to the surround configuration with the 27").
  3. Use both the PC and the laptop. The PC is connected to 27 "and the left half of the 49" while the laptop is connected to the right half of the 49 "(of course runs in PBP).

The first mode is the mode I use for general computer use and playing games on only one of the two monitors. I can activate Gsync and Freesync and run both monitors to the fullest.

I use the second mode to play games on a triple-screen setup. This has several problems. Since nvidia refuses to fix the insanely restrictive mount, i can not just connect the two monitors side by side and call it a day, the picture is stretched to the 49 ", what i need to do is connect the 49" over two cables (and they can't both be DP, NVIDIA / Windows still treats it as a single monitor in this case (for some reason) and then pretend to have three monitors.

I can't use this mode in everyday use because it lowers my refresh rate on both monitors (49 "in PBP runs at 100Hz instead of 120Hz, the other one can run at 144Hz, but is limited to 100Hz because everyone has to run the same way. I can also use Freesync or Gsync do not use on monitors and some programs (such as video players) are severely cracked in this mode, I just want to be able to turn this mode on and off as painlessly as possible if I have to.

Finally, I use the third mode when I want to use my laptop. I've installed debauchee / barrier so I can share my PC mouse and keyboard with the laptop and move seamlessly from one to the other. Typically, if I only switched the smaller screen to laptop, I would have either an extra step to disable that screen on the PC or an invisible screen that I would have to go through to get to the laptop.

The PBP really helps here, because if I turn it on, instead of switching one of the Windows displays to the laptop, it just shrinks and the laptop is right next to it, with no invisible screens, no extra steps to get it.

If you haven't noticed, here are some problems I'm trying to solve:

  1. Nvidia Surround – you can't help me here, it's just stupid, I don't understand why they can't allow the monitors to be stacked horizontally at the same height, or vice versa. It has been a popular feature for years.
  2. Surround does not recognize PBP with two DP cables as two monitors. Since I have two DP inputs and one HDMI input (and my laptop can only be connected via HDMI), it is much easier to connect it like this. I now have to use an HDMI-to-DP adapter to connect my laptop. Does anyone know how to get nvidia / windows to treat such connected displays as two? The model in question is Samsung CRG9.
  3. Windows audio. Every time I turn 49 "PBP on or off or turn on Surround, Windows gets a new audio device, and someone from Microsoft made the brilliant decision that Windows should just start redirecting some of the audio (because why should that be? Make sense?) On the new device For audio I use an external audio card connected via USB, for the entire audio input I do not want it anywhere else. Is there a way to tell Windows to use it? disable the built-in audio, but I still connect my microphone to the PC this way.

"I'll just surround myself with the best and most serious people, believe me." – Donald Trump, 2015. Was he right?

Here are some more quotes from Trump. Just watch the Trump pendants move them down with their thumbs. Pure comedy gold.

"I do not think anyone knows more about campaign finance than me because I contribute the most."

"I know more about people who receive reviews than anyone else."

"I know more about ISIS than the generals."

"I understand social media, I understand the power of Twitter, I understand the power of Facebook perhaps better than almost anyone else, based on my results, right?"

"I know more about dishes than any human on earth."

"Who knows more about complaints than me? I am the king."

"I understand politicians better than anyone else."

"Nobody knows the system better than me. I know the H1B. I know the H2B.

"Nobody knows more about trade than me."

"Nobody knows the [government] system better than me."

"I know more about renewable energy than anyone on Earth."

"I think nobody knows more about taxes than me, maybe in the history of the world."

"I'm the king of debt, I'm great with debt, nobody knows debt better than me."

"I understand money better than anyone else."

"Look, as a contractor, no one in the history of this country has known as much about infrastructure as Donald Trump."

"I know more about Cory [Booker] than he does about himself."

"I think I know more about the other side than almost anyone else."

"Nobody knows more about building than me."

"I think I know better than [the Federal Reserve]."

"Technology – nobody knows more about technology than me."

"I know more about drones than anyone else, and I know about every form of security you can have."

"Let a drone fly – and I think nobody knows more about technology than me."

Recording Technique – What is this effect when millions of colored points of light surround people in the dark?

The correct term for what you refer to is a "blur circle" that occurs to mark blurred markers. The blurrier a point is highlighted, the greater the blur circle to the size of the entrance pupil (which is the ultimate limiting factor).

Bokeh, derived from the Japanese word boke (ボ ボ, "haze" or "blur"), simply refers to blur … usually background, but also foreground. Boke does not specifically refer to blurred highlights that form blur circles. Blur circles are a specific aspect of photography. When made with a high quality lens that produces high quality blurs, they are usually quite appealing.

In your photo, it looks like blur circles, but with relatively little blurring. I also suspect that they are generated by very small point light sources … Christmas lights, possibly the result of firecrackers etc.