예제 #1
0
        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();
                }
            }
        }
예제 #2
0
 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;
 }
예제 #3
0
 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);
 }
예제 #4
0
        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;
        }
예제 #5
0
    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);
        }
    }
예제 #6
0
        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;
        }
예제 #7
0
    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);
        }
    }
예제 #8
0
 public FileUploader(NetworkPorts ports, ConcurrentDictionary <string, Peer> peers)
 {
     this._ports = ports;
     DiskHelper.GetRegistryValue("Path");
     this._peers = peers;
 }
예제 #9
0
 public FileDeleter(ConcurrentDictionary<string, Peer> peers, NetworkPorts ports){
     _peers = peers;
     _port = ports.GetAvailablePort();
 }