/// <summary> /// Create a fresh start for an <see cref="Neat"/> object /// </summary> private void Reset() { AllConnections.Clear(); AllNodes.Clear(); AllClients.Clear(); for (int i = 0; i < Constants.InputSize; i++) { NodeGene node = CreateNode(); node.X = 0.1;; node.Y = (i + 1) / (double)(Constants.InputSize + 1); } for (int i = 0; i < Constants.OutputSize; i++) { NodeGene node = CreateNode(); node.X = 0.9;; node.Y = (i + 1) / (double)(Constants.OutputSize + 1); ActivationEnumeration a = ActivationEnumeration.Random(); node.Activation = a.Activation; node.ActivationName = a.Name; } for (int i = 0; i < Constants.MaxClients; i++) { Client c = new Client(EmptyGenome()); AllClients.Add(c); } }
public void EmptyAllNodes() { lock (AllNodesLock) { AllNodes.Clear(); NodeCount = 0; } }
public void ClearNodes() { CtrlPressed = false; CurrentMouseMode?.End(Event.current?.mousePosition ?? Vector2.zero); CurrentMouseMode = null; OnDeleteNode.Clear(); OnSelectNode.Clear(); OnDeleteNode.Clear(); SelectedNodes.Clear(); AllNodes.Clear(); }
public void ClearNodes() { CtrlPressed = false; CurrentMouseMode?.End(Event.current?.mousePosition ?? Vector2.zero); CurrentMouseMode = null; OnDeleteNode.Clear(); OnSelectNode.Clear(); OnDeleteNode.Clear(); SelectedNodes.Clear(); foreach (var node in AllNodes) { node.OnDestroy(); } AllNodes.Clear(); }
public void CreateTree(List <FileBlock> fileBlocks) { AllNodes.Clear(); List <HATNode <T> > AllParentsNodeTemp = new List <HATNode <T> >(); ServerBob server = new ServerBob(); AliceUser user = new AliceUser(); server.User = user; user.Server = server; server.setKeysWithUser(); fileBlocks = fileBlocks.OrderBy(x => x.Index).ToList(); for (int i = 0; i < fileBlocks.Count; i = i + 2) { HATNode <T> left = new HATNode <T>(); left.Hash = fileBlocks[i].ContentHash; left.Tag = user.EncryptMessage(left.Hash); left.IsBlockNode = true; left.FileBlockIndex = i; left.Version = 1; AllNodes.Add(left); HATNode <T> right = new HATNode <T>(); if (i + 1 < fileBlocks.Count) { right.Hash = fileBlocks[i + 1].ContentHash; right.Tag = user.EncryptMessage(right.Hash); right.IsBlockNode = true; right.FileBlockIndex = i + 1; right.Version = 1; AllNodes.Add(right); } HATNode <T> parent = new HATNode <T>(); parent.Left = left; parent.Right = right; parent.IsBlockNode = false; parent.FileBlockIndex = -1; if (i + 1 < fileBlocks.Count) { parent.Hash = Utility.ComputeHashAsString(left.Hash + right.Hash); } else { parent.Hash = Utility.ComputeHashAsString(left.Hash); } AllNodes.Add(parent); AllParentsNodeTemp.Add(parent); } CreateTree(AllParentsNodeTemp); SetNodeIndexes(); SetLeafNodeCount(); }
public override void OnAbort() { aborted = GameTime; AllNodes.Clear(); }