public override void AddedToContainer() { base.AddedToContainer(); columnListBox = new ColumnListBox(); columnListBox.Initialize(4); AddDrawBox(columnListBox); columnListBox.SetIntOrStringSort(true, true, true, true); columnListBox.SetColumnName(0, "ID"); columnListBox.SetColumnName(1, "Source"); columnListBox.SetColumnName(1, "Target"); columnListBox.SetColumnName(3, "Weight"); columnListBox.Width = 200; columnListBox.Height = 200; columnListBox.ItemDoubleClicked += delegate(object sender, TakaGUI.DrawBoxes.ColumnListBox.ListBoxRow item, int index) { RMP_Connection connection = null; foreach (var c in connections) { if (c.ID == (uint)item.Values[0]) { connection = c; } } if (connection != null) { EditConnectionForm.ShowDialogue(Parent, connection, delegate(object _sender) { ReloadListBox(); }); } }; ReloadListBox(); var okButton = new ResizableButton(); okButton.Initialize(); AddDrawBox(okButton); okButton.Title = "OK"; okButton.FitToText(); Push.ToTheBottomSideOf(okButton, columnListBox, 3, Push.VerticalAlign.Left); okButton.Width = 200; okButton.Click += delegate(object sender) { Close(); }; Wrap(); columnListBox.Alignment = DrawBoxAlignment.GetFull(); okButton.Alignment = DrawBoxAlignment.GetLeftRightBottom(); X = (Parent.Width / 2) - (Width / 2); Y = (Parent.Height / 2) - (Height / 2); }
public static EditConnectionForm ShowDialogue(Window window, RMP_Connection _connection, CloseEvent closeFunction = null, string category = null, ISkinFile file = null) { var form = new EditConnectionForm(); form.Initialize(_connection, closeFunction, "Edit Connection-gene", true, true, category, file); form.Show(window); return(form); }
public override void Idle(GameTime gameTime) { base.Idle(gameTime); if (SelectedCreature != null) { SelectedCreature.Age = 0; SelectedCreature.Energy.SetToMax(); } if (SelectingPool != null && SelectingPool.IsUnderMouse && MouseInput.IsClicked(TakaGUI.Services.MouseButtons.Left)) { if (SelectingPool != null) { foreach (var entity in SelectingPool.World.EntityList) { if (entity.EntityName != "Creature") { continue; } var entityRect = new Rectangle((int)entity.Position.X + SelectingPool.RealX - SelectingPool.ViewCamera.LookX - entity.Radius / 2, (int)entity.Position.Y + SelectingPool.RealY - SelectingPool.ViewCamera.LookY - entity.Radius / 2, entity.Radius, entity.Radius); if (MouseInput.X >= entityRect.Left && MouseInput.Y >= entityRect.Top && MouseInput.X <= entityRect.Right && MouseInput.Y <= entityRect.Bottom) { SelectedCreature = (Creature)entity; SetNewNeuralNet((RMP_Net)SelectedCreature.Brain); } } } } if (NeuralNet == null) { return; } if (KeyboardInput.IsClicked(Microsoft.Xna.Framework.Input.Keys.D1)) { connectionWeight = 10 * (1.0 / 10) - 5; } else if (KeyboardInput.IsClicked(Microsoft.Xna.Framework.Input.Keys.D2)) { connectionWeight = 10 * (2.0 / 10) - 5; } else if (KeyboardInput.IsClicked(Microsoft.Xna.Framework.Input.Keys.D3)) { connectionWeight = 10 * (3.0 / 10) - 5; } else if (KeyboardInput.IsClicked(Microsoft.Xna.Framework.Input.Keys.D4)) { connectionWeight = 10 * (4.0 / 10) - 5; } else if (KeyboardInput.IsClicked(Microsoft.Xna.Framework.Input.Keys.D5)) { connectionWeight = 10 * (5.0 / 10) - 5; } else if (KeyboardInput.IsClicked(Microsoft.Xna.Framework.Input.Keys.D6)) { connectionWeight = 10 * (6.0 / 10) - 5; } else if (KeyboardInput.IsClicked(Microsoft.Xna.Framework.Input.Keys.D7)) { connectionWeight = 10 * (7.0 / 10) - 5; } else if (KeyboardInput.IsClicked(Microsoft.Xna.Framework.Input.Keys.D8)) { connectionWeight = 10 * (8.0 / 10) - 5; } else if (KeyboardInput.IsClicked(Microsoft.Xna.Framework.Input.Keys.D9)) { connectionWeight = 10 * (9.0 / 10) - 5; } else if (KeyboardInput.IsClicked(Microsoft.Xna.Framework.Input.Keys.D0)) { connectionWeight = 10 * (10.0 / 10) - 5; } else if (KeyboardInput.IsClicked(Microsoft.Xna.Framework.Input.Keys.Q)) { connectionWeight = Globals.Random.NextDouble(-10, 10); } if (IsUnderMouse) { for (int i = 0; i < neuronPositions.Length; i++) { float x = (int)neuronPositions[i].X - 5 + (Width / 2 - graphWidth / 2 + RealX); float y = (int)neuronPositions[i].Y - 5 + (Height / 2 - graphHeight / 2 + RealY); var neuronRect = new Rectangle((int)x, (int)y, 10, 10); if (MouseInput.X >= neuronRect.Left && MouseInput.Y >= neuronRect.Top && MouseInput.X <= neuronRect.Right && MouseInput.Y <= neuronRect.Bottom) { if (MouseInput.IsPressed(TakaGUI.Services.MouseButtons.Right)) { neurons[i].Activation += 100; } else if (MouseInput.IsClicked(TakaGUI.Services.MouseButtons.Left)) { selectedNeuron = i; } else if (selectedNeuron != -1 && KeyboardInput.IsClicked(Microsoft.Xna.Framework.Input.Keys.C)) { var con = new RMP_Connection(); con.Weight = connectionWeight; con.Source = neurons[selectedNeuron]; con.Target = neurons[i]; neurons[selectedNeuron].Connections.Add(con); } } } } if (IsUnderMouse && KeyboardInput.IsClicked(Microsoft.Xna.Framework.Input.Keys.A)) { var posList = new List <Vector2>(neuronPositions); var neuronList = new List <RMP_Neuron>(neurons); var neuron = new RMP_Neuron(NeuralNet); neuron.SigmoidFunction = (SigmoidFunction)neuronList[0].SigmoidFunction.Clone(); NeuralNet.AddHiddenNeuron(neuron); float x = MouseInput.X - (Width / 2 - graphWidth / 2 + RealX); float y = MouseInput.Y - (Height / 2 - graphHeight / 2 + RealY); posList.Add(new Vector2(x, y)); neuronList.Add(neuron); neuronPositions = posList.ToArray(); neurons = neuronList.ToArray(); } if (IsUnderMouse && KeyboardInput.IsClicked(Microsoft.Xna.Framework.Input.Keys.R)) { foreach (var n in NeuralNet.HiddenNeurons) { n.Activation = Globals.Random.NextDouble(-1, 1); } } }
public void Initialize(RMP_Connection _connection, CloseEvent closeFunction = null, string title = null, bool resizable = false, bool isDialog = true, string category = null, ISkinFile file = null) { connection = _connection; base.Initialize(closeFunction, title, resizable, isDialog, category, file); }