public static EditNeuronForm ShowDialogue(Window window, RMP_Neuron _neuronGene, CloseEvent closeFunction = null, string category = null, ISkinFile file = null) { var form = new EditNeuronForm(); form.Initialize(_neuronGene, closeFunction, "Edit Neuron", 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_Neuron _neuronGene, CloseEvent closeFunction = null, string title = null, bool resizable = false, bool isDialog = true, string category = null, ISkinFile file = null) { neuron = _neuronGene; base.Initialize(closeFunction, title, resizable, isDialog, category, file); }