public MyForm() { EventHandlers(); GuiLayout(); if (!string.IsNullOrEmpty(IdHandler.GetUuid())) { LoggedIn(); } else { if (NetworkPorts.IsPortAvailable(25565) == false) { Sorry(); } else if (String.IsNullOrEmpty(DiskHelper.GetRegistryValue("Path")) == true || Directory.Exists(DiskHelper.GetRegistryValue("Path")) == false) { FirstStartUp(); } else if (File.Exists(DiskHelper.GetRegistryValue("Path") + @".hidden\userdata") == false) { Create(); } else { Login(); } } }
public FileDownloader(NetworkPorts ports, ConcurrentDictionary <string, Peer> peers, int bufferSize = 1024) { _ports = ports; this._ip = IPAddress.Any; this._path = DiskHelper.GetRegistryValue("Path") + @".hidden\incoming\"; this._buffer = new byte[bufferSize]; this._peers = peers; }
public DeletionManager(StateSaveConcurrentQueue <string> queue, NetworkPorts ports, ConcurrentDictionary <string, Peer> peers, ConcurrentDictionary <string, P2PFile> locations) { this._queue = queue; this._ports = ports; this._waitHandle = new ManualResetEvent(false); this._queue.ElementAddedToQueue += QueueElementAddedToQueue; this._filesList = locations; Peer.PeerSwitchedOnline += PeerWentOnline; _fileDeleter = new FileDeleter(peers, _ports); }
public UploadManager(StateSaveConcurrentQueue <P2PFile> queue, NetworkPorts ports, ConcurrentDictionary <string, Peer> peers) { this._queue = queue; this._ports = ports; this._peers = peers; this._waitHandle = new ManualResetEvent(false); this._queue.ElementAddedToQueue += QueueElementAddedToQueue; _hiddenFolder = new HiddenFolder(_path + @".hidden"); this._path = DiskHelper.GetRegistryValue("Path"); Peer.PeerSwitchedOnline += PeerWentOnline; }
IEnumerator EvaluateBatch(int batchIndex, Phenotype[] batch, Orientations orientation) { IList <EvaluationBehaviour> evaluations = new List <EvaluationBehaviour>(); var layout = new TransformLayout(28.0f, 18.0f, batchSize, Mathf.FloorToInt(Mathf.Sqrt(batchSize))) .GetEnumerator(); foreach (var phenotype in batch) { layout.MoveNext(); var t = PoolManager.Pools["Evaluations"].Spawn(prefab, layout.Current, Quaternion.identity, transform); var controllerBehaviour = t.GetComponent <ControllerBehaviour>(); controllerBehaviour.Network = NetworkPorts.FromGenotype(phenotype.Genotype); var evaluationBehaviour = t.GetComponent <EvaluationBehaviour>(); evaluationBehaviour.Phenotype = phenotype; evaluationBehaviour.BeginTrial(orientation, Time.time); evaluations.Add(evaluationBehaviour); } // Wait for evaluations to complete while (evaluations.Any(ev => !ev.IsComplete)) { if (BestEvaluation != null) { var ordered = evaluations.OrderByDescending(ev => ev.CurrentTrial.Fitness); var best = ordered.First(); BestEvaluation(best); } yield return(new WaitForFixedUpdate()); } // Cleanup List <Transform> children = new List <Transform>(transform.childCount); foreach (Transform child in transform) { if (child.gameObject.activeInHierarchy) { children.Add(child); } } foreach (Transform child in children) { PoolManager.Pools["Evaluations"].Despawn(child, null); } }
public DownloadManager(StateSaveConcurrentQueue <P2PFile> queue, NetworkPorts ports, ConcurrentDictionary <string, Peer> peers, Index index) { this._queue = queue; this._ports = ports; this._peers = peers; this._path = DiskHelper.GetRegistryValue("Path"); this._waitHandle = new ManualResetEvent(false); this._index = index; this._queue.ElementAddedToQueue += QueueElementAddedToQueue; _ports.GetAvailablePort(); this._fileDownloader = new FileDownloader(ports, _peers); Peer.PeerSwitchedOnline += PeerWentOnlineCheck; }
void Awake() { upper = transform.Find("Cart/Upper").GetComponent <Rigidbody2D>(); lower = transform.Find("Cart/Lower").GetComponent <Rigidbody2D>(); wheel = transform.Find("Cart/Wheel").GetComponent <Rigidbody2D>(); wheelJoint = wheel.transform.GetComponentInChildren <WheelJoint2D>(); evaluation = GetComponent <EvaluationBehaviour>(); if (json != null) { var genotype = NEAT.Genotype.FromJSON(JSON.Deserialize(json.text)); Assert.AreEqual(JSON.Serialize(genotype.ToJSON()), json.text.Trim(), "JSON should be compatible round-trip"); Network = NetworkPorts.FromGenotype(genotype); } }
public FileUploader(NetworkPorts ports, ConcurrentDictionary <string, Peer> peers) { this._ports = ports; DiskHelper.GetRegistryValue("Path"); this._peers = peers; }
public FileDeleter(ConcurrentDictionary<string, Peer> peers, NetworkPorts ports){ _peers = peers; _port = ports.GetAvailablePort(); }