Example #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);
        }
Example #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));
        }
Example #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));
        }
Example #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;
        }
Example #5
0
 public Halt(HumanReadable hr)
 {
     HumanReadable = hr;
 }
Example #6
0
 public Invert(HumanReadable hr)
 {
     HumanReadable = hr;
 }
Example #7
0
        public override Capability Create(string gene, StringReader genome)
        {
            var hr = new HumanReadable(HumanReadableName, gene);

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

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

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

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

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

            return(new TraceForward(hr, transform));
        }
Example #19
0
 public FanOut(HumanReadable hr, int outputCount)
 {
     this.outputCount = outputCount;
     energyCost       = BaseCost + (EnergyCostPerOutput * outputCount);
     HumanReadable    = hr;
 }
Example #20
0
 public TraceForward(HumanReadable hr, Transform transform)
 {
     HumanReadable  = hr;
     this.transform = transform;
 }
Example #21
0
 public Random(HumanReadable hr, int?seed)
 {
     HumanReadable = hr;
     random        = seed == null ? new System.Random() : new System.Random((int)seed);
 }
Example #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);
        }