Exemplo n.º 1
0
            public void ScriptUpdateWait(SeparationMethodStage stageType, string waitForSymbolName, bool addCommand)
            {
                ITimeStep stage = m_EditMethod.Stages.GetFirstTimeStepOfStage(stageType, addCommand);

                if (!addCommand && stage == null)
                {
                    return;
                }

                string waitForSymbolPath = GetSymbolPath(m_Page, waitForSymbolName);

                ISymbolStep waitForSymbolStep = DDKHelper.FindStepInStage(CommandName.Wait, stage, new string[] { waitForSymbolPath });

                if (addCommand)
                {
                    if (waitForSymbolStep == null)
                    {
                        // System Wait always exist, therefore not checking for nulls
                        ICommand     command     = m_EditMethod.SymbolTable.Child(CommandName.Wait) as ICommand;
                        ICommandStep commandStep = m_Page.Component.CreateStep(command) as ICommandStep;
                        string       path        = m_DeviceSymbol.Child(waitForSymbolName).Path;
                        commandStep.Parameters[0].ValueExpression.Parse(path, ExpressionParseOptions.None);
                        stage.SymbolSteps.Add(commandStep);
                    }
                }
                else
                {
                    if (waitForSymbolStep != null)
                    {
                        waitForSymbolStep.Remove();
                    }
                }
            }
Exemplo n.º 2
0
        /// <summary>
        /// Create a hook with a certain time step and a set of required global registry entries.
        /// </summary>
        /// <param name="timestep">The time step.</param>
        /// <param name="desiredTargets">The targets for which the inputs should be optimised for.</param>
        /// <param name="desiredCost">The maximum factor of difference between approached targets and desired targets (squared difference).</param>
        /// <param name="sharedResultInputKey">The shared key under which the result input will be available.</param>
        /// <param name="sharedResultSuccessKey">The shared key under which the result success flag will be available.</param>
        public TargetMaximisationHook(ITimeStep timestep, INDArray desiredTargets, string sharedResultSuccessKey, string sharedResultInputKey, double desiredCost = 0.06)
            : base(timestep, "network.self", "optimiser.self")
        {
            if (desiredTargets == null)
            {
                throw new ArgumentNullException(nameof(desiredTargets));
            }
            if (sharedResultInputKey == null)
            {
                throw new ArgumentNullException(nameof(sharedResultInputKey));
            }
            if (sharedResultSuccessKey == null)
            {
                throw new ArgumentNullException(nameof(sharedResultSuccessKey));
            }

            ParameterRegistry["desired_targets"]           = desiredTargets;
            ParameterRegistry["desired_cost"]              = desiredCost;
            ParameterRegistry["max_optimisation_steps"]    = 1024;
            ParameterRegistry["max_optimisation_attempts"] = 2;
            ParameterRegistry["shared_result_input_key"]   = sharedResultInputKey;
            ParameterRegistry["shared_result_success_key"] = sharedResultSuccessKey;

            InvokePriority = 10000;
        }
Exemplo n.º 3
0
            public bool IsInScript(SeparationMethodStage stageType, string commandName, ICommand command = null)
            {
                if (command == null)
                {
                    if (string.IsNullOrEmpty(commandName))
                    {
                        throw new ArgumentNullException("At least one of the parameters commandName or command must be provided");
                    }
                }

                ITimeStep stage = m_EditMethod.Stages.GetFirstTimeStepOfStage(stageType, false);

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

                if (command == null)
                {
                    command = m_DeviceSymbol.Children[commandName] as ICommand;
                    if (command == null)
                    {
                        return(false);
                    }
                }

                ISymbolStep symbolStep = DDKHelper.FindStepInStage(command.Path, stage);

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

                return(true);
            }
Exemplo n.º 4
0
        /// <summary>
        /// Create a hook with a certain time step and a set of required global registry entries.
        /// </summary>
        /// <param name="timeStep">The time step.</param>
        /// <param name="averageSpan">The interval span to average over.</param>
        public RunningTimeReporter(ITimeStep timeStep, int averageSpan = 4) : base(timeStep)
        {
            DefaultTargetMode = TargetMode.Global;

            string baseResultKey = $"shared.time_{timeStep.TimeScale}";

            RequireHook(new RunningTimeProcessorHook(timeStep.TimeScale, averageSpan, baseResultKey));

            ParameterRegistry.Set("base_result_key", baseResultKey, typeof(string));
        }
        /// <summary>
        /// Enables the automatic polling of values (call Read on every TimeStep).
        /// <c>null</c> if no automatic polling should be enabled.
        /// </summary>
        /// <param name="trainer">The trainer on which the poll will be performed.</param>
        /// <param name="step">The TimeStep on when the parameter should update.</param>
        public virtual void AutoPollValues(ITrainer trainer, ITimeStep step)
        {
            if (ActiveHook != null)
            {
                trainer.Operator.DetachGlobalHook(ActiveHook);
            }

            ActiveHook = new PollParameterHook(step, this);

            trainer.AddGlobalHook(ActiveHook);
        }
        ///  <summary>
        ///		Create a BitmapPanel that can easily be updated by a hook. This hook will be automatically attached to a given trainer.
        ///		This panel is optimised for MNIST with one hot of 10 and a given number.
        ///  </summary>
        /// <param name="title">The given tile.</param>
        /// <param name="timestep">The timestep this panel updates.</param>
        /// <param name="trainer">The trainer the hook will be applied to.</param>
        /// <param name="headerContent">The content for the header. If <c>null</c> is passed, the title will be used.</param>
        /// <param name="number">The number this panel tries to visualise.</param>
        public MnistBitmapHookPanel(string title, int number, ITrainer trainer, ITimeStep timestep, object headerContent = null) : base(title, 28, 28, headerContent)
        {
            if (trainer == null)
            {
                throw new ArgumentNullException(nameof(trainer));
            }

            UseLoadingIndicator = true;
            VisualTargetMaximisationReporter hook = new VisualTargetMaximisationReporter(this, trainer.Operator.Handler.NDArray(ArrayUtils.OneHot(number, 10), 10L), timestep);

            trainer.AddGlobalHook(hook);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Create a hook with a certain time step and a set of required global registry entries.
        /// </summary>
        /// <param name="validationIteratorName">The name of the validation data iterator to use (as in the trainer).</param>
        /// <param name="timestep">The time step.</param>
        /// <param name="tops">The tops that will get reported.</param>
        public MultiClassificationAccuracyReporter(string validationIteratorName, ITimeStep timestep, params int[] tops) : base(timestep)
        {
            if (tops.Length == 0)
            {
                throw new ArgumentException("Value cannot be an empty collection.", nameof(tops));
            }

            ParameterRegistry["tops"] = tops;

            DefaultTargetMode = TargetMode.Global;
            InvokePriority    = -100;

            RequireHook(new MultiClassificationAccuracyScorer(validationIteratorName, "shared.classification_accuracy_top", timestep, tops));
        }
        private void SteamUGCRequest(ITimeStep t)
        {
            if (UseSteam && ++RequestCount <= 4)
            {
                Console.WriteLine("SteamUGCRequest : " + RequestCount);

                SteamAPICall_t UGCDetails = SteamUGC.RequestUGCDetails(new PublishedFileId_t(PublishedFileId), 0);
                SteamCall = new CallResult <SteamUGCRequestUGCDetailsResult_t>(Callback);
                SteamCall.Set(UGCDetails);
            }
            else
            {
                GameEvents.Twice_Second -= SteamUGCRequest;
            }
        }
Exemplo n.º 9
0
        private void SteamUGCRequest(ITimeStep t)
        {
            if (WorkshopID != 0 && ++RequestCount <= 5)
            {
                Console.WriteLine("SteamUGCRequest : " + RequestCount);

                SteamAPICall_t UGCDetails = SteamUGC.RequestUGCDetails(new PublishedFileId_t(WorkshopID), 0);
                SteamCall = new CallResult <SteamUGCRequestUGCDetailsResult_t>(Callback);
                SteamCall.Set(UGCDetails);
            }
            else
            {
                GameEvents.Twice_Second.UnregWithEvent(SteamUGCRequest);
            }
        }
Exemplo n.º 10
0
        ///  <summary>
        ///     Create a hook that fetches a given amount of values (i.e. registry identifiers) at a given <see cref="ITimeStep"/>.
        ///  </summary>
        ///  <param name="valueIdentifiers">The values that will be fetched (i.e. registry identifiers). E.g. <c>"optimiser.cost_total"</c>, ...</param>
        ///  <param name="timestep">The <see cref="ITimeStep"/> the hook will executed on.</param>
        /// <param name="reportEpochIteration">Indicate whether or not to report the current epoch and iteration in addition to the values.</param>
        public ValueReporter(string[] valueIdentifiers, ITimeStep timestep, bool averageValues = false, bool reportEpochIteration = false) : base(timestep, valueIdentifiers)
        {
            if (valueIdentifiers.Length == 0)
            {
                throw new ArgumentException("Value identifiers cannot be empty (it's the whole point of this hook).");
            }

            DefaultTargetMode = TargetMode.Local;

            Dictionary <string, object> valueBuffer = new Dictionary <string, object>(valueIdentifiers.Length);

            ParameterRegistry["value_identifiers"]      = valueIdentifiers;
            ParameterRegistry["value_buffer"]           = valueBuffer;
            ParameterRegistry["report_epoch_iteration"] = reportEpochIteration;
        }
Exemplo n.º 11
0
        public void SlowUpdate(ITimeStep dt)
        {
            foreach (MainConstruct current in StaticConstructablesManager.constructables.ToArray())
            {
                if (standardhp && (!HUDLog[current.GetTeam().Id][current.UniqueId].Disqual || !HUDLog[current.GetTeam().Id][current.UniqueId].Scrapping))
                {
                    HUDLog[current.GetTeam().Id][current.UniqueId].HPCUR = current.iMainStatus.GetNumberAliveBlocksIncludingSubConstructables();
                    HUDLog[current.GetTeam().Id][current.UniqueId].HP    = current.iMainStatus.GetFractionAliveBlocksIncludingSubConstructables() * 100;
                }
                else if (!standardhp && (!HUDLog[current.GetTeam().Id][current.UniqueId].Disqual || !HUDLog[current.GetTeam().Id][current.UniqueId].Scrapping))
                {
                    HUDLog[current.GetTeam().Id][current.UniqueId].HPCUR = current.iResourceCosts.CalculateResourceCostOfAliveBlocksIncludingSubConstructs_ForCashBack(true).Material;
                    HUDLog[current.GetTeam().Id][current.UniqueId].HP    = HUDLog[current.GetTeam().Id][current.UniqueId].HPCUR / HUDLog[current.GetTeam().Id][current.UniqueId].HPMAX * 100;
                }
                else
                {
                    HUDLog[current.GetTeam().Id][current.UniqueId].HPCUR = 0;
                    HUDLog[current.GetTeam().Id][current.UniqueId].HP    = 0;
                }
            }

            foreach (KeyValuePair <int, SortedDictionary <int, TournamentParticipant> > team in HUDLog)        //foreach team
            {
                foreach (KeyValuePair <int, TournamentParticipant> member in HUDLog[team.Key])                 //foreach member in team

                {
                    if ((!StaticConstructablesManager.constructables.Contains(StaticConstructablesManager.constructables.Find(c => c.GetTeam() == member.Value.TeamId && c.UniqueId == member.Key)) ||
                         HUDLog[team.Key][member.Key].Disqual) &&
                        !HUDLog[team.Key][member.Key].Scrapping)
                    {
                        HUDLog[team.Key][member.Key].HPCUR     = 0;
                        HUDLog[team.Key][member.Key].Scrapping = true;
                        var loc = StaticConstructablesManager.constructables.Find(c => c.GetTeam() == member.Value.TeamId && c.UniqueId == member.Key).iMain.CentreOfMass;
                        UnityEngine.Object.Instantiate(Resources.Load("Detonator-MushroomCloud") as GameObject, loc, Quaternion.identity);
                        StaticConstructablesManager.constructables.Find(c => c.GetTeam() == member.Value.TeamId && c.UniqueId == member.Key).DestroyCompletely();
                    }
                }
            }
            if (timerTotal > maxtime && overtime == false)
            {
                Time.timeScale = 0f;
                overtime       = true;
            }
        }
Exemplo n.º 12
0
        ///  <summary>
        ///     Create a hook that fetches a given amount of values (i.e. registry identifiers) at a given <see cref="ITimeStep"/>.
        ///  </summary>
        ///  <param name="valueIdentifiers">The values that will be fetched (i.e. registry identifiers). E.g. <c>"optimiser.cost_total"</c>, ...</param>
        ///  <param name="timestep">The <see cref="ITimeStep"/> the hook will executed on.</param>
        /// <param name="reportEpochIteration">Indicate whether or not to report the current epoch and iteration in addition to the values.</param>
        public AccumulatedValueReporter(string[] valueIdentifiers, ITimeStep timestep, bool averageValues = false, bool reportEpochIteration = false) : base(timestep, valueIdentifiers)
        {
            if (valueIdentifiers.Length == 0)
            {
                throw new ArgumentException("Value identifiers cannot be empty (it's the whole point of this hook).");
            }

            DefaultTargetMode = TargetMode.Local;

            string[] accumulatedIdentifiers         = new string[valueIdentifiers.Length];
            Dictionary <string, object> valueBuffer = new Dictionary <string, object>(valueIdentifiers.Length);

            for (int i = 0; i < valueIdentifiers.Length; i++)
            {
                string value = valueIdentifiers[i];

                accumulatedIdentifiers[i] = GetAccumulatedIdentifier(value);

                // TODO let caller decide if it's a number (double) / something else

                int resetEvery, resetInterval;

                if (timestep.TimeScale == TimeScale.Iteration)
                {
                    resetEvery    = timestep.Interval;
                    resetInterval = -1;
                }
                else
                {
                    resetEvery    = -1;
                    resetInterval = 0;
                }

                RequireHook(new NumberAccumulatorHook(value, accumulatedIdentifiers[i], Utils.TimeStep.Every(1, TimeScale.Iteration), averageValues, resetEvery, resetInterval));

                valueBuffer.Add(value, null);
            }

            ParameterRegistry["value_identifiers"]       = valueIdentifiers;
            ParameterRegistry["accumulated_identifiers"] = accumulatedIdentifiers;
            ParameterRegistry["value_buffer"]            = valueBuffer;
            ParameterRegistry["report_epoch_iteration"]  = reportEpochIteration;
        }
Exemplo n.º 13
0
        /// <summary>
        /// Create an AccuracyPanel with a given title. It displays given accuracies per epoch.
        /// If a title is not sufficient modify <see cref="SigmaPanel.Header" />.
        /// </summary>
        /// <param name="title">The given tile.</param>
        /// <param name="trainer"></param>
        /// <param name="headerContent">The content for the header. If <c>null</c> is passed,
        /// the title will be used.</param>
        /// <param name="tops"></param>
        public AccuracyPanel(string title, ITrainer trainer, ITimeStep timeStep, object headerContent = null, params int[] tops) : base(title, headerContent)
        {
            if (timeStep == null)
            {
                throw new ArgumentNullException(nameof(timeStep));
            }

            // skip the first since its automatically generated
            for (int i = 1; i < tops.Length; i++)
            {
                AddSeries(new LineSeries());
            }

            trainer.AddHook(new ChartValidationAccuracyReport(this, "validation", timeStep, tops));
            trainer.AddGlobalHook(new LambdaHook(TimeStep.Every(1, TimeScale.Stop), (registry, resolver) => Clear()));

            AxisY.MinValue = 0;
            AxisY.MaxValue = 100;
        }
Exemplo n.º 14
0
        /// <summary>
        /// Create a hook with a certain time step and a set of required global registry entries.
        /// </summary>
        /// <param name="timestep">The time step.</param>
        /// <param name="requiredRegistryEntries">The required global registry entries.</param>
        protected BaseHook(ITimeStep timestep, ISet <string> requiredRegistryEntries)
        {
            if (timestep == null)
            {
                throw new ArgumentNullException(nameof(timestep));
            }

            if (requiredRegistryEntries == null)
            {
                throw new ArgumentNullException(nameof(requiredRegistryEntries));
            }

            TimeStep                 = timestep;
            _requiredHooks           = new List <IHook>();
            _requiredRegistryEntries = new List <string>(requiredRegistryEntries.ToArray());

            RequiredRegistryEntries = new ReadOnlyCollection <string>(_requiredRegistryEntries);
            RequiredHooks           = new ReadOnlyCollection <IHook>(_requiredHooks);
            ParameterRegistry       = new Registry();
        }
Exemplo n.º 15
0
        public MetricProcessorHook(ITimeStep timestep, string registryEntryToProcess, Func <T, IComputationHandler, INumber> metricFunction, string metricSharedResultIdentifier) : base(timestep, registryEntryToProcess)
        {
            if (registryEntryToProcess == null)
            {
                throw new ArgumentNullException(nameof(registryEntryToProcess));
            }
            if (metricFunction == null)
            {
                throw new ArgumentNullException(nameof(metricFunction));
            }
            if (metricSharedResultIdentifier == null)
            {
                throw new ArgumentNullException(nameof(metricSharedResultIdentifier));
            }

            InvokePriority = -1000;
            ParameterRegistry["registry_entry_to_process"]       = registryEntryToProcess;
            ParameterRegistry["metric_function"]                 = metricFunction;
            ParameterRegistry["metric_shared_result_identifier"] = metricSharedResultIdentifier;
        }
Exemplo n.º 16
0
        /// <summary>Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.</summary>
        /// <returns>A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes <paramref name="obj" /> in the sort order. Zero This instance occurs in the same position in the sort order as <paramref name="obj" />. Greater than zero This instance follows <paramref name="obj" /> in the sort order. </returns>
        /// <param name="obj">An object to compare with this instance. </param>
        /// <exception cref="T:System.ArgumentException">
        /// <paramref name="obj" /> is not the same type as this instance. </exception>
        public int CompareTo(object obj)
        {
            ITimeStep otherTimeStep = obj as ITimeStep;

            if (otherTimeStep == null)
            {
                throw new ArgumentException($"Object to compare with must be of type {typeof(ITimeStep)} but was {obj.GetType()}.");
            }

            if (otherTimeStep.TimeScale == TimeScale)
            {
                return(Interval - otherTimeStep.Interval);
            }

            if (otherTimeStep.TimeScale == TimeScale.Indeterminate || TimeScale == TimeScale.Indeterminate)
            {
                throw new InvalidOperationException($"Cannot compare indeterminate with determinate time scale, attempted to compare this {TimeScale} with other {otherTimeStep.TimeScale}.");
            }

            return(TimeScale == TimeScale.Epoch && otherTimeStep.TimeScale == TimeScale.Iteration ? 1 : -1);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Create a savior hook that will automatically serialise a certain registry entry.
        /// </summary>
        /// <param name="timestep">The time step.</param>
        /// <param name="registryEntryToSave"></param>
        /// <param name="fileNamer">The file namer to store to disk as.</param>
        /// <param name="selectFunction">The select function to apply.</param>
        /// <param name="verbose">Indicate whether or not to report when the specified object was serialised.</param>
        public DiskSaviorHook(ITimeStep timestep, string registryEntryToSave, INamer fileNamer, Func <T, T> selectFunction, bool verbose = true) : base(timestep, registryEntryToSave)
        {
            if (registryEntryToSave == null)
            {
                throw new ArgumentNullException(nameof(registryEntryToSave));
            }
            if (fileNamer == null)
            {
                throw new ArgumentNullException(nameof(fileNamer));
            }
            if (selectFunction == null)
            {
                throw new ArgumentNullException(nameof(selectFunction));
            }

            ParameterRegistry["registry_entry_to_save"] = registryEntryToSave;
            ParameterRegistry["file_namer"]             = fileNamer;
            ParameterRegistry["select_function"]        = selectFunction;
            ParameterRegistry["verbose"] = verbose;

            DefaultTargetMode = TargetMode.Global;
        }
Exemplo n.º 18
0
            public void ScriptUpdate(SeparationMethodStage stageType, string commandName, bool addCommand)
            {
                ITimeStep stage = m_EditMethod.Stages.GetFirstTimeStepOfStage(stageType, true);

                ICommand    command     = m_DeviceSymbol.Children[commandName] as ICommand;
                ISymbolStep commandStep = DDKHelper.FindStepInStage(command.Path, stage);

                if (addCommand)
                {
                    if (commandStep == null)  // The command is not in the script
                    {
                        command     = m_DeviceSymbol.Child(commandName) as ICommand;
                        commandStep = m_Page.Component.CreateStep(command) as ICommandStep;
                        stage.SymbolSteps.Add(commandStep);
                    }
                }
                else // Remove Command
                {
                    if (commandStep != null)  // The command is in the script
                    {
                        commandStep.Remove();
                    }
                }
            }
        public void FixedStep(ITimeStep t)
        {
            if (!Running || (CompiledStartMethod == null && CompiledUpdateMethod == null))
            {
                return;
            }

            try
            {
                if (RunStartMethod)
                {
                    RunStartMethod = false;
                    CompiledStartMethod?.Invoke(null, new object[] { this });
                }

                CompiledUpdateMethod?.Invoke(null, new object[] { this });
            }
            catch (Exception e)
            {
                Running = false;
                Log("FixedStep method error catch");
                ErrorOutput(e);
            }
        }
Exemplo n.º 20
0
 /// <summary>
 /// Create a new <see ref="VisualValueReportHook"/> fully prepared to report values.
 /// </summary>
 /// <param name="chartPanel">The chartpanel to which points will get added.</param>
 /// <param name="valueIdentifiers">The identifiers for the <see cref="AccumulatedValueReporter"/>; these values will get plotted.</param>
 /// <param name="timestep">The <see cref="TimeStep"/> for the hook (i.e. execution definition).</param>
 public VisualAccumulatedValueReporterHook(ChartPanel <TChart, TSeries, TChartValues, TData> chartPanel, string[] valueIdentifiers, ITimeStep timestep, bool averageMode = false) : base(valueIdentifiers, timestep, averageMode, false)
 {
     ParameterRegistry[ChartPanelIdentifier] = chartPanel;
 }
Exemplo n.º 21
0
        public void FixedUpdate(ITimeStep dt)
        {
            if (Time.timeScale != 0)               //dont calc when paused....
            {
                if (matconv == -1)                 //no material fix
                {
                    if (t1_res < entry_t1[0].Team_id.FactionInst().ResourceStore.Material.Quantity)
                    {
                        entry_t1[0].Team_id.FactionInst().ResourceStore.SetResources(t1_res);
                    }
                    else
                    {
                        t1_res = (float)entry_t1[0].Team_id.FactionInst().ResourceStore.Material.Quantity;
                    }
                    if (t2_res < entry_t2[0].Team_id.FactionInst().ResourceStore.Material.Quantity)
                    {
                        entry_t2[0].Team_id.FactionInst().ResourceStore.SetResources(t2_res);
                    }
                    else
                    {
                        t2_res = (float)entry_t2[0].Team_id.FactionInst().ResourceStore.Material.Quantity;
                    }
                }

                foreach (MainConstruct current in StaticConstructablesManager.constructables.ToArray())                   //alive loop
                {
                    if (!HUDLog[current.GetTeam().Id][current.UniqueId].Disqual || !HUDLog[current.GetTeam().Id][current.UniqueId].Scrapping)
                    {
                        if (penaltyhp > 0 && HUDLog[current.GetTeam().Id][current.UniqueId].HP < penaltyhp && !srules)                           //dont check aicount or location oob if under hp%
                        {
                            HUDLog[current.GetTeam().Id][current.UniqueId].OoBTime += Time.timeSinceLevelLoad - timerTotal - timerTotal2;
                        }
                        else
                        {
                            HUDLog[current.GetTeam().Id][current.UniqueId].AICount = current.BlockTypeStorage.MainframeStore.Blocks.Count;
                            if (penaltynoai && HUDLog[current.GetTeam().Id][current.UniqueId].AICount == 0)                               //dont check location oob if aipenalty on and no ai
                            {
                                HUDLog[current.GetTeam().Id][current.UniqueId].OoBTime += Time.timeSinceLevelLoad - timerTotal - timerTotal2;
                            }
                            else
                            {
                                if (current.CentreOfMass.y < minalt || current.CentreOfMass.y > maxalt)                                   //check Out of Bounds vertically
                                {
                                    HUDLog[current.GetTeam().Id][current.UniqueId].OoBTime += Time.timeSinceLevelLoad - timerTotal - timerTotal2;
                                }
                                else                                     //check Out of Bounds horizontally
                                {
                                    float nearest         = -1;
                                    float nearestvelocity = -1;
                                    foreach (MainConstruct current2 in StaticConstructablesManager.constructables.ToArray())
                                    {
                                        if (current != current2 && current.GetTeam() != current2.GetTeam())                                           //find nearest enemy
                                        {
                                            float distance = Vector3.Distance(current.CentreOfMass, current2.CentreOfMass);
                                            if (nearest < 0)
                                            {
                                                nearest         = distance;
                                                nearestvelocity = Vector3.Distance(current.CentreOfMass + current.iPartPhysics.iVelocities.VelocityVector, current2.CentreOfMass);
                                            }
                                            else if (Vector3.Distance(current.CentreOfMass, current2.CentreOfMass) < nearest)
                                            {
                                                nearest         = distance;
                                                nearestvelocity = Vector3.Distance(current.CentreOfMass + current.iPartPhysics.iVelocities.VelocityVector, current2.CentreOfMass);
                                            }
                                        }
                                    }
                                    if (nearest > maxdis && nearest < nearestvelocity)                                       //if further than nearest and moving away
                                    {
                                        HUDLog[current.GetTeam().Id][current.UniqueId].OoBTime += Time.timeSinceLevelLoad - timerTotal - timerTotal2;
                                    }
                                }
                            }
                        }
                        HUDLog[current.GetTeam().Id][current.UniqueId].Disqual = HUDLog[current.GetTeam().Id][current.UniqueId].OoBTime > maxoob;
                    }
                }
                timerTotal += Time.timeSinceLevelLoad - timerTotal - timerTotal2;
            }
        }
Exemplo n.º 22
0
 public void UpdateBoardSectionPreview(ITimeStep dt)
 {
     //Vector3d currentBoard = getBoardOffset();
     //justOrbitCam.transform.position = currentBoard.ToSingle() + new Vector3(0, 50, 0);
     justOrbitCam.transform.Rotate(0, (float)(15 * dt.PhysicalDeltaTime.Seconds), 0);            //15° pro vergangene Sekunde
 }
Exemplo n.º 23
0
 /// <summary>
 /// Create a hook with a certain time step and a set of required global registry entries.
 /// </summary>
 /// <param name="timestep">The time step.</param>
 /// <param name="requiredRegistryEntries">The required global registry entries.</param>
 protected BaseHook(ITimeStep timestep, params string[] requiredRegistryEntries) : this(timestep, new HashSet <string>(requiredRegistryEntries))
 {
 }
Exemplo n.º 24
0
 /// <summary>
 /// Create a hook with a certain time step and a set of required global registry entries.
 /// </summary>
 /// <param name="timestep">The time step.</param>
 /// <param name="requiredRegistryEntries">The required global registry entries.</param>
 public TimeSeriesGeneratorHook(ITimeStep timestep) : base(timestep, "network.self")
 {
 }
Exemplo n.º 25
0
 /// <summary>
 /// Create a hook with a certain time step and a set of required global registry entries.
 /// </summary>
 /// <param name="validationIteratorName">The validation data iterator name (as in the trainer).</param>
 /// <param name="timestep">The time step.</param>
 /// <param name="threshold">The threshold above which predictions are treated as 1 and below as 0.</param>
 public UniClassificationAccuracyReporter(string validationIteratorName, double threshold, ITimeStep timestep) : this(validationIteratorName, threshold, threshold, timestep)
 {
 }
Exemplo n.º 26
0
 /// <summary>
 /// Create a hook with a certain time step
 /// </summary>
 /// <param name="timestep">The time step.</param>
 /// <param name="visualiser">The visualisers that will be updated.</param>
 public PollParameterHook(ITimeStep timestep, IParameterVisualiser visualiser) : base(timestep)
 {
     ParameterRegistry[VisualiserIdentifier] = visualiser;
 }
Exemplo n.º 27
0
        ///  <summary>
        ///  Create a TrainerChartPanel with a given title.
        ///  This <see ref="ChartPanel{T,TSeries,TData}"/> automatically receives data via a hook and adds it to the chart.
        ///  If a title is not sufficient modify <see cref="SigmaPanel.Header" />.
        ///  </summary>
        /// <param name="title">The given tile.</param>
        /// <param name="trainer">The trainer to attach the hook to.</param>
        /// <param name="hookedValues">The values that will get hooked (i.e. the value identifiers of <see cref="AccumulatedValueReporter"/>).</param>
        /// <param name="timestep">The <see cref="TimeStep"/> for the hook.</param>
        /// <param name="headerContent">The content for the header. If <c>null</c> is passed,
        /// the title will be used.</param>
        public TrainerChartPanel(string title, ITrainer trainer, ITimeStep timestep, bool averageMode = false, object headerContent = null, params string[] hookedValues) : base(title, headerContent)
        {
            VisualAccumulatedValueReporterHook hook = new VisualAccumulatedValueReporterHook(this, hookedValues, timestep, averageMode);

            Init(trainer, hook);
        }
Exemplo n.º 28
0
        /// <summary>
        /// Create a hook with a certain time step and a set of required global registry entries.
        /// </summary>
        /// <param name="validationIteratorName">The validation data iterator name (as in the trainer).</param>
        /// <param name="timestep">The time step.</param>
        /// <param name="lowerThreshold">The lower threshold, below which predictions are treated as 0.</param>
        /// <param name="upperThreshold">The upper threshold, above which predictions are treated as 1.</param>
        public UniClassificationAccuracyReporter(string validationIteratorName, double lowerThreshold, double upperThreshold, ITimeStep timestep) : base(timestep)
        {
            DefaultTargetMode = TargetMode.Global;
            InvokePriority    = -100;

            RequireHook(new UniClassificationAccuracyScorer(validationIteratorName, "shared.classification_accuracy", lowerThreshold, upperThreshold, timestep));
        }
Exemplo n.º 29
0
 /// <summary>
 /// Create a validation scorer hook for a certain validation iterator.
 /// Note:	The "external_default" output may not always be the actual final output in your model.
 ///			If your model contains multiple output you may need to explicitly specify the actual final output with this alias.
 /// </summary>
 /// <param name="validationIteratorName">The validation data iterator name (as in the trainer).</param>
 /// <param name="timestep">The time step.</param>
 protected BaseAccuracyScorer(string validationIteratorName, ITimeStep timestep) : this(validationIteratorName, "external_default", timestep)
 {
 }
Exemplo n.º 30
0
        /// <summary>
        /// Create a validation scorer hook for a certain validation iterator.
        /// </summary>
        /// <param name="validationIteratorName">The validation data iterator name (as in the trainer).</param>
        /// <param name="finalExternalOutputAlias">The final external output alias (where the actual output is).</param>
        /// <param name="timestep">The time step.</param>
        protected BaseAccuracyScorer(string validationIteratorName, string finalExternalOutputAlias, ITimeStep timestep) : base(timestep, "network.self", "trainer.self")
        {
            if (validationIteratorName == null)
            {
                throw new ArgumentNullException(nameof(validationIteratorName));
            }
            if (finalExternalOutputAlias == null)
            {
                throw new ArgumentNullException(nameof(finalExternalOutputAlias));
            }

            DefaultTargetMode = TargetMode.Global;

            ParameterRegistry["validation_iterator_name"]    = validationIteratorName;
            ParameterRegistry["final_external_output_alias"] = finalExternalOutputAlias;
            ParameterRegistry["output_activations_alias"]    = "activations";
            ParameterRegistry["targets_alias"] = "targets";
        }