Ejemplo n.º 1
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            CloseButtonOn = false;

            var builder = new FieldBuilder();

            builder.BuildSessionStart(this);

            var valueField = builder.AddDoubleField("Value: ");

            valueField.Value = Result;

            builder.AddVerticalMargin(5);

            builder.AddResizableButtonField("OK", delegate(object sender)
            {
                Result = valueField.Value;

                Close();
            }, FieldBuilder.ResizableButtonOrientation.Left);

            builder.BuildSessionEnd();

            CanResizeFormVertically = false;

            X = (Parent.Width / 2) - (Width / 2);
            Y = (Parent.Height / 2) - (Height / 2);
        }
Ejemplo n.º 2
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            CloseButtonOn = false;

            var builder = new FieldBuilder();

            builder.BuildSessionStart(this);

            builder.AddLabelField("Name: " + connection.Name);
            builder.AddLabelField("Source: " + connection.Source.GeneID);
            builder.AddLabelField("Target: " + connection.Target.GeneID);

            var weightField = builder.AddDoubleField("Weight:");

            weightField.Value = connection.Weight;

            builder.AddResizableButtonField("OK", delegate(object sender)
            {
                connection.Weight = weightField.Value;

                Close();
            }, FieldBuilder.ResizableButtonOrientation.Left);

            builder.BuildSessionEnd();

            X = (Parent.Width / 2) - (Width / 2);
            Y = (Parent.Height / 2) - (Height / 2);
        }
Ejemplo n.º 3
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            CloseButtonOn = false;

            var builder = new FieldBuilder();

            builder.BuildSessionStart(this);

            nameField      = builder.AddTextField("Name: ");
            nameField.Text = neuronGene.Name;

            isMutableCheckBox         = builder.AddCheckBoxField("Gene Mutability: ");
            isMutableCheckBox.Checked = neuronGene.IsMutable;

            builder.AddLabelField("Bias:");
            biasMin = builder.AddDoubleField("Min: ");
            biasMax = builder.AddDoubleField("Max: ");
            biasVal = builder.AddDoubleField("Value: ");


            biasMin.Value = neuronGene.Bias.Min;
            biasMax.Value = neuronGene.Bias.Max;
            biasVal.Value = neuronGene.Bias.Value;

            builder.AddResizableButtonField("Edit Sigmoid Function", delegate(object sender)
            {
                neuronGene.SigmoidFunction.GetType().InvokeMember("GUI_Edit", BindingFlags.Default | BindingFlags.InvokeMethod, null, null, new object[] { Parent, neuronGene.SigmoidFunction });
            }, FieldBuilder.ResizableButtonOrientation.FillWidth);

            builder.AddResizableButtonField("Edit Connections", delegate(object sender)
            {
                EditConnectionGeneListForm.ShowDialogue(Parent, neuronGene.Connections);
            }, FieldBuilder.ResizableButtonOrientation.FillWidth);

            builder.AddResizableButtonField("OK", delegate(object sender)
            {
                Close();
            }, FieldBuilder.ResizableButtonOrientation.Left);

            builder.BuildSessionEnd();

            X = (Parent.Width / 2) - (Width / 2);
            Y = (Parent.Height / 2) - (Height / 2);
        }
Ejemplo n.º 4
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            CloseButtonOn = false;

            var builder = new FieldBuilder();

            builder.BuildSessionStart(this);

            builder.AddLabelField("Name: " + neuron.Name);
            builder.AddLabelField("GeneID: " + neuron.GeneID);

            var activation = builder.AddDoubleField("Activation: ");

            activation.Value = neuron.Activation;

            var bias = builder.AddDoubleField("Bias: ");

            bias.Value = neuron.Bias;

            builder.AddResizableButtonField("Edit Sigmoid Function", delegate(object sender)
            {
                neuron.SigmoidFunction.GetType().InvokeMember("GUI_Edit", BindingFlags.Default | BindingFlags.InvokeMethod, null, null, new object[] { Parent, neuron.SigmoidFunction });
            }, FieldBuilder.ResizableButtonOrientation.FillWidth);

            builder.AddResizableButtonField("Edit Connections", delegate(object sender)
            {
                EditConnectionListForm.ShowDialogue(Parent, neuron.Connections);
            }, FieldBuilder.ResizableButtonOrientation.FillWidth);

            builder.AddResizableButtonField("OK", delegate(object sender)
            {
                neuron.Activation = activation.Value;
                neuron.Bias       = bias.Value;

                Close();
            }, FieldBuilder.ResizableButtonOrientation.Left);

            builder.BuildSessionEnd();

            X = (Parent.Width / 2) - (Width / 2);
            Y = (Parent.Height / 2) - (Height / 2);
        }
Ejemplo n.º 5
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            CloseButtonOn = false;

            var builder = new FieldBuilder();

            builder.BuildSessionStart(this);

            var gName    = builder.AddTextField("Name: ");
            var gMin     = builder.AddDoubleField("Min: ");
            var gMax     = builder.AddDoubleField("Max: ");
            var gVal     = builder.AddDoubleField("Value: ");
            var gMutable = builder.AddCheckBoxField("IsMutable: ");

            gName.Text       = Result.Name;
            gMin.Value       = Result.Min;
            gMax.Value       = Result.Max;
            gVal.Value       = Result.Value;
            gMutable.Checked = Result.IsMutable;

            builder.AddVerticalMargin(5);

            builder.AddResizableButtonField("OK", delegate(object sender)
            {
                Result.Name = gName.Text;
                Result.SetMinMaxValue(gMin.Value, gMax.Value, gVal.Value);
                Result.IsMutable = gMutable.Checked;

                Close();
            }, FieldBuilder.ResizableButtonOrientation.Left);

            builder.BuildSessionEnd();

            CanResizeFormVertically = false;

            X = (Parent.Width / 2) - (Width / 2);
            Y = (Parent.Height / 2) - (Height / 2);
        }
Ejemplo n.º 6
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            CloseButtonOn = false;

            var builder = new FieldBuilder();

            builder.BuildSessionStart(this);

            targetIntegerField       = builder.AddIntegerField("Target: ");
            targetIntegerField.Value = connection.Target;

            isOutputConnectionCheckBox         = builder.AddCheckBoxField("Is Output-Connection: ");
            isOutputConnectionCheckBox.Checked = connection.IsOutputConnection;

            isMutableCheckBox         = builder.AddCheckBoxField("Connection Mutability: ");
            isMutableCheckBox.Checked = connection.IsMutable;

            builder.AddLabelField("Weight:");
            weightMin = builder.AddDoubleField("Min: ");
            weightMax = builder.AddDoubleField("Max: ");
            weightVal = builder.AddDoubleField("Value: ");

            weightMin.Value = connection.Weight.Min;
            weightMax.Value = connection.Weight.Max;
            weightVal.Value = connection.Weight.Value;

            builder.AddResizableButtonField("OK", delegate(object sender)
            {
                Close();
            }, FieldBuilder.ResizableButtonOrientation.Left);

            builder.BuildSessionEnd();

            X = (Parent.Width / 2) - (Width / 2);
            Y = (Parent.Height / 2) - (Height / 2);
        }
Ejemplo n.º 7
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            var builder = new FieldBuilder();

            builder.BuildSessionStart(this);

            var nameField = builder.AddTextField("Name: ");

            nameField.Text = spawnPoint.Name;

            var posX = builder.AddDoubleField("Position X: ");

            posX.Value = spawnPoint.SpawnArea.X;

            var posY = builder.AddDoubleField("Position Y: ");

            posY.Value = spawnPoint.SpawnArea.Y;

            var width = builder.AddIntegerField("Width: ");

            width.Value = spawnPoint.SpawnArea.Width;

            var height = builder.AddIntegerField("Height: ");

            height.Value = spawnPoint.SpawnArea.Height;

            var timeInterval = builder.AddDoubleField("Time Interval: ");

            timeInterval.Value = spawnPoint.TimeInterval;

            reloadValues = delegate()
            {
                nameField.Text     = spawnPoint.Name;
                posX.Value         = spawnPoint.SpawnArea.X;
                posY.Value         = spawnPoint.SpawnArea.Y;
                width.Value        = spawnPoint.SpawnArea.Width;
                height.Value       = spawnPoint.SpawnArea.Height;
                timeInterval.Value = spawnPoint.TimeInterval;
            };

            reloadValues();

            Action setValues = delegate()
            {
                spawnPoint.Name = nameField.Text;

                spawnPoint.SpawnArea.X      = (int)posX.Value;
                spawnPoint.SpawnArea.Y      = (int)posY.Value;
                spawnPoint.SpawnArea.Width  = (int)width.Value;
                spawnPoint.SpawnArea.Height = (int)height.Value;

                spawnPoint.SetTimeInterval(timeInterval.Value);
            };

            builder.AddVerticalMargin(5);

            builder.AddResizableButtonField("Set Spawn-Area with mouse", delegate(object sender)
            {
                setValues();

                Parent.DialoguesAreHidden = true;

                Globals.Editor.Mode = Editor.Modes.SetPeremiter;
                Globals.Editor.Set_SendPeremiterFunction(sendPeremiter);
            }, FieldBuilder.ResizableButtonOrientation.FillWidth);

            builder.AlignTop    = true;
            builder.AlignBottom = true;

            spawnEntitiesList = builder.AddColumnListBox("Spawn-entities", 300, 2);
            spawnEntitiesList.SetIntOrStringSort(false, true);
            spawnEntitiesList.SetColumnName(0, "Entity-Type");
            spawnEntitiesList.SetColumnName(1, "Amount");

            builder.AlignTop    = false;
            builder.AlignBottom = true;

            builder.AddResizableButtonField("Add Entity", delegate(object sender)
            {
                AddSpawnEntityForm.ShowDialogue(Parent, spawnPoint, delegate(object _sender)
                {
                    reloadList();
                });
            }, FieldBuilder.ResizableButtonOrientation.Right);

            builder.AddResizableButtonField("Remove Entity", delegate(object sender)
            {
                if (spawnEntitiesList.SelectedRowIndex == -1)
                {
                    return;
                }

                spawnPoint.SpawnClones.Remove((IEntity)spawnEntitiesList.Values[spawnEntitiesList.SelectedRowIndex].ExtraValues[0]);
                reloadValues();
            }, FieldBuilder.ResizableButtonOrientation.Right);

            builder.AddResizableButtonField("OK", delegate(object sender)
            {
                setValues();
                Close();
            }, FieldBuilder.ResizableButtonOrientation.Right);

            builder.BuildSessionEnd();

            X = (Parent.Width / 2) - (Width / 2);
            Y = (Parent.Height / 2) - (Height / 2);

            CanResizeFormVertically = false;
        }
Ejemplo n.º 8
0
        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;
            });
        }
Ejemplo n.º 9
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            CloseButtonOn = false;

            var builder = new FieldBuilder();

            builder.BuildSessionStart(this);

            var symmetricalBordersCheckBox = builder.AddCheckBoxField("Symmetrical Borders: ");

            symmetricalBordersCheckBox.Checked = sigmoid.SymmetricalBorders;

            builder.AddLabelField("P: ");
            var pMin     = builder.AddDoubleField("Min: ");
            var pMax     = builder.AddDoubleField("Max: ");
            var pVal     = builder.AddDoubleField("Value: ");
            var pMutable = builder.AddCheckBoxField("IsMutable: ");

            builder.AddVerticalMargin(4);

            builder.AddLabelField("Output-Border: ");
            var o1Min     = builder.AddDoubleField("Min: ");
            var o1Max     = builder.AddDoubleField("Max: ");
            var o1Val     = builder.AddDoubleField("Value: ");
            var o1Mutable = builder.AddCheckBoxField("IsMutable: ");

            var switchBox = new SwitchBox();

            switchBox.Initialize();
            builder.AddDrawBoxAsField(switchBox, DrawBoxAlignment.GetLeftRight());

            var emptyPanel = new Panel();

            emptyPanel.Initialize();

            switchBox.AddDrawBox(emptyPanel, "symmetrical");

            var panel = new Panel();

            panel.Initialize();

            var builder2 = new FieldBuilder();

            builder2.BuildSessionStart(panel);
            builder2.AddLabelField("Output-Border 2: ");
            var o2Min     = builder2.AddDoubleField("Min: ");
            var o2Max     = builder2.AddDoubleField("Max: ");
            var o2Val     = builder2.AddDoubleField("Value: ");
            var o2Mutable = builder2.AddCheckBoxField("IsMutable: ");

            builder2.BuildSessionEnd();

            switchBox.AddDrawBox(panel, "non-symmetrical");

            int largestHeight = 0;

            foreach (var p in switchBox.DrawBoxList)
            {
                if (p.Height > largestHeight)
                {
                    largestHeight = panel.Height;
                }
            }

            switchBox.Width  = builder.FieldWidth;
            switchBox.Height = largestHeight;

            if (sigmoid.GeneList.Count != 0)
            {
                var o1Gene = (DoubleGene)sigmoid.GeneList[0];
                o1Min.Value       = o1Gene.Min;
                o1Max.Value       = o1Gene.Max;
                o1Val.Value       = o1Gene.Value;
                o1Mutable.Checked = o1Gene.IsMutable;

                int n = 1;

                if (!sigmoid.SymmetricalBorders)
                {
                    var o2Gene = (DoubleGene)sigmoid.GeneList[n++];
                    o2Min.Value       = o2Gene.Min;
                    o2Max.Value       = o2Gene.Max;
                    o2Val.Value       = o2Gene.Value;
                    o2Mutable.Checked = o2Gene.IsMutable;
                }

                var pGene = (DoubleGene)sigmoid.GeneList[n++];
                pMin.Value       = pGene.Min;
                pMax.Value       = pGene.Max;
                pVal.Value       = pGene.Value;
                pMutable.Checked = pGene.IsMutable;
            }

            if (sigmoid.SymmetricalBorders)
            {
                switchBox.SelectDrawBoxWithKey("symmetrical");
            }
            else
            {
                switchBox.SelectDrawBoxWithKey("non-symmetrical");
            }

            symmetricalBordersCheckBox.CheckedChanged += delegate(object sender, bool newValue)
            {
                if (newValue)
                {
                    switchBox.SelectDrawBoxWithKey("symmetrical");
                }
                else
                {
                    switchBox.SelectDrawBoxWithKey("non-symmetrical");
                }
            };

            builder.AddResizableButtonField("OK", delegate(object sender)
            {
                Close();
            }, FieldBuilder.ResizableButtonOrientation.Left);

            builder.BuildSessionEnd();

            IsClosing += delegate(object sender)
            {
                geneList.Clear();

                var _o1Gene = new DoubleGene();
                _o1Gene.SetMinMaxValue(o1Min.Value, o1Max.Value, o1Val.Value);
                _o1Gene.IsMutable = o1Mutable.Checked;
                geneList.Add(_o1Gene);

                if (!symmetricalBordersCheckBox.Checked)
                {
                    var _o2Gene = new DoubleGene();
                    _o2Gene.SetMinMaxValue(o2Min.Value, o2Max.Value, o2Val.Value);
                    _o2Gene.IsMutable = pMutable.Checked;
                    geneList.Add(_o2Gene);
                }

                var _pGene = new DoubleGene();
                _pGene.SetMinMaxValue(pMin.Value, pMax.Value, pVal.Value);
                _pGene.IsMutable = pMutable.Checked;
                geneList.Add(_pGene);
            };

            CanResizeFormVertically = false;

            X = (Parent.Width / 2) - (Width / 2);
            Y = (Parent.Height / 2) - (Height / 2);
        }