public virtual Func <bool> GUI_Edit(SingleSlotBox container) { return(delegate() { return true; }); }
public override Func <bool> GUI_Edit(SingleSlotBox container) { var builder = new FieldBuilder(); builder.BuildSessionStart(container); builder.AddResizableButtonField("Edit Input-Neurons", delegate(object sender) { EditNeuronListForm <RMP_InputNeuron> .ShowDialogue(container.Parent, InputNeurons); }, FieldBuilder.ResizableButtonOrientation.FillWidth); builder.AddResizableButtonField("Edit Hidden-Neurons", delegate(object sender) { EditNeuronListForm <RMP_Neuron> .ShowDialogue(container.Parent, HiddenNeurons); }, FieldBuilder.ResizableButtonOrientation.FillWidth); builder.AddResizableButtonField("Edit Output-Neurons", delegate(object sender) { EditNeuronListForm <RMP_OutputNeuron> .ShowDialogue(container.Parent, OutputNeurons); }, FieldBuilder.ResizableButtonOrientation.FillWidth); builder.AddVerticalMargin(5); builder.BuildSessionEnd(); return(delegate() { return true; }); }
public static Func <bool> GUI_Edit(SingleSlotBox container, FitnessWorld world) { var builder = new FieldBuilder(); builder.BuildSessionStart(container); Panel panel = new Panel(); panel.Initialize(); builder.AddDrawBoxAsField(panel, DrawBoxAlignment.GetFull()); Func <bool> isReadyFunc = World.GUI_Edit(panel, world); var minFood = builder.AddIntegerField("Minimum Food: "); var minCreatures = builder.AddIntegerField("Minimum Creatures: "); builder.BuildSessionEnd(); container.IsClosing += delegate(object sender) { world.MinimumFood = (int)minFood.Value; world.MinimumCreatures = (int)minCreatures.Value; }; return(delegate() { return isReadyFunc(); }); }
public static Func <bool> GUI_Edit(SingleSlotBox container, World world) { var builder = new FieldBuilder(); builder.BuildSessionStart(container); var width = builder.AddIntegerField("World Width: "); width.MinValue = 1; width.Value = world.Width; var height = builder.AddIntegerField("World Height: "); height.MinValue = 1; height.Value = world.Height; var worldHasEdges = builder.AddCheckBoxField("World Edges"); worldHasEdges.Checked = world.WorldHasEdges; var regionSize = builder.AddIntegerField("Region Size: "); regionSize.MinValue = 1; regionSize.Value = world.RegionSize; var gaussianMin = builder.AddIntegerField("Gassian Generator Min: "); gaussianMin.Value = 0; var gaussianMax = builder.AddIntegerField("Gassian Generator Max: "); gaussianMax.Value = 1000; container.IsClosing += delegate(object sender) { world.Width = (int)width.Value; world.Height = (int)height.Value; world.WorldHasEdges = worldHasEdges.Checked; world.RegionSize = (int)regionSize.Value; world.Random = new UniformRandomGenerator(); world.GaussianRandom = new NormalRandomGenerator((int)gaussianMin.Value, (int)gaussianMax.Value, world.Random); foreach (var e in world.EntityList) { e.Position = new EntityPosition(Math.Min(e.Position.X, world.Width - 1), Math.Min(e.Position.Y, world.Height - 1)); } world.ReloadRegions(); }; builder.BuildSessionEnd(); return(delegate() { return true; }); }
public void BuildSessionStart(SingleSlotBox _container) { container = _container; FieldWidth = 300; VerticalMargin = 5; HorizontalMargin = 3; container.Width = FieldWidth; AddNewFieldList(); }
public void BuildSessionEnd() { container.Wrap(); container = null; foreach (var pair in alignments) { pair.Key.Alignment = pair.Value; } fieldHistory.Clear(); alignments.Clear(); }
public static Func <bool> GUI_Edit(SingleSlotBox container, FoodWorld world) { var builder = new FieldBuilder(); builder.BuildSessionStart(container); Panel panel = new Panel(); panel.Initialize(); builder.AddDrawBoxAsField(panel, DrawBoxAlignment.GetFull()); Func <bool> isReadyFunc = World.GUI_Edit(panel, world); var minFood = builder.AddIntegerField("Minimum Food: "); minFood.Value = world.MinimumFood; var foodSpawnRate = builder.AddIntegerField("Food Spawn-rate: "); foodSpawnRate.Value = world.FoodSpawnRate; builder.AddResizableButtonField("Edit Food", delegate(object sender) { EditEntityForm.ShowDialogue(container.Parent, world.FoodToClone); }, FieldBuilder.ResizableButtonOrientation.FillWidth); container.IsClosing += delegate(object sender) { world.MinimumFood = (int)minFood.Value; world.FoodSpawnRate = (int)foodSpawnRate.Value; }; builder.BuildSessionEnd(); return(delegate() { return isReadyFunc(); }); }
public virtual Func <bool> GUI_Edit(SingleSlotBox container) { return(null); }
public static Func <bool> GUI_Edit(SingleSlotBox container, RMP_Chromosome chromosome) { var builder = new FieldBuilder(); builder.BuildSessionStart(container); Dictionary <string, object> valueHolder = new Dictionary <string, object>(); valueHolder.Add("RMP_Chromosome", chromosome); var inhibitoryConnectionChance = builder.AddDoubleField("Inhibitory Connection-Chance: "); inhibitoryConnectionChance.Value = chromosome.InhibitoryConnectionChance; var connectionChance = builder.AddDoubleField("Connection-Chance: "); connectionChance.Value = chromosome.ConnectionChance; var newConnectionsCanForm = builder.AddCheckBoxField("NewConnectionsCanForm: "); newConnectionsCanForm.Checked = chromosome.NewConnectionsCanForm; var connectionsCanDie = builder.AddCheckBoxField("ConnectionsCanDie: "); connectionsCanDie.Checked = chromosome.ConnectionsCanDie; var newNeuronsCanForm = builder.AddCheckBoxField("NewNeuronsCanForm: "); newNeuronsCanForm.Checked = chromosome.NewNeuronsCanForm; var neuronsCanDie = builder.AddCheckBoxField("NeuronsCanDie: "); neuronsCanDie.Checked = chromosome.NeuronsCanDie; Action reloadChromosome = delegate() { chromosome.InhibitoryConnectionChance = inhibitoryConnectionChance.Value; chromosome.ConnectionChance = connectionChance.Value; chromosome.NewConnectionsCanForm = newConnectionsCanForm.Checked; chromosome.ConnectionsCanDie = connectionsCanDie.Checked; chromosome.NewNeuronsCanForm = newNeuronsCanForm.Checked; chromosome.NeuronsCanDie = neuronsCanDie.Checked; }; if (chromosome.MutationGenes.Count == 0) { //Mutation Genes chromosome.MutationGenes.Add(new DoubleGene("NeuronAddChance", 0, 1, 0.1)); chromosome.MutationGenes.Add(new DoubleGene("NeuronRemoveChance", 0, 1, 0.1)); chromosome.MutationGenes.Add(new DoubleGene("MaxNeuronRemoving", 0, 1, 0.1)); chromosome.MutationGenes.Add(new DoubleGene("MaxNeuronAdding", 0, 1, 0.1)); chromosome.MutationGenes.Add(new DoubleGene("ConnectionAddChance", 0, 1, 0.05)); chromosome.MutationGenes.Add(new DoubleGene("ConnectionRemoveChance", 0, 1, 0.05)); } builder.AddResizableButtonField("Edit Mutation Genes", delegate(object sender) { EditDoubleGeneListForm.ShowDialogue(container.Parent, chromosome.MutationGenes); }); var sigmoidTypes = Globals.GetAllTypesDeriving(typeof(SigmoidFunction), Assembly.GetExecutingAssembly()); var sigmoidNames = new List <string>(sigmoidTypes.Select(s => s.Name)); var globalSigmoidComboBox = builder.AddComboBoxField("GlobalSigmoid: ", sigmoidNames); if (chromosome.GlobalSigmoidFunction != null) { var globalSigmoidType = chromosome.GlobalSigmoidFunction.GetType(); foreach (var type in sigmoidTypes) { if (type.IsEquivalentTo(globalSigmoidType)) { globalSigmoidComboBox.Index = sigmoidTypes.IndexOf(type); } } } globalSigmoidComboBox.SelectedItemChanged += delegate(object sender, int newItemIndex, int oldItemIndex) { chromosome.GlobalSigmoidFunction = (SigmoidFunction)Activator.CreateInstance(sigmoidTypes[newItemIndex]); }; var globalSigmoidEditButton = builder.AddResizableButtonField("Edit GlobalSigmoid", delegate(object sender) { if (chromosome.GlobalSigmoidFunction == null) { return; } var sigmoid = chromosome.GlobalSigmoidFunction; sigmoidTypes[globalSigmoidComboBox.Index].InvokeMember("GUI_Edit", BindingFlags.Default | BindingFlags.InvokeMethod, null, null, new object[] { container.Parent, sigmoid }); }); var globalOutputSigmoidComboBox = builder.AddComboBoxField("GlobalOutputSigmoid: ", sigmoidNames); if (chromosome.GlobalOutputSigmoidFunction != null) { var globalOutputSigmoidType = chromosome.GlobalOutputSigmoidFunction.GetType(); foreach (var type in sigmoidTypes) { if (type.IsEquivalentTo(globalOutputSigmoidType)) { globalOutputSigmoidComboBox.Index = sigmoidTypes.IndexOf(type); } } } globalOutputSigmoidComboBox.SelectedItemChanged += delegate(object sender, int newItemIndex, int oldItemIndex) { chromosome.GlobalOutputSigmoidFunction = (SigmoidFunction)Activator.CreateInstance(sigmoidTypes[newItemIndex]); }; var globalOutputSigmoidEditButton = builder.AddResizableButtonField("Edit GlobalOutputSigmoid", delegate(object sender) { if (chromosome.GlobalOutputSigmoidFunction == null) { return; } var sigmoid = chromosome.GlobalOutputSigmoidFunction; sigmoidTypes[globalOutputSigmoidComboBox.Index].InvokeMember("GUI_Edit", BindingFlags.Default | BindingFlags.InvokeMethod, null, null, new object[] { container.Parent, sigmoid }); }); builder.AddResizableButtonField("Randomize", delegate(object sender) { reloadChromosome(); if (chromosome.GlobalSigmoidFunction == null || chromosome.GlobalOutputSigmoidFunction == null) { AlertForm.ShowDialogue(container.Parent, null, "Can't randomize before choosing a sigmoid function."); } else { RandomizeForm.ShowDialogue(container.Parent, chromosome); } }); builder.AddResizableButtonField("Edit Neuron-genes", delegate(object sender) { reloadChromosome(); EditChromosomeNeuronsForm.ShowDialogue(container.Parent, valueHolder); }); container.IsClosing += delegate(object sender) { reloadChromosome(); }; builder.BuildSessionEnd(); return(delegate() { return chromosome.GlobalSigmoidFunction != null && chromosome.GlobalOutputSigmoidFunction != null; }); }
protected virtual ColumnListBox GUI_Edit_AddColumnListBox(SingleSlotBox container) { var columnListBox = new ColumnListBox(); columnListBox.Initialize(2); container.AddDrawBox(columnListBox); columnListBox.SetIntOrStringSort(false, false); columnListBox.SetColumnName(0, "Name"); columnListBox.SetColumnName(1, "Value"); columnListBox.Width = 200; columnListBox.Height = 200; GUI_Edit_SetColumnListBox(columnListBox); columnListBox.ItemDoubleClicked += delegate(object sender, ColumnListBox.ListBoxRow item, int index) { var valType = columnListBox.SelectedRow.Values[1].GetType(); if (valType.IsEquivalentTo(typeof(int))) { EditIntForm.ShowDialogue(container.Parent, (int)columnListBox.SelectedRow.Values[1], delegate(object _sender) { columnListBox.SelectedRow.Values[1] = ((EditIntForm)_sender).Result; }); } else if (valType.IsEquivalentTo(typeof(byte))) { EditByteForm.ShowDialogue(container.Parent, (byte)columnListBox.SelectedRow.Values[1], delegate(object _sender) { columnListBox.SelectedRow.Values[1] = ((EditByteForm)_sender).Result; }); } else if (valType.IsEquivalentTo(typeof(double))) { EditDoubleForm.ShowDialogue(container.Parent, (double)columnListBox.SelectedRow.Values[1], delegate(object _sender) { columnListBox.SelectedRow.Values[1] = ((EditDoubleForm)_sender).Result; }); } else if (valType.IsEquivalentTo(typeof(bool))) { EditBoolForm.ShowDialogue(container.Parent, (bool)columnListBox.SelectedRow.Values[1], delegate(object _sender) { columnListBox.SelectedRow.Values[1] = ((EditBoolForm)_sender).Result; }); } }; var editFieldButton = new ResizableButton(); editFieldButton.Initialize(); container.AddDrawBox(editFieldButton); editFieldButton.Title = "Edit Field"; editFieldButton.FitToText(); Push.ToTheBottomSideOf(editFieldButton, columnListBox, 3, Push.VerticalAlign.Left); editFieldButton.Width = 200; editFieldButton.Click += delegate(object sender) { var valType = columnListBox.SelectedRow.Values[1].GetType(); if (valType.IsEquivalentTo(typeof(int))) { EditIntForm.ShowDialogue(container.Parent, (int)columnListBox.SelectedRow.Values[1], delegate(object _sender) { columnListBox.SelectedRow.Values[1] = ((EditIntForm)_sender).Result; }); } else if (valType.IsEquivalentTo(typeof(byte))) { EditByteForm.ShowDialogue(container.Parent, (byte)columnListBox.SelectedRow.Values[1], delegate(object _sender) { columnListBox.SelectedRow.Values[1] = ((EditByteForm)_sender).Result; }); } else if (valType.IsEquivalentTo(typeof(double))) { EditDoubleForm.ShowDialogue(container.Parent, (double)columnListBox.SelectedRow.Values[1], delegate(object _sender) { columnListBox.SelectedRow.Values[1] = ((EditDoubleForm)_sender).Result; }); } else if (valType.IsEquivalentTo(typeof(bool))) { EditBoolForm.ShowDialogue(container.Parent, (bool)columnListBox.SelectedRow.Values[1], delegate(object _sender) { columnListBox.SelectedRow.Values[1] = ((EditBoolForm)_sender).Result; }); } }; container.Wrap(); columnListBox.Alignment = DrawBoxAlignment.GetFull(); editFieldButton.Alignment = DrawBoxAlignment.GetLeftRightBottom(); container.IsClosing += delegate(object sender) { GUI_Edit_SetValues(columnListBox); }; return(columnListBox); }
public virtual Func <bool> GUI_Edit(SingleSlotBox container) { GUI_Edit_AddColumnListBox(container); return(GUI_Edit_GetValidFunction()); }