Esempio n. 1
0
        public ActionResult EngineResult()
        {
            DecisionType decType = new DecisionType();

            decType.Result       = false;
            decType.RandomString = Request.Form["TheWord"];
            decType.CheckBox     = new List <bool>();
            for (int h = 0; h < 132; h++)
            {
                decType.CheckBox.Add(Request.Form["RadioButtonYes" + h].ToString() == "Yes");
            }

            try
            {
                EnterpriseApiClient eapiClient = new EnterpriseApiClient("EnterpriseApi");
                eapiClient.Open();
                DecisionType decisionResult = eapiClient.GetDecision(decType);
                eapiClient.Close();
                ViewBag.RandomString = "Decision result.";
                ViewBag.Result       = decType.Result ? "Yes" : "No";
            }
            catch (Exception eek)
            {
                ViewBag.RandomString = eek.Message;
                ViewBag.Result       = "No";
            }

            ViewBag.Message = "Decision result.";
            return(this.View());
        }
Esempio n. 2
0
        public double GetDecisionValue(DecisionType Decision)
        {
            switch (Decision)
            {
            case DecisionType.AngreifenAmeise:
                return(ratingAngreifenAmeise);

            case DecisionType.AngreifenWanze:
                return(ratingAngreifenWanze);

            case DecisionType.Laufen:
                return(ratingLaufen);

            case DecisionType.SammelnObst:
                return(ratingSammelnObst);

            case DecisionType.SammelnZucker:
                return(ratingSammelnZucker);

            case DecisionType.Wegrennen:
                return(ratingWegrennen);

            default:
                return(0.5);
            }
        }
Esempio n. 3
0
        public Step Next(string name, DecisionType decisionMade)
        {
            var current  = Find(name);
            var nextStep = current.NextStepsAccordingToDecision[decisionMade];

            if (nextStep == null)
            {
                throw new NotImplementedException($"ten krok nie ma zdefiniowanej takiej decyzji: {name} - {decisionMade}");
            }
            var next = _steps.FirstOrDefault(x => x.CurrentStep == nextStep);

            if (next == null)
            {
                throw new NotImplementedException($"kolejny krok po {name} jest nieznany");
            }

            _ourProces.Add(next);

            if (next.CurrentStep == "Odrzucenie zamówienia" || next.CurrentStep == "Zamównienie zostało przetworzone pomyślnie")
            {
                using (var writer = File.CreateText("./ourProcess.json"))
                {
                    writer.Write(JsonConvert.SerializeObject(_ourProces));
                }
            }
            return(next);
        }
 public TrainingDecisionModel(DecisionType type, int[] inputs, List <int> options, int playerInd)
 {
     this.Type      = type;
     this.Inputs    = inputs;
     this.Options   = options;
     this.PlayerInd = playerInd;
 }
Esempio n. 5
0
 public static bool IsRaiseMove(this DecisionType decisionType)
 {
     return(decisionType == DecisionType.AllIn ||
            decisionType == DecisionType.Ante ||
            decisionType == DecisionType.Raise ||
            decisionType == DecisionType.Reraise);
 }
Esempio n. 6
0
 public SavedExchangeOrder(
     string orderId_,
     string sliceId_,
     decimal price_,
     decimal quantity_,
     decimal cumQty_,
     decimal leavesQty_,
     int status_,
     int type_,
     decimal sliceAvgPrice_,
     int decision_,
     int category_,
     string effectiveTime_,
     string expireTime_
     )
 {
     this.orderId       = orderId_;
     this.sliceId       = sliceId_;
     this.price         = price_;
     this.quantity      = quantity_;
     this.cumQty        = cumQty_;
     this.leavesQty     = leavesQty_;
     this.status        = (OrderStatus)status_;
     this.type          = (OrderType)type_;
     this.sliceAvgPrice = sliceAvgPrice_;
     this.decision      = (DecisionType)decision_;
     this.category      = (PlacementCategory)category_;
     this.effectiveTime = effectiveTime_;
     this.expireTime    = expireTime_;
 }
        private Decision GenerateDecisionFromHandGrade(HandValueGradeEnum handGrade, PreflopStatusSummary statusSummary)
        {
            DecisionType decisionType = TranslateBasedOnIsRaised(handGrade, statusSummary);
            int          chipsAdded   = _betSizeConsultant.GetBetSize(statusSummary, decisionType);

            return(new Decision(decisionType, chipsAdded));
        }
Esempio n. 8
0
 public Signal(DateTime date, DecisionType decisionType, double price, string comment = "")
 {
     Date         = date;
     DecisionType = decisionType;
     Price        = price;
     Comment      = comment;
 }
Esempio n. 9
0
 public static IDecisionTaker CreateDecisionTaker(DecisionType decisionType)
 {
     return(decisionType switch
     {
         DecisionType.Standard => new StandardDecisionTaker(),
         _ => throw new NotImplementedException()
     });
Esempio n. 10
0
        /// <summary>
        ///     Handles the menu and sub menu selection of the presidential decision until it is executed.
        /// </summary>
        private void HandlePresidentialDecision()
        {
            bool hasNotChosenDecisionOrExited = true;

            while (hasNotChosenDecisionOrExited)
            {
                DecisionType decisionType = userInterface.DisplayPresidentialDecisionMainDialog();

                if (decisionType == DecisionType.None)
                {
                    hasNotChosenDecisionOrExited = false;
                }
                else
                {
                    Decision[] decisions      = engine.GetDecisionsByType(decisionType);
                    int        optionSelected = userInterface.DisplayPresidentialDecisionSubDialog(decisions);

                    if (engine.DoesPresidentialOptionExistAndIsAvailable(decisionType, optionSelected))
                    {
                        Decision decision = engine.GetDecisionByTypeAndIndex(decisionType, optionSelected);

                        if (TryProcessSelectedDecision(decision))
                        {
                            hasNotChosenDecisionOrExited = false;
                        }
                    }
                }
            }
        }
Esempio n. 11
0
 private void CheckToDefend()
 {
     // if ally planet is under attack then we need to help to this planet
     if (TargetPlanet.UnitCountNearBasEnemies > 1)
     {
         Weight += 3;
         float unitCount = 0;
         // choosing planet to defend it
         foreach (var basSelf in AiPlayer.Planets)
         {
             if ((basSelf.Trans.position - TargetPlanet.Trans.position).sqrMagnitude < AiPlayer.DistanceToFar)
             {
                 unitCount += basSelf.Spawner.UnitCount;
                 BeginPlanets.Add(basSelf);
             }
         }
         // if unit count on ally planets is less than attackers count then we lose this planet
         if (unitCount < TargetPlanet.UnitCountNearBasEnemies)
         {
             Weight -= 3;
             BeginPlanets.Clear();
         }
         Type = DecisionType.Defense;
     }
 }
Esempio n. 12
0
 /// <summary>
 /// Used internally to add a record of the scheduling decision made.
 /// The list of decisions are used to compare with any future runs using the same seed,
 /// in order to check that the run is reproduced.
 /// </summary>
 /// <param name="decisionType">Either ContextSwitch, CreateNondetBool, or CreateNondetInteger</param>
 /// <param name="decisionValue">Either the selected Task ID, the boolean value, or the integer value generated</param>
 /// <param name="currentTask">The Task ID of the current Task when the decision was made</param>
 /// <param name="state">The <see cref="ProgramState"/> when the decision was made</param>
 private void PushTrace(DecisionType decisionType, int decisionValue, int currentTask, ProgramState state)
 {
     lock (this.testTrace)
     {
         var decision = new DecisionTrace(decisionType, decisionValue, currentTask, state.GetAllTasksTuple());
         // Console.WriteLine(decision.ToReadableString());
         this.testTrace.Add(decision);
     }
 }
Esempio n. 13
0
        public Decision(DecisionType DecisionType, string Option1, string Option2, bool FirstIsDefault)
        {
            option1        = Option1;
            option2        = Option2;
            firstIsDefault = FirstIsDefault;

            characterParts = new DotFuzzy.LinguisticVariable(DecisionType.ToString());
            characterParts.MembershipFunctionCollection.Add(new DotFuzzy.MembershipFunction(Option1, 0, 0, 50, 50));
            characterParts.MembershipFunctionCollection.Add(new DotFuzzy.MembershipFunction(Option2, 50, 50, 100, 100));
        }
Esempio n. 14
0
        public Decision PerformTurn(int flips)
        {
            var compChoice = GetDecisionNumber(out double _raiseAmount, flips);

            RaiseAmount = _raiseAmount;
            DecisionType compDecicisionType = (DecisionType)compChoice;

            PlayersDecision = compDecicisionType;
            return(new Decision(compDecicisionType));
        }
Esempio n. 15
0
    public NeuralDecisionNetwork GetChooserDecider(DecisionType type)
    {
        switch (type)
        {
        case DecisionType.SelectWhereToGo: return(_whereToGoDecider);

        case DecisionType.SelectUsedHumans: return(_getUsedHumansDecider);

        default: return(null);
        }
    }
Esempio n. 16
0
        public static ResponseType Evaluate(RequestType request)
        {
            PolicyCombAlg[XacmlPolicyCombAlg.FIRST_APPLICABLE] = new FirstApplicablePolicy();

            /// deserijalizacija xml dokumenta koji specificira autorizacionu politiku
            //XmlSerializer serializer = new XmlSerializer(typeof(PolicyType));
            //StreamReader reader = new StreamReader("rule1.main.xml");
            ////StreamReader reader = new StreamReader("TimeRange.checkTimeInRange.xml");
            //var value = serializer.Deserialize(reader);

            ///// kreiranje objekta koji predstavlja definisanu politiku
            //PolicyType policy = new PolicyType();
            //policy = value as PolicyType;

            NetTcpBinding binding = new NetTcpBinding();

            binding.CloseTimeout   = new TimeSpan(0, 10, 0);
            binding.OpenTimeout    = new TimeSpan(0, 10, 0);
            binding.ReceiveTimeout = new TimeSpan(0, 10, 0);
            binding.SendTimeout    = new TimeSpan(0, 10, 0);
            string address = "net.tcp://localhost:6000/PapService";

            if (policySet.Items == null)
            {
                using (PapProxy proxy = new PapProxy(binding, new EndpointAddress(new Uri(address))))
                {
                    policySet = proxy.Load();
                    Console.WriteLine("-------------------------------------");
                    Console.WriteLine("\nPolicy loaded...");
                }
            }
            List <PolicyType> policiesL = new List <PolicyType>();

            foreach (PolicyType policy in policySet.Items)
            {
                policiesL.Add(policy);
            }

            PolicyType[] policies = policiesL.ToArray();

            DecisionType decision = PolicyCombAlg[policySet.PolicyCombiningAlgId].Evaluate(policies, request);

            Console.WriteLine("\nAccess decision: {0}", decision.ToString());

            ResponseType XacmlResponse = new ResponseType();

            ResultType result = new ResultType();

            result.Decision         = decision;
            XacmlResponse.Result    = new ResultType[1];
            XacmlResponse.Result[0] = result;

            return(XacmlResponse);
        }
 public static string GetDecisionTypeString(DecisionType decisionType)
 {
     switch (decisionType)
     {
         case DecisionType.SingleAction:
             return "Features";
         case DecisionType.MultiActions:
             return "Action Dependent Features";
         default:
             return string.Empty;
     }
 }
Esempio n. 18
0
        private void ProcessDecision(string[] parts, Guid roundId)
        {
            //"Decision-Chris-Call",
            //  "Decision-David-Reraise-20",
            var          name         = parts[1];
            DecisionType decisionType = DecisionType.Undefined;
            int          chips        = 0;

            switch (parts[2])
            {
            case "Check":
                decisionType = DecisionType.Check;
                break;

            case "Call":
                decisionType = DecisionType.Call;
                break;

            case "Raise":
                decisionType = DecisionType.Raise;
                chips        = int.Parse(parts[3]);
                break;

            case "Reraise":
                decisionType = DecisionType.Reraise;
                chips        = int.Parse(parts[3]);
                break;

            case "Fold":
                decisionType = DecisionType.Fold;
                break;

            case "AllIn":
                decisionType = DecisionType.AllIn;
                chips        = int.Parse(parts[3]);
                break;

            case "AllInRaise":
                decisionType = DecisionType.AllInRaise;
                chips        = int.Parse(parts[3]);
                break;
            }

            var request = new NotifyDecisionRequest()
            {
                Decision   = new Decision(decisionType, chips),
                PlayerName = name,
                RoundId    = roundId
            };

            _rm.NotifyDecision(request);
        }
 public void Init(DecisionType type, List <TrainingDecisionModel> trainingModels, AINeuralPlayer2 player)
 {
     _trainingModels = new List <TrainingDecisionModel> ();
     foreach (var model in trainingModels)
     {
         if (model.Type == type && model.RewardPercent > 0.5f)
         {
             _trainingModels.Add(model);
         }
     }
     _trainingsDataSize.text = _trainingModels.Count.ToString();
     _decider        = player.GetChooserDecider(type);
     _trainingsCount = 0;
 }
Esempio n. 20
0
        private void PushProcess(DecisionType decision, Dictionary <Data, object> attachs)
        {
            if (messageId.HasValue)
            {
                ShitHelper.Model.BasicAck(messageId.Value, false);
            }
            var nextStep = new Process().Next(Process.MyStep, decision);

            ShitHelper.Publish(nextStep.CurrentStep, new ProcessMessage
            {
                Step        = nextStep.CurrentStep,
                Attachments = attachs
            });
        }
Esempio n. 21
0
        public static string GetDecisionTypeString(DecisionType decisionType)
        {
            switch (decisionType)
            {
            case DecisionType.SingleAction:
                return("Features");

            case DecisionType.MultiActions:
                return("Action Dependent Features");

            default:
                return(string.Empty);
            }
        }
Esempio n. 22
0
    private int GetDecisionInd(DecisionType type, Game game, PlayerModel player, NeuralNetwork decider, List <int> randoms, int points, Resource receivedRecource, WhereToGo whereToGo)
    {
        List <int> optionInds = GetOptionInds(type, game, _model, randoms, points, receivedRecource, whereToGo);

        int[]    inputs       = GetInputs(type, game, _model, receivedRecource, whereToGo);
        double[] inputsDouble = new double[inputs.Length];
        for (int i = 0; i < inputs.Length; i++)
        {
            inputsDouble [i] = inputs [i];
        }
        double[] outputs     = decider.Think(inputsDouble);
        int      decisionInd = GetDecisionFromOutputs(outputs, optionInds);

        return(decisionInd);
    }
Esempio n. 23
0
    public static List <int> GetOptionInds(DecisionType type, Game game, PlayerModel player, List <int> randoms, int points, Resource receivedRecource, WhereToGo whereToGo)
    {
        switch (type)
        {
        default:
        case DecisionType.SelectWhereToGo: return(GetWhereToGoOptionInds(game, player));

        case DecisionType.SelectUsedHumans: return(GetUsedHumansOptionInds(game, player, whereToGo));

        case DecisionType.SelectCharity: return(GetCharityOptionInds(game, player, randoms));

        case DecisionType.SelectInstruments: return(GetInstrumentsOptionInds(game, player, randoms, points, receivedRecource));

        case DecisionType.SelectLeaveHungry: return(GetHungryOptionInds(game, player));
        }
    }
Esempio n. 24
0
    public static int[] GetInputs(DecisionType type, Game game, PlayerModel player, Resource receivedRecource, WhereToGo whereToGo)
    {
        switch (type)
        {
        default:
        case DecisionType.SelectWhereToGo: return(GetWhereToGoInputs(game, player));

        case DecisionType.SelectUsedHumans: return(GetUsedHumansInputs(game, player, whereToGo));

        case DecisionType.SelectCharity: return(GetCharityInputs(game, player));

        case DecisionType.SelectInstruments: return(GetInstrumentsInputs(game, player, receivedRecource));

        case DecisionType.SelectLeaveHungry: return(GetHungryInputs(game, player));
        }
    }
Esempio n. 25
0
        /// <summary>
        ///     Retrieves a decisions with the specified type and index.
        /// </summary>
        /// <param name="decisionType">The type of decision.</param>
        /// <param name="optionSelected">The position of the decision within the group of decisions with the specified type.</param>
        /// <returns>The position that matches the specified type and at the specific position.</returns>
        public Decision GetDecisionByTypeAndIndex(DecisionType decisionType, int optionNumber)
        {
            if (optionNumber < 0)
            {
                throw new ArgumentException(nameof(optionNumber));
            }

            Decision[] decisions = GetDecisionsByType(decisionType);

            if (optionNumber > decisions.Length)
            {
                throw new ArgumentException(nameof(optionNumber));
            }

            return(decisions[optionNumber - 1]);
        }
Esempio n. 26
0
        /// <summary>
        ///     Determines if a presidential option exists and is available for selection.
        /// </summary>
        /// <param name="decisionType">The type of decision.</param>
        /// <param name="optionNumber">The option number within the type group of the decision.</param>
        /// <returns><c>true</c> if the presidential decision exists and is available for selection; otherwise, <c>false</c>.</returns>
        public bool DoesPresidentialOptionExistAndIsAvailable(DecisionType decisionType, int optionNumber)
        {
            Decision[] decisions = GetDecisionsByType(decisionType);

            if (optionNumber > decisions.Length)
            {
                return(false);
            }

            if (decisions[optionNumber - 1].HasBeenUsed)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 27
0
        public Dictionary <Map, int> Get(DecisionType thisType, List <List <Decision> > asT1 = null,
                                         List <List <Decision> > asT2 = null)
        {
            List <List <Decision> > temp1 = asT1 ?? _pickBanBatchT1;

            List <List <Decision> > temp2 = asT2 ?? _pickBanBatchT2;

            List <Map> mapPool = new List <Map>
            {
                Map.Vertigo,
                Map.Inferno,
                Map.Overpass,
                Map.Train,
                Map.Nuke,
                Map.Mirage,
                Map.Dust2
            };

            int counter = 0;
            Dictionary <Map, int> banned = new Dictionary <Map, int>();

            foreach (Map item in mapPool)
            {
                foreach (List <Decision> singlePickBan in temp1)
                {
                    if (singlePickBan
                        .FirstOrDefault(s => s.Map == item && s.Type == thisType && s.GoingFirst) != null)
                    {
                        counter++;
                    }
                }

                foreach (List <Decision> singlePickBan in temp2)
                {
                    if (singlePickBan
                        .FirstOrDefault(s => s.Map == item && s.Type == thisType && s.GoingFirst == false) != null)
                    {
                        counter++;
                    }
                }

                banned.Add(item, counter);
                counter = 0;
            }

            return(banned);
        }
Esempio n. 28
0
        /// <summary>
        /// Calculates accuracy of the PCA Classifier
        /// </summary>
        /// <param name="testingPath"> Location of the Testing Files</param>
        /// <param name="decision"> Whether ClossestNeighbor or KNN</param>
        /// <param name="measureType"> Wether Euclidean or Projection</param>
        /// <param name="numberNeighbs"> How many neighbors to take into account for KNN</param>
        /// <returns></returns>
        public double Accuracy(String testingPath, DecisionType decision, ClossenessMeasure measureType, int numberNeighbs)
        {
            List <ATTFace> testingFaces = DataUnit.GetTestingData(testingPath);
            double         accu         = 0;

            foreach (ATTFace testFace in testingFaces)
            {
                int            guessID   = 0;
                List <ATTFace> bestFaces = new List <ATTFace>();
                FindBestMatch(testFace.ImageVector, decision, measureType, ref bestFaces, ref guessID, neighborNumber: numberNeighbs);
                if (guessID == testFace.personID)
                {
                    accu += 1;
                }
            }
            return(accu / testingFaces.Count);
        }
Esempio n. 29
0
    public NeuralNetwork GetDecider(DecisionType type)
    {
        switch (type)
        {
        case DecisionType.SelectWhereToGo: return(_whereToGoDecider);

        case DecisionType.SelectUsedHumans: return(_getUsedHumansDecider);

        case DecisionType.SelectInstruments: return(_instrumentsDecider);

        case DecisionType.SelectCharity: return(_charityDecider);

        case DecisionType.SelectLeaveHungry: return(_hungryDecider);

        default: return(null);
        }
    }
Esempio n. 30
0
        public static StrategyDecisionType ConvertToStrategyDecision(DecisionType decision, Permits permits)
        {
            if (decision == DecisionType.STAND)
            {
                return StrategyDecisionType.STAND;
            }
            if (decision == DecisionType.HIT)
            {
                return StrategyDecisionType.HIT;
            }
            if (decision == DecisionType.DOUBLE_OR_HIT && !permits.Double)
            {
                return StrategyDecisionType.HIT;
            }
            if (decision == DecisionType.DOUBLE_OR_HIT && permits.Double)
            {
                return StrategyDecisionType.DOUBLE;
            }
            if (decision == DecisionType.DOUBLE_OR_STAND && !permits.Double)
            {
                return StrategyDecisionType.STAND;
            }
            if (decision == DecisionType.DOUBLE_OR_STAND && permits.Double)
            {
                return StrategyDecisionType.DOUBLE;
            }
            if (decision == DecisionType.SURRENDER_OR_HIT && !permits.Surrender)
            {
                return StrategyDecisionType.HIT;
            }
            if (decision == DecisionType.SURRENDER_OR_HIT && permits.Surrender)
            {
                return StrategyDecisionType.SURRENDER;
            }
            if (decision == DecisionType.SURRENDER_OR_STAND && !permits.Surrender)
            {
                return StrategyDecisionType.STAND;
            }
            if (decision == DecisionType.DOUBLE_OR_STAND && permits.Surrender)
            {
                return StrategyDecisionType.SURRENDER;
            }

            return StrategyDecisionType.NA;
        }
Esempio n. 31
0
        public Decision GetDecision(Player player, Player currentRaiser,
                                    ISet <DecisionType> candidateDecisionTypes, int chipsToCall)
        {
            DecisionType decisionType = GetDecisionTypeInput($"Please input the move made by {player.Name}: {string.Join("/", candidateDecisionTypes)}");

            if (decisionType == DecisionType.Raise || decisionType == DecisionType.Reraise)
            {
                int chipsToRaise = GetInputOfInt($"Please input the raise size by {player.Name}");
                return(new Decision(decisionType, chipsToRaise));
            }

            if (decisionType == DecisionType.Call)
            {
                return(new Decision(decisionType, chipsToCall));
            }

            return(new Decision(decisionType, 0));
        }
Esempio n. 32
0
 public Decision(
     DecisionType type,
     DecisionSubType decisionSubType,
     int cost,
     int monthlyCost,
     string groupPopularityChanges,
     string groupStrenghtChanges,
     string text)
 {
     Type                   = type;
     DecisionSubType        = decisionSubType;
     Cost                   = cost;
     MonthlyCost            = monthlyCost;
     GroupPopularityChanges = groupPopularityChanges;
     GroupStrengthChanges   = groupStrenghtChanges;
     Text                   = text;
     HasBeenUsed            = false;
 }
Esempio n. 33
0
        public PlayerDecisionResponse GetPlayerDecision(Player player, double minimumBet, DecisionType[] availableOptions)
        {
            PlayerDecisionResponse pd = new PlayerDecisionResponse();
            pd.Type = DecisionType.TimeOutAndFold;

            PlayerDecisionRequest pdr = new PlayerDecisionRequest();
            pdr.RequestId = Guid.NewGuid().ToString();
            pdr.MinimumBet = minimumBet;
            pdr.AvailableOptions = availableOptions;

            AddToOutgoingMessageQueue(GameMessageType.Client_ReceivePlayerDecisionRequest, pdr, player.ToList());

            int waitingFor = 0;
            while (waitingFor < Table.MAX_DECISION_TIME)
            {
                if (m_dicStorage.ContainsKey(pdr.RequestId))
                {
                    pd = (PlayerDecisionResponse)m_dicStorage[pdr.RequestId];
                    break;
                }

                //-- Perhaps the player has disconnected from the table
                if (Table.IsPlayerSittingAtTable(player.Name) == false)
                {
                    pd.Type = DecisionType.DisconnectAndFold;
                    break;
                }

                m_tcGameFlow.WaitHereFor(100);
                waitingFor += 100;
            }

            return pd;
        }