Ejemplo n.º 1
0
 public override void tick(InputSet input)
 {
     input.debug();
     buttons[0].setActive(input.left);
     buttons[1].setActive(input.middle);
     buttons[2].setActive(input.right);
 }
Ejemplo n.º 2
0
 public NewAnarchyInput(int inputId, InputSet inputSet, User user)
 {
     ButtonSet       = inputSet.Inputs.Select(i => i.ButtonName).ToImmutableList();
     ButtonSetLabels = inputSet.Inputs.Select(i => i.DisplayedText).ToImmutableList();
     User            = user;
     InputId         = inputId;
 }
Ejemplo n.º 3
0
        public KnapsackSolver()
        {
            inputSet_f1 = InputParser.ParseInputFile("LowDimensional\\f1_4_11");
            //inputSet_f2 = InputParser.ParseInputFile("LowDimensional\\f2_4_20");

            inputSet = inputSet_f1;
        }
Ejemplo n.º 4
0
        public int Solve(InputSet inputSet)
        {
            int numItems = inputSet.Items.Count;

            capacity = inputSet.Capacity;
            items    = inputSet.Items;

            matrix = new int[numItems + 1, capacity + 1];
            int leaveItem;
            int takeItem;

            for (int i = 1; i <= numItems; i++)
            {
                for (int j = 1; j <= capacity; j++)
                {
                    if (items[i - 1].Weight <= j)
                    {
                        leaveItem = matrix[i - 1, j];
                        takeItem  = items[i - 1].Value + matrix[i - 1, j - items[i - 1].Weight];

                        matrix[i, j] = Math.Max(leaveItem, takeItem);
                    }
                    else
                    {
                        matrix[i, j] = matrix[i - 1, j];
                    }
                }
            }
            return(matrix[numItems, capacity]);
        }
Ejemplo n.º 5
0
        public static void LearnFromCellCapture()
        {
            string CellCapture = CaptureArea4x4();

            Random MutationRand = new Random();

            // Have probability of 'mutating'. Probability is dependant on Highest fitness achieved for cell, out of maximum possible fitness from sets.



            if (!(KnownCells.ContainsKey(CellCapture)))
            {
                if (RecordingInputs == false)
                {
                    RecordStartFrame = GameVars.CurrentFrame;

                    RecordingInputs = true;
                }
                if (RecordCounter <= 5)
                {
                    RecordCounter += 1;

                    CurrentInputRecord.Add(Player.NextDirection);

                    RecordFitness = (Player.RightMost_X - ((GameVars.CurrentFrame - RecordStartFrame) / RecordCounter) + 100); // Fitness is calculate as: ((Rightmost Horizontal distance - (The number of frames taken / 2)) + 100);
                }
                else
                {
                    if (RecordFitness > RecordMaxFitness)
                    {
                        RecordFitness = RecordMaxFitness;

                        InputSet InputsAndHighFit = new InputSet();

                        InputsAndHighFit.Inputs = CurrentInputRecord;

                        InputsAndHighFit.MaxFitness = RecordMaxFitness;

                        KnownCells.Add(CurrentCellCapture, InputsAndHighFit);
                    }

                    RecordingInputs = false;

                    RecordCounter = 0;

                    CurrentInputRecord.Clear();

                    RecordFitness = 0;

                    RecordStartFrame = 0;

                    RecordMaxFitness = 0;

                    CurrentCellCapture = "";
                }

                //KnownCells.Add(CellCapture,);
            }
            ;
        }
Ejemplo n.º 6
0
 protected override void Update(InputSet input)
 {
     if ((Length - Remaining) > DelayTime)
     {
         Astronaut.Move(delayedInput.Dequeue());
     }
 }
Ejemplo n.º 7
0
        public int Solve(InputSet inputSet)
        {
            List <Item> items    = inputSet.Items;
            int         capacity = inputSet.Capacity;

            items = items.OrderByDescending(o => o.Value).ToList();

            int value           = 0;
            int currentCapacity = capacity;

            for (int i = 0; i < items.Count; i++)
            {
                if (items[i].Weight <= currentCapacity)
                {
                    value           += items[i].Value;
                    currentCapacity -= items[i].Weight;

                    if (currentCapacity <= 0)
                    {
                        break;
                    }
                }
            }
            return(value);
        }
Ejemplo n.º 8
0
 private ParameterSet ParameterSet(InputSet inputSet)
 {
     ParameterSetManager Manager = Scenario.PluginDataModels.OfType<ParameterSetManager>().FirstOrDefault();
     if (Manager == null)
         return null;
     return Manager.ParameterSets.First(x => x.InputSet == inputSet).Parameters;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Check if Stack() will return a solution for the current permutation
        /// </summary>
        /// <param name="value"></param>
        private static void CheckPermutation(int[] value)
        {
            var newPerm = new char[value.Length];

            for (int i = 0; i < value.Length; i++)
            {
                newPerm.SetValue(InputSet.GetValue(value[i] - 1), i);
            }
            var stacks = Stack(newPerm, numBoxes);

            if (CheckSums(stacks))
            {
                Console.WriteLine("Found a solution!");
                foundSolution = true;
                foreach (var c in stacks)
                {
                    foreach (var v in c)
                    {
                        Console.Write(v);
                    }
                    Console.WriteLine();
                }
                ;
            }
            PermutationCount++;
        }
Ejemplo n.º 10
0
        public int Solve(InputSet inputSet)
        {
            int numItems = inputSet.Items.Count;
            int capacity = inputSet.Capacity;

            matrix = new int[numItems + 1, capacity + 1];
            items  = inputSet.Items;

            for (int i = 0; i <= numItems; i++)
            {
                for (int j = 0; j <= capacity; j++)
                {
                    matrix[i, j] = 0;
                }
            }

            for (int i = 1; i <= numItems; i++)
            {
                for (int j = 1; j <= capacity; j++)
                {
                    matrix[i, j] = -1;
                }
            }
            return(MemFunc(numItems, capacity));
        }
Ejemplo n.º 11
0
    static void UpdateStretch(InputSet input, Limb limb)
    {
        var keyDown = input.GetStretch(limb);
        var stretch = StretchSpeed * Time.deltaTime;

        RemoveOxygen(Astronaut.Stretch(limb, keyDown? stretch : -stretch));
    }
Ejemplo n.º 12
0
        public static string FindDataSource(RiverSystemScenario scenario, object target, string element,
                                            string inputSet = null)
        {
            var ri = GetReflectedItem(target, element);

            Network  theNetwork  = scenario.Network;
            InputSet theInputSet = null;

            if (inputSet != null)
            {
                IList <InputSet> inputSets = theNetwork.InputSets;
                theInputSet = inputSets.FirstOrDefault(i => i.Name == inputSet);
            }

            if (theInputSet == null)
            {
                theInputSet = theNetwork.DefaultInputSet;
            }


            DataManager dm = theNetwork.DataManager;

            foreach (var name in dm.DataGroups.Select(g => g.GetFullPath(ri, theInputSet)).Where(name => !String.IsNullOrEmpty(name)))
            {
                return(name);
            }
            return("");
        }
Ejemplo n.º 13
0
        public void TestSameOutcomeInputSet()
        {
            var inputRefA = new Input("Foo", "a", "foo");
            var inputRefB = new Input("Bar", "b", "bar");
            var input1A   = new Input("Baz", "b", "baz");
            var input1B   = new Input("Quz", "a", "quz");
            var input2    = new Input("Foo", "a", "foo");
            var input4A   = new Input("Foo", "a", "foo");
            var input4B   = new Input("Bar", "a", "bar");

            var setRef = new InputSet(new List <Input> {
                inputRefA, inputRefB
            });
            var setDifferentOrder = new InputSet(new List <Input> {
                input1A, input1B
            });
            var setDifferentLength = new InputSet(new List <Input> {
                input2
            });
            var setDifferentEffectiveInput = new InputSet(new List <Input> {
                input4A, input4B
            });

            Assert.AreNotEqual(setRef, setDifferentOrder);
            Assert.IsTrue(setRef.HasSameOutcomeAs(setDifferentOrder));
            Assert.IsFalse(setRef.HasSameOutcomeAs(setDifferentLength));
            Assert.IsFalse(setRef.HasSameOutcomeAs(setDifferentEffectiveInput));
        }
Ejemplo n.º 14
0
        public override void VisitNativeAnalyzer(NativeAnalyzerPoint p)
        {
            string functionName = p.OwningPPGraph.FunctionName;

            if (nativeSanitizers.Contains(p.OwningPPGraph.FunctionName))
            {
                FunctionResolverBase.SetReturn(OutputSet, new MemoryEntry(Output.CreateInfo(false)));
                return;
            }

            // If a native function is not sanitizer, propagates taint status from arguments to return value

            // 1. Get values of arguments of the function
            // TODO: code duplication: the following code, code in SimpleFunctionResolver, and NativeFunctionAnalyzer. Move the code to some API (? FlowInputSet)
            Input.SetMode(SnapshotMode.MemoryLevel);
            MemoryEntry argc = InputSet.ReadVariable(new VariableIdentifier(".argument_count")).ReadMemory(Input);

            Input.SetMode(SnapshotMode.InfoLevel);
            int argumentCount                 = ((IntegerValue)argc.PossibleValues.ElementAt(0)).Value;
            List <MemoryEntry> arguments      = new List <MemoryEntry>();
            List <Value>       argumentValues = new List <Value>();

            for (int i = 0; i < argumentCount; i++)
            {
                arguments.Add(OutputSet.ReadVariable(Argument(i)).ReadMemory(OutputSet.Snapshot));
                argumentValues.AddRange(arguments.Last().PossibleValues);
            }

            // 2. Propagate arguments to the return value.
            FunctionResolverBase.SetReturn(OutputSet, new MemoryEntry(Output.CreateInfo(mergeTaint(argumentValues))));
        }
Ejemplo n.º 15
0
        public void Create(InputSetSummary summary)
        {
            var set = new InputSet(summary.Name);

            Scenario.Network.InputSets.Add(set);
            UpdateInstructions(set, summary.Configuration);
        }
Ejemplo n.º 16
0
 void AddAllKeyboards()
 {
     for (int i = 0; i < maxKeyboardsInpus; ++i)
     {
         inputs[i] = new InputSet("Keyboard " + (i + 1));
     }
 }
Ejemplo n.º 17
0
 public void Run(InputSet inputSet)
 {
     ParameterSet parameterSet = ParameterSet(inputSet);
     if (parameterSet == null)
         return;
     parameterSet.Reset(new Scenario(Scenario));
 }
Ejemplo n.º 18
0
 public void UpdateInstructions(InputSet inputSet, string[] newInstructions)
 {
     ParameterSet parameterSet = ParameterSet(inputSet);
     if (parameterSet == null)
         return;
     parameterSet.Configuration.Instructions = String.Join(Environment.NewLine, newInstructions);
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Constructor of the class
 /// </summary>
 /// <param name="name">name of the state</param>
 /// <param name="sceneName">Scene name of the state</param>
 public State(string name, string sceneName)
 {
     m_stateName = name;
     m_sceneState = new SceneInfo(sceneName);
     m_inputSet = null;
     m_isActive = false;
 }
Ejemplo n.º 20
0
        public async Task Enqueue(InputSet inputSet, User user)
        {
            QueuedInput queuedInput = new(_inputIdSeq++, inputSet);
            await _overlayConnection.Send(new NewAnarchyInput(queuedInput.InputId, queuedInput.InputSet, user),
                                          CancellationToken.None);

            _inputBufferQueue.Enqueue(queuedInput);
        }
Ejemplo n.º 21
0
 // Use this for initialization
 void Start()
 {
     body = GetComponent<Rigidbody2D>();
     anim = GetComponent<Animator>();
     var meta = GetComponent<PlayerMeta>();
     inputSet = new InputSet(meta.playerID);
     currentCooldownValue = 0;
 }
Ejemplo n.º 22
0
 void AddAllControllers()
 {
     for (int i = 0; i < maxController; ++i)
     {
         string controllerName = "Joystick " + (i + 1);
         inputs[i + maxKeyboardsInpus] = new InputSet(controllerName, isController: true);
     }
 }
Ejemplo n.º 23
0
        public void UpdateInputSet(string inputSetName, InputSetSummary summary)
        {
            Log("Updating Input Set Commands for " + inputSetName);
            var      sets = new InputSets(Scenario);
            InputSet set  = sets.Find(inputSetName);

            sets.UpdateInstructions(set, summary.Configuration);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Visits a native analyzer program point. If function is a sanitizer, the output is sanitized,
        /// if it is a reporting function, a warning is created.
        /// </summary>
        /// <param name="p">program point to visit</param>
        public override void VisitNativeAnalyzer(NativeAnalyzerPoint p)
        {
            _currentPoint = p;
            string functionName = p.OwningPPGraph.FunctionName;

            // 1. Get values of arguments of the function
            // TODO: code duplication: the following code, code in SimpleFunctionResolver, and NativeFunctionAnalyzer. Move the code to some API (? FlowInputSet)
            Input.SetMode(SnapshotMode.MemoryLevel);
            MemoryEntry argc = InputSet.ReadVariable(new VariableIdentifier(".argument_count")).ReadMemory(Input);

            Input.SetMode(SnapshotMode.InfoLevel);
            int argumentCount = ((IntegerValue)argc.PossibleValues.ElementAt(0)).Value;

            List <MemoryEntry> arguments = new List <MemoryEntry>();
            List <ValueInfo>   values    = new List <ValueInfo>();
            bool nullValue = false;

            for (int i = 0; i < argumentCount; i++)
            {
                arguments.Add(OutputSet.ReadVariable(Argument(i)).ReadMemory(OutputSet.Snapshot));
                List <Value> argumentValues = new List <Value>(arguments.Last().PossibleValues);
                if (hasPossibleNullValue(OutputSet.ReadVariable(Argument(i))))
                {
                    nullValue = true;
                }
                VariableIdentifier varID = null;
                Value toRemove           = null;
                foreach (Value val in argumentValues)
                {
                    if (val is InfoValue <VariableIdentifier> )
                    {
                        varID    = (val as InfoValue <VariableIdentifier>).Data;
                        toRemove = val;
                    }
                }
                if (toRemove != null)
                {
                    argumentValues.Remove(toRemove);
                }
                values.Add(new ValueInfo(argumentValues, varID));
            }

            TaintInfo outputTaint = mergeTaint(values, nullValue);

            // try to sanitize the taint info
            if (outputTaint != null)
            {
                sanitize(p, ref outputTaint);
                warningsReportingFunct(p, outputTaint);
            }

            // 2. Propagate arguments to the return value.
            // TODO: quick fix
            if (outputTaint.tainted || outputTaint.nullValue)
            {
                FunctionResolverBase.SetReturn(OutputSet, new MemoryEntry(Output.CreateInfo(outputTaint)));
            }
        }
Ejemplo n.º 25
0
    void Awake()
    {
        inputs = new InputSet(false, false, false);
        cannonReloadTimeMax = cannonReloadTime;
        cannonReloadTime    = 0.0f;

        cannonAngle = cannon.transform.localRotation.z;
        makeTarget();
    }
Ejemplo n.º 26
0
 private void OutputPermutation(int[] value)
 {
     foreach (int i in value)
     {
         Console.Write(InputSet.GetValue(i - 1));
     }
     Console.WriteLine();
     PermutationCount++;
 }
Ejemplo n.º 27
0
    void Update()
    {
        bool     left   = Input.GetKey(KeyCode.A);
        bool     middle = Input.GetKey(KeyCode.S);
        bool     right  = Input.GetKey(KeyCode.D);
        InputSet input  = new InputSet(left, middle, right);

        game.tick(input);
    }
Ejemplo n.º 28
0
        public string[] Instructions(InputSet inputSet)
        {
            ParameterSet parameterSet = ParameterSet(inputSet);
            if (parameterSet == null)
                return new string[0];

            IEnumerable<string> result = parameterSet.Configuration.GetInstructions(null);
            return result.ToArray();
        }
Ejemplo n.º 29
0
 public static void Move(InputSet input)
 {
     UpdateGrip(input, Limb.LeftArm);
     UpdateGrip(input, Limb.RightArm);
     UpdateStretch(input, Limb.LeftArm);
     UpdateStretch(input, Limb.LeftLeg);
     UpdateStretch(input, Limb.RightArm);
     UpdateStretch(input, Limb.RightLeg);
 }
Ejemplo n.º 30
0
 void ReturnPressed(InputSet inputSet)
 {
     if (dummiesToInputsDictionary.ContainsKey(inputSet) && dummiesToInputsDictionary[inputSet].activeSelf)
     {
         dummiesToInputsDictionary[inputSet].GetComponent <PlayerSelectionDummy>().Reset();
         inputSet.Clear();
         inputSet.isActive = false;
         dummiesToInputsDictionary.Remove(inputSet);
     }
 }
Ejemplo n.º 31
0
 public bool CheckAndUpdate(InputSet input)
 {
     remaining -= Time.deltaTime;
     if (remaining < 0)
     {
         return(false);
     }
     Update(input);
     return(true);
 }
Ejemplo n.º 32
0
    public void RemovePlayer(GameObject player)
    {
        InputSet inputSet = player.GetComponent <CharController>().GetInputs();

        player.GetComponent <Character>().UI.RemovePlayer();
        inputSet.Clear();
        players.Remove(player);
        Destroy(player);
        AddSelectionDummy(inputSet);
    }
Ejemplo n.º 33
0
    void Awake()
    {
        inputs = new InputSet(false, false, false);

        // make the business
        makeFallingBusiness();
        makeFallingBusiness();
        makeFallingBusiness();
        makeStillBusiness();
    }
Ejemplo n.º 34
0
        public HttpResponseMessage Put(InputSet value)
        {
            var result = Validator.Validate(value);

            if (result.IsValid)
            {
                var resultSet = new Calculator().ResultSets(value);
                return(Request.CreateResponse(HttpStatusCode.OK, resultSet));
            }
            return(Request.CreateResponse(HttpStatusCode.BadRequest, result.Errors));
        }
Ejemplo n.º 35
0
        /// <summary>
        /// Process response text.
        /// </summary>
        /// <param name="input">The input set passed into the <see cref="IConversationSystem"/>.</param>
        /// <param name="output">The output set being returned from the <see cref="IConversationSystem"/>.</param>
        public void Process(InputSet input, OutputSet output)
        {
            var parameters = new PatternProcessingParameters(output.Response)
            {
                CapitalizationScheme = CapitalizationScheme.BY_SENTENCE,
                Variables            = input.Variables,
                Context = input.Variables.Keys.ToArray()
            };

            output.Response = _nameParser.Process(parameters);
        }
Ejemplo n.º 36
0
        public void ShouldReturnBadRequestWhenMonthlySavingIsNotProvided()
        {
            var inputSet = new InputSet();

            inputSet.Principle      = 10000;
            inputSet.TermLength     = 60;
            inputSet.InterestRate   = 0;
            inputSet.InstrumentType = InstrumentType.RecurringDeposit;
            inputSet.PayoutType     = PayoutType.Cumulative;
            Assert.AreEqual(HttpStatusCode.BadRequest, _controller.Put(inputSet).StatusCode);
        }
Ejemplo n.º 37
0
 public static string GetFullPath(this DataGroupItem dgi, ReflectedItem ri,InputSet inputSet)
 {
     var gdd = dgi.DataDetails.FirstOrDefault(dd => dd.Usages.Any(u => u.ReflectedItem.Equals(ri)));
     return gdd == null ? "" : SimpleDataGroupItem.MakeID(dgi) + "/" + inputSet.Name + "/" + SourceService.URLSafeString(gdd.Name);
 }