Ejemplo n.º 1
0
        protected override void FinishLevelSetup()
        {
            // set variables
            m_bestPlayerScore    = float.PositiveInfinity;
            m_thresholdscorebeat = false;

            if (!m_endlessMode)
            {
                // set score key for current level
                m_scorekey  = SceneManager.GetActiveScene().name + "_score_" + m_levelCounter;
                m_highscore = PlayerPrefs.GetFloat(m_scorekey, float.PositiveInfinity);
            }
            m_numberOfHints = (int)Math.Floor(.5 * Math.Sqrt(m_settlements.Count()));

            //calculate goal
            var greedySpanner = Spanner.GreedySpanner(
                m_settlements.Select(go => new Vertex(go.Pos)).ToList(),
                m_t
                );

            m_thresholdscore = greedySpanner.TotalEdgeWeight + 0.0001f;

            UpdateHintButton();

            m_scoreText.text = "Information on your graph is displayed here.\nGoal: Find a " + m_t + "-spanner";
        }
Ejemplo n.º 2
0
        //Initialize SpannersDataDetailViewModel Properties
        public void SetSpannersDataDetailViewModelProperties(string spannerCode)
        {
            //var currentGroup = _httpContext.HttpContext.User.FindFirst(ClaimTypes.GroupSid).Value;

            Spanner       spanner       = _flightSpannersData.GetSpannerByCode(spannerCode);
            Qualification qualification = _flightSpannersData.GetQualificationByQualificationId(spanner.QualificationId);

            SpannerCode            = spanner.SpannerCode;
            SpannerLicenseNo       = spanner.SpannerLicenseNo;
            GroupName              = spanner.GroupName;
            SpannerFName           = spanner.SpannerFName;
            SpannerM1Name          = spanner.SpannerM1Name;
            SpannerM2Name          = spanner.SpannerM2Name;
            SpannerLName           = spanner.SpannerLName;
            SpannerEmail           = spanner.SpannerEmail;
            SpannerMobile1         = spanner.SpannerMobile1;
            SpannerMobile2         = spanner.SpannerMobile2;
            SpannerGender          = spanner.SpannerGender;
            SpannerBirthday        = spanner.SpannerBirthday;
            SpannerHireDate        = spanner.SpannerHireDate;
            IsSpannerViewGroupData = spanner.IsSpannerViewGroupData;
            IsSpannerHasCar        = spanner.IsSpannerHasCar;

            DepartmentName = spanner.DepartmentName;

            QualificationId     = qualification.QualificationId;
            QualificationName   = qualification.QualificationName;
            QualificationDegree = qualification.QualificationDegree;
            QualificationMajor  = qualification.QualificationMajor;
        }
        //Initialize SpannersDataDetailViewModel Properties
        public void SetApprovalsDataDetailViewModelProperties(int approvalId)
        {
            var currentGroup = _httpContext.HttpContext.User.FindFirst(ClaimTypes.GroupSid).Value;

            Approval       approval       = _flightSpannersData.GetApprovalByApprovalId(approvalId);
            Spanner        spanner        = _flightSpannersData.GetSpannerByCode(approval.SpannerCode);
            AircraftType   aircraftType   = _flightSpannersData.GetAircraftTypeByAircraftTypeId(approval.AircraftTypeId);;
            ApprovalDetail approvalDetail = _flightSpannersData.GetApprovalDetailByApprovalDetailId(approval.ApprovalDetailId);

            GroupName = currentGroup;

            ApprovalId       = approvalId;
            SpannerCode      = approval.SpannerCode;
            SpannerLicenseNo = spanner.SpannerLicenseNo;
            SpannerName      = spanner.SpannerFName + " " + spanner.SpannerM1Name;

            AircraftTypeId       = aircraftType.AircraftTypeId;
            AircraftModel        = aircraftType.AircraftModel;
            EngineModel          = aircraftType.EngineModel;
            AircraftTypeConstant = aircraftType.AircraftTypeConstant;

            ApprovalDetailId = approvalDetail.ApprovalDetailId;
            ApprovalRating   = approvalDetail.ApprovalRating;
            ApprovalCategory = approvalDetail.ApprovalCategory;
            ApprovalConstant = approvalDetail.ApprovalConstant;
        }
Ejemplo n.º 4
0
        public bool ValidatePasswordSpanner(string code, string password)
        {
            Spanner spanner = _context.Spanner.FirstOrDefault(r => r.SpannerCode == code);

            if (spanner == null)
            {
                return(false);
            }

            string databasePassword = spanner.SpannerPassword;
            bool   returnValue      = databasePassword.Equals(password) ? true : false;

            return(returnValue);
        }
Ejemplo n.º 5
0
        public override void CheckSolution()
        {
            // verify if graph is t-spanner
            var   spannerVerifier = Spanner.VerifySpanner(m_graph, m_t);
            float score           = m_graph.TotalEdgeWeight;

            if (spannerVerifier.IsSpanner)
            {
                // update best score
                if (score < m_bestPlayerScore)
                {
                    m_bestPlayerScore = score;
                }

                //victory is achieved by equaling the greedy spanner
                if (score <= m_thresholdscore)
                {
                    m_thresholdscorebeat = true;
                }
                else
                {
                    m_thresholdscorebeat = false;
                }

                // update all-time high score
                if (score < m_highscore)
                {
                    m_highscore = score;
                    PlayerPrefs.SetFloat(m_scorekey, m_highscore);
                }

                // enable or disable buttons
                if (m_thresholdscorebeat)
                {
                    EnableAdvanceButton();
                }
                else
                {
                    DisableBothButtons();
                }
            }
            else
            {
                // enable hints if still available
                UpdateHintButton();
            }

            UpdateTextField(spannerVerifier, score);
        }
Ejemplo n.º 6
0
        public void SpannerIsSpannerTest()
        {
            var pos = new List <Vertex> {
                new Vertex(9, 3), new Vertex(5, 6), new Vertex(4, 7), new Vertex(-2, 5), new Vertex(6, -3), new Vertex(23, 3), new Vertex(22, 4),
                new Vertex(9.5f, -3.4f), new Vertex(5.5f, -6.3f), new Vertex(-4.5f, 7.4f), new Vertex(-2.5f, -5.3f), new Vertex(6.5f, -3.3f), new Vertex(23.5f, -4.3f), new Vertex(22.5f, -5.3f)
            };
            var tlist = new List <float> {
                1f, 1.1f, 1.5f, 2f, 3f, 5f, 10f
            };

            foreach (var t in tlist)
            {
                var spanner = Spanner.GreedySpanner(pos, t);
                Assert.True(Spanner.VerifySpanner(spanner, t).IsSpanner, "we failed for t is: " + t);
            }
        }
Ejemplo n.º 7
0
        public void GreedySpannerLineGraphTest()
        {
            //Line graph test case
            var vert = new List <Vertex> {
                new Vertex(0, 0), new Vertex(1, 0), new Vertex(2, 0)
            };

            var lineGraph = new AdjacencyListGraph(vert);

            lineGraph.AddEdge(vert[0], vert[1]);
            lineGraph.AddEdge(vert[1], vert[2]);

            var spanner = Spanner.GreedySpanner(vert, 20);

            Assert.True(lineGraph.Equals(spanner));
        }
Ejemplo n.º 8
0
        public void GreedySpannerCompleteTest()
        {
            Assert.True(m_complete4.Equals(Spanner.GreedySpanner(m_complete4pos, 1)));

            //large test case
            var pos = new List <Vertex> {
                new Vertex(9, 3), new Vertex(5, 6), new Vertex(4, 7), new Vertex(-2, 5), new Vertex(6, -3), new Vertex(23, 3), new Vertex(22, 4),
                new Vertex(9.5f, -3.4f), new Vertex(5.5f, -6.3f), new Vertex(-4.5f, 7.4f), new Vertex(-2.5f, -5.3f), new Vertex(6.5f, -3.3f), new Vertex(23.5f, -4.3f), new Vertex(22.5f, -5.3f)
            };
            var completegraph = new AdjacencyListGraph(pos);

            completegraph.MakeComplete();
            var spanner = Spanner.GreedySpanner(pos, 1);

            Assert.True(completegraph.Equals(spanner));
        }
Ejemplo n.º 9
0
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);
            phoneEt = view.FindViewById <TextInputLayout>(Resource.Id.phone_et);
            var gsPhoneEt  = view.FindViewById <TextInputEditText>(Resource.Id.gs_phone_et);
            var facebookTv = view.FindViewById <TextView>(Resource.Id.facebook_log_btn);
            var spanner    = new Spanner(Activity, true);

            spanner.SetSpan(facebookTv, textToSpanarray);
            spanner.OnSpanClick += (s1, e1) =>
            {
                LoginManager.Instance.LogInWithReadPermissions(this, new List <string> {
                    "public_profile", "email"
                });
            };
            gsPhoneEt.Click += GsPhoneEt_Click;
        }
Ejemplo n.º 10
0
 public Engineer()
 {
     _weapon1    = new RailGun();
     _weapon2    = new SuperShotgun();
     _weapon3    = new Spanner();
     _weapon4    = null;
     _gren1      = Ammunition.FragGrenade;
     _gren2      = Ammunition.EMPGrenade;
     _health     = 80;
     _armour     = 50;
     _maxShells  = 50;
     _maxNails   = 50;
     _maxRockets = 50;
     _maxCells   = 200;
     _maxGren1   = 4;
     _maxGren2   = 4;
 }
        private List <DaysOfInActive> GetInActivePeriodListBySpannerCode(string spannerCode)
        {
            InActivePeriodList = new List <DaysOfInActive>();
            var     inActiveDaysQuery = _flightSpannersData.GetInActivePeriodBySpannerCode(spannerCode);
            Spanner spanner           = _flightSpannersData.GetSpannerByCode(spannerCode);

            foreach (var inActiveDays in inActiveDaysQuery)
            {
                InActivePeriodList.Add(new DaysOfInActive
                {
                    SpannerCode      = spanner.SpannerCode,
                    SpannerLicenseNo = spanner.SpannerLicenseNo,
                    SpannerName      = spanner.SpannerFName + " " + spanner.SpannerM1Name,
                    InActivePeriodId = inActiveDays.InActivePeriodId,
                    InActiveFromDate = inActiveDays.InActiveFromDate,
                    InActiveToDate   = inActiveDays.InActiveToDate
                });
            }
            return(InActivePeriodList);
        }
        public void SetFlightSummaryDetailViewModelProperties(string spannerCode)
        {
            GroupName = _httpContext.HttpContext.User.FindFirst(ClaimTypes.GroupSid).Value;
            //string spannerCode = _httpContext.HttpContext.Request.Query["SpannerCode"];
            Spanner spanner = _flightSpannersData.GetSpannerByCode(spannerCode);

            SpannerCode         = spannerCode;
            SpannerName         = spanner.SpannerFName + " " + spanner.SpannerM1Name;
            DeservedFlights     = _flightSpannersData.GetSpannerDeservedFlights(spannerCode);
            AllFlights          = _flightSpannersData.GetFlightsAll(spannerCode);
            SpannerLicenseNo    = spanner.SpannerLicenseNo;
            ShortFlights        = _flightSpannersData.GetFlightsShort(spannerCode);
            LongFlights         = _flightSpannersData.GetFlightsLong(spannerCode);
            ExtraFlights        = _flightSpannersData.GetFlightsExtra(spannerCode);
            MultipleFlights     = _flightSpannersData.GetFlightsMultiple(spannerCode);
            ApologyFlights      = _flightSpannersData.GetFlightsApology(spannerCode);
            BonusFlights        = _flightSpannersData.GetFlightsBonus(spannerCode);
            HolidayFlights      = _flightSpannersData.GetFlightsHoliday(spannerCode);
            CurrentMonthFlights = _flightSpannersData.GetFlightsCurrentMonth(spannerCode);
            IsCurrentlyInActive = _flightSpannersData.IsCurrentlyInActive(spannerCode);
            Balance             = _flightSpannersData.GetSpannerBalance(spannerCode);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Gives a road as a hint that still makes graph an invalid t-spanner.
        /// </summary>
        public void ShowHint()
        {
            // no more hints allowed
            if (m_numberOfHints <= 0)
            {
                return;
            }

            // check if graph spanner
            var spannerVerifier = Spanner.VerifySpanner(m_graph, m_t);

            if (spannerVerifier.IsSpanner)
            {
                throw new Exception("Hint button could be clicked while no hint is available");
            }

            // display the falsification road
            DisplayHintRoad(spannerVerifier.FalsificationStart, spannerVerifier.FalsificationEnd);

            m_numberOfHints -= 1;

            UpdateHintButton();
        }
Ejemplo n.º 14
0
        public Qualification GetQualificationOfSpanner(string code)
        {
            Spanner spanner = _context.Spanner.FirstOrDefault(r => r.SpannerCode == code);

            return(_context.Qualification.FirstOrDefault(r => r.QualificationId == spanner.QualificationId));
        }
Ejemplo n.º 15
0
        // Read the header and return it broken up into its parts
        public static QsValues ParseString(ReadOnlySpan <char> headerStr)
        {
            var sig          = new QsValues();
            var headerReader = new Spanner <char>(headerStr);
            var red5Text     = headerReader.ReadUntil(' ');

            if (!red5Text.Equals("red5", StringComparison.InvariantCultureIgnoreCase))
            {
                return(sig);
            }

            sig.Token = headerReader.ReadUntil(' ');
            var qs = new Spanner <char>(headerReader.ReadUntil(' '));

            sig.Token2 = headerReader.Remaining;

            do
            {
                var kvpStr = qs.ReadUntil('&');
                if (kvpStr.Length == 0)
                {
                    break;
                }

                var kvp = Spanner <char> .SplitKVP(kvpStr, '=');

                if (kvp.Key.Equals("ver", StringComparison.InvariantCultureIgnoreCase))
                {
                    sig.Version = int.TryParse(kvp.Value, out var version) ? version : 0;
                }
                else if (kvp.Key.Equals("tc", StringComparison.InvariantCultureIgnoreCase))
                {
                    sig.Time = uint.TryParse(kvp.Value, out var time) ? time : 0;
                }
                else if (kvp.Key.Equals("nonce", StringComparison.InvariantCultureIgnoreCase))
                {
                    sig.Nonce = kvp.Value;
                }
                else if (kvp.Key.Equals("uid", StringComparison.InvariantCultureIgnoreCase))
                {
                    sig.UID = kvp.Value;
                }
                else if (kvp.Key.Equals("host", StringComparison.InvariantCultureIgnoreCase))
                {
                    sig.Host = HttpUtility.UrlDecode(kvp.Value.ToString());
                }
                else if (kvp.Key.Equals("path", StringComparison.InvariantCultureIgnoreCase))
                {
                    sig.Path = HttpUtility.UrlDecode(kvp.Value.ToString());
                }
                else if (kvp.Key.Equals("hbody", StringComparison.InvariantCultureIgnoreCase))
                {
                    sig.Body = kvp.Value;
                }
                else if (kvp.Key.Equals("cid", StringComparison.InvariantCultureIgnoreCase))
                {
                    sig.Cid = uint.TryParse(kvp.Value, out var cid) ? cid : 0;
                }
            } while (true);

            return(sig);
        }