示例#1
0
            public void Execute(int index)
            {
                BioClouds.CloudIDPosRadius CloudPos;


                float3 currentMarkerPosition;
                NativeMultiHashMapIterator <int> it;

                float3 moveStep  = float3.zero;
                float3 direction = float3.zero;
                float  totalW;

                AgentTotalW.TryGetValue(AgentData[index].ID, out totalW);

                bool keepgoing = AgentMarkersMap.TryGetFirstValue(AgentData[index].ID, out currentMarkerPosition, out it);

                if (!keepgoing)
                {
                    return;
                }

                float F = AgentCalculations.GetF(currentMarkerPosition, AgentPos[index].Value, AgentGoals[index].SubGoal - AgentPos[index].Value);

                direction += AgentCalculations.PartialW(totalW, F) * AgentData[index].MaxSpeed * (currentMarkerPosition - AgentPos[index].Value);



                while (AgentMarkersMap.TryGetNextValue(out currentMarkerPosition, ref it))
                {
                    F = AgentCalculations.GetF(currentMarkerPosition, AgentPos[index].Value, AgentGoals[index].SubGoal - AgentPos[index].Value);

                    direction += AgentCalculations.PartialW(totalW, F) * AgentData[index].MaxSpeed * (currentMarkerPosition - AgentPos[index].Value);
                }


                float moduleM = math.length(direction);
                float s       = (float)(moduleM * math.PI);

                if (s > AgentData[index].MaxSpeed)
                {
                    s = AgentData[index].MaxSpeed;
                }

                if (moduleM > 0.00001f)
                {
                    moveStep = s * (math.normalize(direction));
                }
                else
                {
                    moveStep = float3.zero;
                }

                AgentStep[index] = new AgentStep()
                {
                    delta = moveStep
                };
            }
            public void Execute(int index)
            {
                float3 moveStep = float3.zero;
                float3 goalDir  = math.normalize(AgentGoals[index].SubGoal - AgentPos[index].Value);


                //Linear Estimative
                float  y   = AgentStep[index].delta.y;
                float3 pdr = AgentStep[index].delta * TimeJump;



                //Environment Perturbation
                pdr *= (1 - EnvironmentalComplexity);



                //Density Perturbation
                int3 cell = pos2cell(AgentPos[index].Value.x, AgentPos[index].Value.z);

                cellDensities.TryGetValue(cell, out float localDensity);
                if (localDensity == 0.0f)
                {
                    return;
                }

                int   weibulIndex = densityIndex(localDensity);
                float r           = 0;

                switch (weibulIndex)
                {
                case 0:
                    r = weibul0_25[random.NextInt(4999)];
                    break;

                case 1:
                    r = weibul0_5[random.NextInt(4999)];
                    break;

                case 2:
                    r = weibul0_75[random.NextInt(4999)];
                    break;

                case 3:
                    r = weibul1_0[random.NextInt(4999)];
                    break;

                case 4:
                    r = weibul1_25[random.NextInt(4999)];
                    break;

                case 5:
                    r = weibul1_5[random.NextInt(4999)];
                    break;

                case 6:
                    r = weibul1_75[random.NextInt(4999)];
                    break;

                case 7:
                    r = weibul2_0[random.NextInt(4999)];
                    break;

                case 8:
                    r = weibul2_25[random.NextInt(4999)];
                    break;

                case 9:
                    r = weibul2_5[random.NextInt(4999)];
                    break;
                }
                Debug.Log(r);

                float3 IP = r * goalDir * TimeJump;

                pdr -= IP;

                moveStep   = pdr;
                moveStep.y = y;

                AgentStep[index] = new AgentStep()
                {
                    delta = moveStep
                };
            }
示例#3
0
            public void Execute(int index)
            {
                BioClouds.CloudIDPosRadius CloudPos;
                if (!BioClouds2PosMap.TryGetValue(AgentCloudID[index].CloudID, out CloudPos))
                {
                    return;
                }
                float3 CloudPosition          = CloudPos.position;
                float3 BioCrowdsCloudPosition = WindowManager.Clouds2Crowds(CloudPosition);


                float3 Agent2CloudCenterVec = BioCrowdsCloudPosition - AgentPos[index].Value;

                float3 NormalizedAgent2CloudCenter = math.normalize(Agent2CloudCenterVec);


                float3 currentMarkerPosition;
                NativeMultiHashMapIterator <int> it;

                float3 moveStep  = float3.zero;
                float3 direction = float3.zero;
                float  totalW;

                AgentTotalW.TryGetValue(AgentData[index].ID, out totalW);

                bool keepgoing = AgentMarkersMap.TryGetFirstValue(AgentData[index].ID, out currentMarkerPosition, out it);

                if (!keepgoing)
                {
                    return;
                }

                float extraweight = math.dot(NormalizedAgent2CloudCenter, currentMarkerPosition - AgentPos[index].Value);

                float F = AgentCalculations.GetF(currentMarkerPosition, AgentPos[index].Value, AgentGoals[index].SubGoal - AgentPos[index].Value);

                F += extraweight * 0.1f;

                direction += AgentCalculations.PartialW(totalW, F) * AgentData[index].MaxSpeed * (currentMarkerPosition - AgentPos[index].Value);



                while (AgentMarkersMap.TryGetNextValue(out currentMarkerPosition, ref it))
                {
                    extraweight = math.dot(NormalizedAgent2CloudCenter, currentMarkerPosition - AgentPos[index].Value);

                    F = AgentCalculations.GetF(currentMarkerPosition, AgentPos[index].Value, AgentGoals[index].SubGoal - AgentPos[index].Value);

                    F += extraweight * 0.1f;

                    direction += AgentCalculations.PartialW(totalW, F) * AgentData[index].MaxSpeed * (currentMarkerPosition - AgentPos[index].Value);
                }


                float moduleM = math.length(direction);
                float s       = (float)(moduleM * math.PI);

                if (s > AgentData[index].MaxSpeed)
                {
                    s = AgentData[index].MaxSpeed;
                }

                if (moduleM > 0.00001f)
                {
                    moveStep = s * (math.normalize(direction));
                }
                else
                {
                    moveStep = float3.zero;
                }

                AgentStep[index] = new AgentStep()
                {
                    delta = moveStep
                };
            }