Exemple #1
0
        public override bool Tick()
        {
            Entity       agent = context.agent;
            WaypointPath path  = context.path;

            Debug.Assert(path != null, nameof(path) + " != null");

            WaypointTracker tracker       = path.GetTrackerForEntity(context.agent.index);
            int             completedLaps = tracker.CompletedLaps;

            Vector3 waypoint = tracker.CurrentWaypoint;

            float distSquared = agent.transformInfo.DistanceToSquared(waypoint);

            if (distSquared < 20 * 20)   // todo replace with a radius per waypoint
            {
                tracker.Progress();
            }

            waypoint = tracker.CurrentWaypoint;
            ApproachType approachType = tracker.IsFinalWaypoint ? ApproachType.Arrive : ApproachType.Normal;

            agent.FlightSystem.SetTargetPosition(waypoint, approachType);
            return(tracker.CompletedLaps != completedLaps);
        }
 public Simulator(ushort suitCount,
                  ushort valueCount,
                  ushort trials,
                  ushort experiments,
                  DealType deal,
                  ApproachType approach,
                  OutputType output)
 {
     SuitCount   = suitCount;
     ValueCount  = valueCount;
     Trials      = trials;
     Experiments = experiments;
     Deal        = deal;
     Approach    = approach;
     Output      = output;
 }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static Approach Create(
            DateTime initialDate,
            Employee recruiter,
            string jobTitle,
            Company targetCompany,
            ApproachType ApproachType,
            string createdBy = null)
        {
            createdBy = createdBy ?? Common.Utilities.DefaultUser();
            var sp = new Approach
            {
                InitialDate = initialDate,
                JobTitle    = jobTitle,
                AuditData   = AuditData.Create(createdBy)
            };

            return(sp);
        }
Exemple #4
0
    public void BumpInto(CarMenuCarInput bumpee, bool fwd)
    {
        if (ExitSequenceRunning)
        {
            ExitSequenceRunning = false;
        }
        trCam = GameObject.Find("CameraSpinner").transform;
        float Angle = Vector3.Angle(transform.position - trCam.position, Vector3.forward);

        if (Angle < 35)
        {
            _approach = ApproachType.Direct;
        }
        else
        {
            float rnd = Random.value;
            transform.localPosition = new Vector3(fwd ? 10 : -10, 0, bumpee.transform.localPosition.z * 2);
        }

        StartCoroutine(BumpSequence(bumpee, fwd));
    }
Exemple #5
0
 public void SetTargetPosition(Vector3 position, ApproachType arrivalType)
 {
     // AssertOnlyOneCallPerFrame();
     targetPosition   = position;
     this.arrivalType = arrivalType;
 }
Exemple #6
0
 public void SetTargetDirection(Vector3 direction, ApproachType arrivalType = ApproachType.Normal)
 {
     //   AssertOnlyOneCallPerFrame();
     targetPosition   = direction * 10000f;
     this.arrivalType = arrivalType;
 }
        // WARNING: stores all attained positions in memory in two shapes, and can cause memory issues on some platforms
        public SolveResults Solve(PretzelPosition position, ApproachType approach, OutputType output)
        {
            bool hasDuellingDeuces = position.HasDuelingDeuces();
            bool hasDuckingCrab    = position.HasDuckingCrab();

            if (hasDuellingDeuces || hasDuckingCrab)
            {
                return(new SolveResults {
                    Solvable = false, Moves = 0, Deadends = 0, HasDuellingDeuces = hasDuellingDeuces, HasDuckingCrab = hasDuckingCrab
                });
            }
            else
            {
                LinkedList <PositionInfo>   attainablePositionList = new LinkedList <PositionInfo>();   // ordered doubly-linked list of positions known to be attainable (explored and not yet explored)
                Dictionary <ushort, object> attainedPositions      = new Dictionary <ushort, object>(); // trie of all positions attained (explored)
                                                                                                        // add initial position to list
                attainablePositionList.AddFirst(new PositionInfo(position, null, position.CalculateScore()));
                // add initial position to trie
                int lastTableauIndex = position.Tableau.Length - 1;
                Dictionary <ushort, object> childTrieNode = new Dictionary <ushort, object> {
                    { position.Tableau[lastTableauIndex], 0 }
                };
                for (int i = lastTableauIndex - 1; i >= 0; --i)
                {
                    Dictionary <ushort, object> trieNode = new Dictionary <ushort, object> {
                        { position.Tableau[i], childTrieNode }
                    };
                    childTrieNode = trieNode;
                }
                LinkedListNode <PositionInfo>         solutionListNode = null;
                List <LinkedListNode <PositionInfo> > deadendListNodes = new List <LinkedListNode <PositionInfo> >();
                LinkedListNode <PositionInfo>         currentListNode  = attainablePositionList.First;
                while (((solutionListNode == null) || (approach == ApproachType.FullTree)) && (currentListNode != null))
                {
                    if (currentListNode.Value.Position.IsSolved())
                    {
                        solutionListNode = currentListNode;
                    }
                    else
                    {
                        List <PretzelPosition> subsequentPositions = currentListNode.Value.Position.GetSubsequentPositions();
                        if (subsequentPositions.Count > 0)
                        {
                            if (approach == ApproachType.RandomPlay)
                            {
                                int randomPlayIndex = (short)rng.Next(0, subsequentPositions.Count);
                                attainablePositionList.AddLast(new PositionInfo(subsequentPositions[randomPlayIndex], currentListNode, subsequentPositions[randomPlayIndex].CalculateScore()));
                            }
                            else if (approach == ApproachType.ScoredLookahead)
                            {
                                short highestScore      = subsequentPositions[0].CalculateScore();
                                int   highestScoreIndex = 0;
                                for (int i = 1; i < subsequentPositions.Count; ++i)
                                {
                                    short positionScore = subsequentPositions[i].CalculateScore();
                                    if (positionScore > highestScore)
                                    {
                                        highestScore      = positionScore;
                                        highestScoreIndex = i;
                                    }
                                }
                                attainablePositionList.AddLast(new PositionInfo(subsequentPositions[highestScoreIndex], currentListNode, highestScore));
                            }
                            else
                            {
                                for (short i = 0; i < subsequentPositions.Count; ++i)
                                {
                                    // check if position has already been attained
                                    bool positionPreviouslyAttained = true;
                                    LinkedListNode <PositionInfo> attainablePositionListNode = null;
                                    ushort currentTableauIndex = 0;
                                    Dictionary <ushort, object> currentTrieNode = attainedPositions;
                                    object childNodeObject = null;
                                    while (positionPreviouslyAttained && (currentTableauIndex <= lastTableauIndex))
                                    {
                                        if (currentTrieNode.TryGetValue((ushort)subsequentPositions[i].Tableau[currentTableauIndex], out childNodeObject))
                                        {
                                            if (currentTableauIndex < lastTableauIndex)
                                            {
                                                currentTrieNode = (Dictionary <ushort, object>)childNodeObject;
                                            }
                                            else
                                            {
                                                attainablePositionListNode = (LinkedListNode <PositionInfo>)childNodeObject; // unwrap pointer to position in attainablePositionList from position's last grid position node in trie
                                            }
                                            ++currentTableauIndex;
                                        }
                                        else
                                        {
                                            positionPreviouslyAttained = false;
                                            // add remainder of position to trie, starting at the last grid position and chaining forward to divergent node
                                            // NOTE: last grid position in trie contains wrapped reference to this position within attainablePositionList
                                            childTrieNode = new Dictionary <ushort, object> {
                                                { subsequentPositions[i].Tableau[lastTableauIndex], currentListNode }
                                            };
                                            for (int j = lastTableauIndex - 1; j > currentTableauIndex; --j)
                                            {
                                                Dictionary <ushort, object> newTrieNode = new Dictionary <ushort, object> {
                                                    { subsequentPositions[i].Tableau[j], childTrieNode }
                                                };
                                                childTrieNode = newTrieNode;
                                            }
                                            currentTrieNode.Add((ushort)subsequentPositions[i].Tableau[currentTableauIndex], childTrieNode);
                                        }
                                    }
                                    // if new position attained, queue it at the end of attainable position list
                                    if (!positionPreviouslyAttained)
                                    {
                                        attainablePositionList.AddLast(new PositionInfo(subsequentPositions[i], currentListNode, subsequentPositions[i].CalculateScore()));
                                    }
                                    else if (approach == ApproachType.FullTree)
                                    {
                                        // position already reached; add new path to it if analyzing full decision tree
                                        attainablePositionListNode.Value.ParentIndexes.Add(currentListNode);
                                    }
                                }
                            }
                        }
                        else
                        {
                            // deadend
                            deadendListNodes.Add(currentListNode);
                        }
                    }
                    currentListNode = currentListNode.Next;
                }
                // output and return results
                if (output == OutputType.Verbose)
                {
                    Console.WriteLine(attainablePositionList.Count + " Attainable Positions Explored");
                    if (approach == ApproachType.FullTree)
                    {
                        Console.WriteLine(deadendListNodes.Count.ToString() + " Dead Ends");
                    }
                }
                if (solutionListNode != null)
                {
                    if (output == OutputType.Verbose)
                    {
                        Console.WriteLine("Solution (read last line to first):");
                    }
                    ushort solutionMoveCount = 0;
                    while (solutionListNode != null)
                    {
                        string scoreText = string.Empty;
                        if (approach == ApproachType.ScoredLookahead)
                        {
                            scoreText = " | Score = " + solutionListNode.Value.Score.ToString();
                        }
                        if (output == OutputType.Verbose)
                        {
                            Console.WriteLine(solutionListNode.Value.Position.ToString() + scoreText);
                        }
                        solutionListNode = solutionListNode.Value.ParentIndexes[0];
                        ++solutionMoveCount;
                    }
                    --solutionMoveCount; // do not count starting position
                    if (output == OutputType.Verbose)
                    {
                        Console.WriteLine(solutionMoveCount.ToString() + " Moves");
                    }
                    return(new SolveResults {
                        Solvable = true, Moves = solutionMoveCount, Deadends = (ushort)deadendListNodes.Count
                    });
                }
                else
                {
                    if (output == OutputType.Verbose)
                    {
                        Console.WriteLine("No Solution Found");
                    }
                    return(new SolveResults {
                        Solvable = false, Moves = 0, Deadends = (ushort)deadendListNodes.Count
                    });
                }
            }
        }
        public FlightSafetyReportModelSp getflightSafetyJson(FlightSafetyReportModel sd)
        {
            FlightSafetyReportModelSp sddp = new FlightSafetyReportModelSp();

            sddp.MobileEntry = true;
            List <string> strData = sd.ApproachType != null?sd.ApproachType.Trim(',').Split(',').ToList() : null;

            List <string> relativeStr = sd.Relativeposition != null?sd.Relativeposition.Trim(',').Split(',').ToList() : null;

            List <string> deviation = sd.ReasonforDeviation != null?sd.ReasonforDeviation.Trim(',').Split(',').ToList() : null;



            if (strData != null)
            {
                ApproachType sfapp = new ApproachType();
                sfapp.results = strData;
                Metadata1 md1 = new Metadata1();
                md1.type          = "Collection(Edm.String)";
                sfapp.__metadata  = md1;
                sddp.ApproachType = sfapp;
            }



            if (relativeStr != null)
            {
                ReasonForDeviation rsDev = new ReasonForDeviation();
                rsDev.results = deviation;
                Metadata2 md2 = new Metadata2();
                md2.type                = "Collection(Edm.String)";
                rsDev.__metadata        = md2;
                sddp.ReasonforDeviation = rsDev;
            }

            if (deviation != null)
            {
                IntruderACRelativePosition intru = new IntruderACRelativePosition();
                intru.results = deviation;
                Metadata3 md3 = new Metadata3();
                md3.type              = "Collection(Edm.String)";
                intru.__metadata      = md3;
                sddp.Relativeposition = intru;
            }


            sddp.ReportType       = "Flight Safety Report";// sd.ReportType;
            sddp.AircraftRegis    = sd.AircraftRegistration;
            sddp.EventTitle       = sd.EventTitle;
            sddp.FlightNumber     = sd.FlightNumber;
            sddp.DateOfEvent      = sd.DateOfEvent.ToString("yyyy-MM-dd") + "T07:00:00Z";
            sddp.DepartureStation = sd.DepartureStation;
            sddp.ArrivalStation   = sd.ArrivalStation;
            sddp.DivertStation    = sd.DivertStation;
            sddp.Area_FIR         = sd.Area_FIR;
            sddp.DescribeEvent    = sd.DescribeEvent != null ? "<div class=\"ExternalClass733EA004DCC641EFAFED516F5D12CCA7\"><br>\u200b" + sd.DescribeEvent + "<br><\u002fdiv>" : null;
            sddp.Attachment       = sd.Attachment;
            sddp.MOR = SSIRShortForm.MORTypeID != null?Convert.ToString(SSIRShortForm.MORTypeID + 1) : null;  //Convert.ToString(sd.MOR + 1);

            sddp.ConfiReport = sd.ConfiReport == true ? "1" : "0";
            sddp.ssQ         = sd.ssQ == true ? "1" : "0";
            sddp.pax         = sd.pax;

            sddp.CommanderPForPM = FlightSafetyReportView.CommanderPForPMpickerValue;
            if (FlightSafetyReportView.PeoplePickerCommander != null)
            {
                sddp.CommandersEmail = FlightSafetyReportView.PeoplePickerCommander.Id.ToString();
            }

            if (FlightSafetyReportView.PeoplePickercrew1email != null)
            {
                sddp.FlightCrew1 = FlightSafetyReportView.PeoplePickercrew1email.Id.ToString();
            }

            if (FlightSafetyReportView.PeoplePickercrew2email != null)
            {
                sddp.FlightCrew2 = FlightSafetyReportView.PeoplePickercrew2email.Id.ToString();
            }

            sddp.FlightCrew1PFPMOBs       = FlightSafetyReportView.FlightCrew1PFPMOBspickerValue;
            sddp.FlightCrew2PFPMOBs       = FlightSafetyReportView.FlightCrew2PFPMOBspickerValue;
            sddp.Ifflighteventselectphase = FlightSafetyReportView.IfflighteventselectphasepickerValue;
            sddp.Ifongroundselectwhere    = FlightSafetyReportView.IfongroundselectwherepickerValue;
            sddp.Altitude    = sd.Altitude;
            sddp.IASMach     = sd.IASMach;
            sddp.AutopilotOn = sd.AutopilotOn == true ? "1" : "0";
            sddp.ATOn        = sd.ATOn == true ? "1" : "0";

            //  sddp.ApproachType = "{\"__metadata\":{\"type\":\"Collection(Edm.String)\"},\"results\":\"" + apptypestr + "\"}";
            sddp.Heading              = sd.Heading;
            sddp.VS                   = sd.VS;
            sddp.Gear                 = FlightSafetyReportView.GearpickerValue;
            sddp.Speedbrake           = FlightSafetyReportView.SpeedbrakepickerValue;
            sddp.FlapPosition         = sd.FlapPosition;
            sddp.Weight               = sd.Weight;
            sddp.FuelDumping          = sd.FuelDumping == true ? "1" : "0";
            sddp.SeatbeltSign         = sd.SeatbeltSign == true ? "1" : "0";
            sddp.MeteorologicalReport = FlightSafetyReportView.MeteorologicalReportpickerValue;
            sddp.Wind                 = sd.Wind;
            sddp.VisRVR               = sd.VisRVR;
            sddp.Temp                 = sd.Temp;
            sddp.Light                = FlightSafetyReportView.LightpickerValue;
            sddp.Weather              = FlightSafetyReportView.WeatherpickerValue;
            sddp.Precipitation        = FlightSafetyReportView.PrecipitationpickerValue;
            sddp.Turbulence           = FlightSafetyReportView.TurbulencepickerValue;
            sddp.RWYDirection         = sd.RWYDirection;
            sddp.Conditions           = FlightSafetyReportView.ConditionspickerValue;
            sddp.NAVAIDS              = FlightSafetyReportView.NAVAIDSpickerValue;
            sddp.ClearedAltitude      = sd.ClearedAltitude;
            sddp.DeviationHorizontal  = sd.DeviationHorizontal;
            sddp.Vertical             = sd.Vertical;
            //  sddp.ReasonforDeviation = sd.ReasonforDeviation != null ? "<div class=\"ExternalClass733EA004DCC641EFAFED516F5D12CCA7\"><br>\u200b" + sd.ReasonforDeviation + "<br><\u002fdiv>" : null;
            sddp.TAAlert        = sd.TAAlert == true ? "1" : "0";
            sddp.RAAlert        = sd.RAAlert == true ? "1" : "0";
            sddp.RACommand      = sd.RACommand;
            sddp.IntruderACType = sd.IntruderACType;
            sddp.Callsign       = sd.Callsign;
            //  sddp.Relativeposition = sd.Relativeposition != null ? "<div class=\"ExternalClass733EA004DCC641EFAFED516F5D12CCA7\"><br>\u200b" + sd.Relativeposition + "<br><\u002fdiv>" : null;
            sddp.Bearing        = sd.Bearing;
            sddp.Range          = sd.Range;
            sddp.ATC            = FlightSafetyReportView.ATCorAirportReportFiledpickerValue;
            sddp.ATCUnit        = sd.ATCUnit;
            sddp.Frequency      = sd.Frequency;
            sddp.TypeofWarnings = sd.TypeofWarnings != null ? "<div class=\"ExternalClass733EA004DCC641EFAFED516F5D12CCA7\"><br>\u200b" + sd.TypeofWarnings + "<br><\u002fdiv>" : null;
            sddp.WildlifeType   = sd.WildlifeType;
            sddp.Numberofbirds  = FlightSafetyReportView.NumberofbirdspickerValue;
            sddp.SizeofWildlife = FlightSafetyReportView.SizeofWildlifepickerValue;
            sddp.AircraftDamage = FlightSafetyReportView.AircraftDamagepickerValue;

            sddp.ImpactAreaDamage = sd.ImpactAreaDamage != null ? "<div class=\"ExternalClass733EA004DCC641EFAFED516F5D12CCA7\"><br>\u200b" + sd.ImpactAreaDamage + "<br><\u002fdiv>" : null;
            sddp.SubmitterEmail   = sd.SubmitterEmail;
            sddp.NameStaffNumber  = sd.NameStaffNumber;
            return(sddp);
        }
Exemple #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="approachType"></param>
        /// <returns></returns>
        public Entity.ApproachTypeEntity GetApproachTypeEntity(ApproachType approachType)
        {
            var t = approachType.ToString();

            return(Query(x => x.ApproachMethod == approachType.ToString()).FirstOrDefault());
        }