/// <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); }
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)); }
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)); }
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; }
public Halt(HumanReadable hr) { HumanReadable = hr; }
public Invert(HumanReadable hr) { HumanReadable = hr; }
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)); }
public override Capability Create(string gene, StringReader genome) { var hr = new HumanReadable(HumanReadableName, gene); return(new Random(hr, seed)); }
public Static(HumanReadable hr, ulong value) { HumanReadable = hr; this.value = value; }
public override Capability Create(string gene, StringReader genome) { var hr = new HumanReadable(HumanReadableName, gene); return(new Static(hr, value)); }
public MoveForward(HumanReadable hr, Rigidbody rb) { HumanReadable = hr; this.rb = rb; }
public Eat(HumanReadable hr, Transform t, long sensitivity) { this.t = t; this.sensitivity = sensitivity; HumanReadable = hr; }
public TorqueHorizontal(HumanReadable hr, Rigidbody rb) { HumanReadable = hr; this.rb = rb; }
public override Capability Create(string gene, StringReader genome) { var hr = new HumanReadable(HumanReadableName, gene); return(new MemorySave(hr, memory)); }
public Decide(HumanReadable hr) { HumanReadable = hr; }
public MemorySave(HumanReadable hr, Memory memory) { HumanReadable = hr; this.memory = memory; }
public override Capability Create(string gene, StringReader genome) { var hr = new HumanReadable(HumanReadableName, gene); return(new TraceForward(hr, transform)); }
public FanOut(HumanReadable hr, int outputCount) { this.outputCount = outputCount; energyCost = BaseCost + (EnergyCostPerOutput * outputCount); HumanReadable = hr; }
public TraceForward(HumanReadable hr, Transform transform) { HumanReadable = hr; this.transform = transform; }
public Random(HumanReadable hr, int?seed) { HumanReadable = hr; random = seed == null ? new System.Random() : new System.Random((int)seed); }
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); }