コード例 #1
0
        protected override float ScoreAngle(float angle, Vector2 position, Vector2 momentum)
        {
            float accumulator = 0f;

            var fleet = Robot.SensorFleets.MyFleet;

            if (fleet != null)
            {
                ConsideredPoints.Add(position);

                foreach (var danger in Projections)
                {
                    var dist = Vector2.Distance(danger, position);
                    if (dist < DistanceFromCenterThreshold)
                    {
                        accumulator -= 1 / (dist * dist);
                    }
                }
            }

            return(accumulator);
        }
コード例 #2
0
ファイル: DogeWow.cs プロジェクト: yahyaguzide/daud
        protected override float ScoreAngle(float angle, Vector2 position, Vector2 momentum)
        {
            float accumulator = 0f;

            var fleet = Robot.SensorFleets.MyFleet;
            var dead  = 0;

            if (fleet != null)
            {
                ConsideredPoints.Add(position);
                foreach (var ship in fleet.Ships)
                {
                    var   shipDead = 0;
                    float farA     = 40000 * 40000;
                    float farB     = 40000 * 40000;
                    float minA     = 0.0f;
                    float hitd     = 90.0f;
                    foreach (var danger in Projections)
                    {
                        var dist = Vector2.Distance(danger, position + ship.Position - fleet.Center);
                        if (dist < DistanceFromCenterThreshold)
                        {
                            var fm = -hitd * hitd / MathF.Max(dist * dist, hitd * hitd) / fleet.Ships.Count * (2.0f + Vector2.Dot(danger - (position + ship.Position - fleet.Center), new Vector2(MathF.Cos(angle), MathF.Sin(angle))) / dist);
                            farA = MathF.Min(dist, farA);
                            minA = MathF.Min(fm, minA);
                            if (dist < hitd)
                            {
                                shipDead = 1;
                            }
                        }
                    }
                    foreach (var danger in PhantomProjections)
                    {
                        var dist = Vector2.Distance(danger, position + ship.Position - fleet.Center);
                        if (dist < DistanceFromCenterThreshold)
                        {
                            farB = MathF.Min(dist, farB);
                        }
                    }

                    var thr = DistanceFromCenterThreshold;
                    // if (farB < thr && farA < thr)
                    // {


                    //     var dist = farB;
                    //     var accumulator1 = -10.0f * 10.0f / (MathF.Max(dist * dist, 10.0f * 10.0f)) / fleet.Ships.Count/2.0f;
                    //     dist = farA;
                    //     accumulator1 = MathF.Min(accumulator1,-10.0f * 10.0f / (MathF.Max(dist * dist, 10.0f * 10.0f)) / fleet.Ships.Count);
                    //     accumulator+=accumulator1;
                    //     // accumulator -= 1.0f / (MathF.Max(dist*dist,10.0f*10.0f)+0.001f)/fleet.Ships.Count/2.0f;

                    //     // accumulator -=1.0f/d/fleet.Ships.Count/4.0f;//( 400.0f*400.0f )/ (farA+1.0f)/fleet.Ships.Count;
                    // }else{
                    if (farA < thr)
                    {
                        var dist = farA;
                        accumulator += minA;
                    }
                    // if (farB < thr)
                    // {


                    //     var dist = farB;
                    //     accumulator -= 1.0f / (MathF.Max(dist * dist, 10.0f * 10.0f)) / fleet.Ships.Count/2.0f;
                    //     // accumulator -= 1.0f / (MathF.Max(dist*dist,10.0f*10.0f)+0.001f)/fleet.Ships.Count/2.0f;

                    //     // accumulator -=1.0f/d/fleet.Ships.Count/4.0f;//( 400.0f*400.0f )/ (farA+1.0f)/fleet.Ships.Count;
                    // }
                    // }
                    dead += shipDead;
                }
            }
            if (fleet.Ships.Count < dead * 2 + 1)
            {
                return(accumulator * 1000.0f);
            }

            return(accumulator * ((float)dead + 1.0f));//-0.5f+1.0f/(1.0f+MathF.Exp(accumulator));
        }