Exemplo n.º 1
0
        public static void InitParameters(
            decimal _numSkaters,
            string _moveDirections,
            decimal _collisionRadius,
            decimal _moveSpeed,
            decimal _successReward,
            decimal _failReward,
            bool _modifyReward,
            bool _learningRateDecreasing,
            decimal _learningRate,
            bool _epsilonDecreasing,
            decimal _epsilonForGreedy,
            decimal _dotSize,
            string _selectedPalette,
            decimal _fadeSpeed)
        {
            // Interface Parameters
            // Regarding functionality
            NumSkaters        = (int)_numSkaters;
            NumMoveDirections = Int32.Parse(_moveDirections);
            CollisionRadius   = (double)_collisionRadius / 100;
            MovementSpeed     = (double)_moveSpeed;
            // Learning Parameters
            SuccesReward           = (double)_successReward;
            FailReward             = (double)_failReward;
            ModifiedRewards        = _modifyReward;
            LearningRateDecreasing = _learningRateDecreasing;
            LearningRate           = (double)_learningRate;
            EpsilonDecreasing      = _epsilonDecreasing;
            Epsilon = (double)_epsilonForGreedy;
            // Aesthetics
            DotSize            = (int)_dotSize;
            SelectedPalette    = (Palette)Enum.Parse(typeof(Palette), _selectedPalette);
            CollisionFadeSpeed = (int)_fadeSpeed;

            // Internal / code
            GeneratePalette();

            DirectionList.Clear();
            for (int i = 0; i < NumMoveDirections; i++)
            {
                // Convert to Radian
                DirectionList.Add((i * 360.0f / NumMoveDirections) * (Math.PI / 180));
            }

            SessionStartTime = DateTime.Now.ToString("yyyyMMddhhmmss");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Opens a profile.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonOpenProfile_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                var dialog = new OpenFileDialog();
                dialog.InitialDirectory = App.Settings.AvalonSettings.SaveDirectory;
                dialog.Filter           = "JSON files (*.json)|*.json|Text Files (*.txt)|*.txt|All files (*.*)|*.*";

                if (dialog.ShowDialog() == true)
                {
                    // Load the settings for the file that was selected.
                    App.Settings.LoadSettings(dialog.FileName);

                    // Inject the Conveyor into the Triggers.
                    foreach (var trigger in App.Settings.ProfileSettings.TriggerList)
                    {
                        trigger.Conveyor = Conveyor;
                    }

                    // Important!  This is a new profile, we have to reload ALL of the DataList controls
                    // and reset their bindings.
                    AliasList.Reload();
                    DirectionList.Reload();
                    MacroList.Reload();
                    TriggersList.Reload();
                    VariableList.Reload();

                    // Show the user that the profile was successfully loaded.
                    Interp.EchoText("");
                    Interp.EchoText($"--> Loaded {dialog.FileName}.\r\n", AnsiColors.Cyan);

                    // Auto connect if it's setup to do so (this will disconnect from the previous server if it
                    // was connected.
                    if (App.Settings.ProfileSettings.AutoLogin)
                    {
                        Disconnect();
                        Connect();
                    }
                }
            }
            catch (Exception ex)
            {
                Interp.EchoText("");
                Interp.EchoText($"--> An error occured: {ex.Message}.\r\n", AnsiColors.Red);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Button event to create a package.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ButtonCreate_Click(object sender, RoutedEventArgs e)
        {
            int count = AliasList.SelectedCount() + TriggerList.SelectedCount() + DirectionList.SelectedCount();

            if (count == 0)
            {
                var msgbox = new MessageBoxDialog()
                {
                    Title   = "Info",
                    Content = "No items were selected to create a package from.",
                };

                await msgbox.ShowAsync();

                return;
            }

            var package = new Package
            {
                GameAddress = App.Settings.ProfileSettings.IpAddress
            };

            foreach (object obj in AliasList.DataList.SelectedItems)
            {
                // Make sure the item is an Alias.  The last item in the list which is a new record is sometimes
                // an different object type.
                if (obj is Alias item)
                {
                    var alias = (Alias)item.Clone();
                    alias.Count     = 0;
                    alias.Character = "";
                    package.AliasList.Add(alias);
                }
            }

            foreach (object obj in TriggerList.DataList.SelectedItems)
            {
                // Make sure the item is an Alias.  The last item in the list which is a new record is sometimes
                // an different object type.
                if (obj is Common.Triggers.Trigger item)
                {
                    var trigger = (Common.Triggers.Trigger)item.Clone();
                    trigger.Character   = "";
                    trigger.LastMatched = DateTime.MinValue;
                    trigger.Count       = 0;
                    package.TriggerList.Add(trigger);
                }
            }

            foreach (object obj in DirectionList.DataList.SelectedItems)
            {
                // Make sure the item is an Alias.  The last item in the list which is a new record is sometimes
                // an different object type.
                if (obj is Direction item)
                {
                    var direction = (Direction)item.Clone();
                    package.DirectionList.Add(direction);
                }
            }

            var dialog = new SaveFileDialog
            {
                InitialDirectory = App.Settings.AvalonSettings.SaveDirectory,
                Filter           = "JSON files (*.json)|*.json",
                Title            = "Save Package"
            };

            try
            {
                if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    File.WriteAllText(dialog.FileName, Newtonsoft.Json.JsonConvert.SerializeObject(package, Newtonsoft.Json.Formatting.Indented));
                }
            }
            catch (Exception ex)
            {
                var msgbox = new MessageBoxDialog()
                {
                    Title   = "Error",
                    Content = ex.Message,
                };

                return;
            }

            this.Close();
        }
Exemplo n.º 4
0
 // Use this for initialization
 public void Setup(LevelChooser _ch, DirectionList _direc)
 {
     chooser = _ch;
     direction = _direc;
     _spr = GetComponentInChildren<OTSprite>();
 }