Exemplo n.º 1
0
        /// <summary>
        /// Check to see whether file is mirrored in target folder
        /// </summary>
        /// <param name="file"></param>
        /// <param name="destination"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        static public bool FileIsMirroredAt(FileData file, string destination, Options options)
        {
            DirectoryInfo dir = new DirectoryInfo(destination);

            if (dir.Exists == false)
            {
                return(false);
            }

            if (options.ignoreExtension)
            {
                var pattern = String.Format("{0}.*", Path.GetFileNameWithoutExtension(file.Name));

                var matchingFiles = dir.EnumerateFiles(pattern, SearchOption.TopDirectoryOnly);

                if (matchingFiles.Any() == false)
                {
                    return(false);
                }

                if (options.ignoreSize == false)
                {
                    if (matchingFiles.Any(f => f.Length == file.Length) == false)
                    {
                        file.Notes = String.Format("No matching file sizes : {0}", HumanReadable.Size(file.Length));
                        return(false);
                    }
                }
            }
            else
            {
                string target = Path.Combine(destination, file.Name);

                // Check if file exists (should check size too)
                if (File.Exists(target) == false)
                {
                    return(false);
                }

                if (options.ignoreSize == false)
                {
                    FileData targetFile = new FileData(target, null);
                    if (targetFile.Length != file.Length)
                    {
                        file.Notes = String.Format("Size mismatch: {0} -> {1}", HumanReadable.Size(file.Length), HumanReadable.Size(targetFile.Length));
                        return(false);
                    }
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        public override Capability Create(string gene, StringReader genome)
        {
            var c              = genome.Read();
            var outputCount    = 2;
            var geneParameters = "";

            if (c != -1)
            {
                var parameter = (char)c;
                geneParameters += parameter;
                outputCount    += Math.Min(dialect.IndexOf(parameter) + 0, maxOutputs);
            }

            var hr = new HumanReadable(HumanReadableName, gene, new[] { $"{outputCount}" }, geneParameters);

            return(new FanOut(hr, outputCount));
        }
Exemplo n.º 3
0
        public override Capability Create(string gene, StringReader genome)
        {
            var   c              = genome.Read();
            float multiplier     = 0;
            var   geneParameters = "";

            if (c != -1)
            {
                var parameter = (char)c;
                geneParameters += parameter;
                multiplier      = (dialect.IndexOf(parameter) / (float)(dialect.Count - 1));
            }

            var sensitivity = (long)(maxSensitivity * multiplier);
            var hr          = new HumanReadable(HumanReadableName, gene, new[] { $"{sensitivity}" }, geneParameters);

            return(new Eat(hr, transform, sensitivity));
        }
Exemplo n.º 4
0
        public Reproduce(HumanReadable hr, Transform t, long copyCost)
        {
            HumanReadable = hr;
            this.t        = t;
            this.copyCost = (ulong)Math.Abs(copyCost);
            parent        = t.gameObject.GetComponent <Organism>();
            var groupName = $"Gen{parent.Config.Generation + 1}";
            var genGo     = GameObject.Find(groupName);

            if (genGo != null)
            {
                genGroup = genGo.transform;
                return;
            }
            var go = new GameObject {
                name = groupName
            };

            go.transform.SetParent(t.parent.parent);
            genGroup = go.transform;
        }
Exemplo n.º 5
0
 public Halt(HumanReadable hr)
 {
     HumanReadable = hr;
 }
Exemplo n.º 6
0
 public Invert(HumanReadable hr)
 {
     HumanReadable = hr;
 }
Exemplo n.º 7
0
        public override Capability Create(string gene, StringReader genome)
        {
            var hr = new HumanReadable(HumanReadableName, gene);

            return(new Reproduce(hr, transform, copyCost));
        }
Exemplo n.º 8
0
        public override Capability Create(string gene, StringReader genome)
        {
            var hr = new HumanReadable(HumanReadableName, gene);

            return(new TorqueHorizontal(hr, rb));
        }
Exemplo n.º 9
0
        public override Capability Create(string gene, StringReader genome)
        {
            var hr = new HumanReadable(HumanReadableName, gene);

            return(new Random(hr, seed));
        }
Exemplo n.º 10
0
 public Static(HumanReadable hr, ulong value)
 {
     HumanReadable = hr;
     this.value    = value;
 }
Exemplo n.º 11
0
        public override Capability Create(string gene, StringReader genome)
        {
            var hr = new HumanReadable(HumanReadableName, gene);

            return(new Static(hr, value));
        }
Exemplo n.º 12
0
 public MoveForward(HumanReadable hr, Rigidbody rb)
 {
     HumanReadable = hr;
     this.rb       = rb;
 }
Exemplo n.º 13
0
 public Eat(HumanReadable hr, Transform t, long sensitivity)
 {
     this.t           = t;
     this.sensitivity = sensitivity;
     HumanReadable    = hr;
 }
Exemplo n.º 14
0
 public TorqueHorizontal(HumanReadable hr, Rigidbody rb)
 {
     HumanReadable = hr;
     this.rb       = rb;
 }
Exemplo n.º 15
0
        public override Capability Create(string gene, StringReader genome)
        {
            var hr = new HumanReadable(HumanReadableName, gene);

            return(new MemorySave(hr, memory));
        }
Exemplo n.º 16
0
 public Decide(HumanReadable hr)
 {
     HumanReadable = hr;
 }
Exemplo n.º 17
0
 public MemorySave(HumanReadable hr, Memory memory)
 {
     HumanReadable = hr;
     this.memory   = memory;
 }
Exemplo n.º 18
0
        public override Capability Create(string gene, StringReader genome)
        {
            var hr = new HumanReadable(HumanReadableName, gene);

            return(new TraceForward(hr, transform));
        }
Exemplo n.º 19
0
 public FanOut(HumanReadable hr, int outputCount)
 {
     this.outputCount = outputCount;
     energyCost       = BaseCost + (EnergyCostPerOutput * outputCount);
     HumanReadable    = hr;
 }
Exemplo n.º 20
0
 public TraceForward(HumanReadable hr, Transform transform)
 {
     HumanReadable  = hr;
     this.transform = transform;
 }
Exemplo n.º 21
0
 public Random(HumanReadable hr, int?seed)
 {
     HumanReadable = hr;
     random        = seed == null ? new System.Random() : new System.Random((int)seed);
 }
Exemplo n.º 22
0
        public string GetStatusString(Options options)
        {
            string statusString = "";

            if (CurrentFolder != null)
            {
                FolderData dir = CurrentFolder;
                if (dir != null && Directory.Exists(dir.FullName))
                {
                    statusString = String.Format("{0} [ {1} folders, {2} files, {3}]", dir.FullName, dir.NumDirectories, dir.NumFiles, HumanReadable.Size(CurrentFolderSize));
                }
            }
            else
            {
                statusString = options.sourcePath;
            }

            if (ScanRequest)
            {
                statusString += "<...scanning...>";
            }
            else
            {
                if (m_numCheckedFolders > 0 || m_numCheckedFiles > 0)
                {
                    statusString += String.Format("   Selected Folders: {0} ({2} in {1} files) ", m_numCheckedFolders, m_numCheckedFiles, HumanReadable.Size(m_checkedFoldersSize));
                }
            }

            statusString += String.Format("     Filters: [{0}]", options.Filters);

            return(statusString);
        }