public static void Main(string[] args) { var file = new FileInfo("data.bin"); int nodeSize = 0; var collection = new NodeCollection(LoadNodes(file)); if (Log(args, collection)) { return; } if (args.Length == 0 || !Int32.TryParse(args[0], out nodeSize)) { nodeSize = 50000; } Console.Clear(); Console.WriteLine("Node size: {0:#,##0.0}k", nodeSize / 1000.0); var simulator = new Simulator(); var rnd = new MT19937Generator(); Merge(collection); var sw = Stopwatch.StartNew(); long runs = 0; var shrinks = 0; while (true) { runs++; ClearNewStatus(collection); simulator.Simulate(collection, rnd); Write(collection, sw, runs, shrinks); if ((runs & 15) == 15) { collection.Save(file); Merge(collection); } if (collection.Count > nodeSize) { var nodes = collection.ToList(); nodes.Shrink(); collection.Clear(); collection.AddRange(nodes); collection.Save(file); shrinks++; Write(collection, sw, runs, shrinks, true); } } }