static int Main(string[] args) { if (!Parser.ParseArgumentsWithUsage(args, _cmdLine)) { return(1); } if (_cmdLine.DebuggerLaunch) { Debugger.Launch(); } CtMcGen.Tree input = new CtMcGen.Tree(); input.Read(_cmdLine.Input); long leavesCount = input.CalculateLeavesCount(); Console.WriteLine("Input file: leaves: {0:#,#}, samples: {1:#,#}, av. samples: {2:#,#}", leavesCount, input.SamplesCount, input.SamplesCount / (ulong)leavesCount); ChanceTree ct = input.ConvertToChanceTree(); ct.Write(_cmdLine.Output); return(0); }
/// <summary> /// Runs FictitiousPlay with the specified parameters. /// Some parameters are set by default (e.g. verbosity), the caller has a chance to overwrite them /// using Configure delegate. /// </summary> public StrategyTree[] Solve(ActionTree at, ChanceTree ct) { int playersCount = 2; DirectoryExt.Delete(BaseDir); Directory.CreateDirectory(BaseDir); string inputDir = Path.Combine(BaseDir, "input"); Directory.CreateDirectory(inputDir); string traceDir = Path.Combine(BaseDir, "trace"); string chanceTreeFile = Path.Combine(inputDir, "ct.dat"); string actionTreeFile = Path.Combine(inputDir, "at.dat"); ct.Write(chanceTreeFile); at.Write(actionTreeFile); if (VisualizeTrees) { VisActionTree.Show(at, actionTreeFile + ".gv"); VisChanceTree.Show(ct, chanceTreeFile + ".gv"); } Solver.ChanceTreeFile = chanceTreeFile; Solver.EqualCa = false; Solver.ActionTreeFile = actionTreeFile; Solver.OutputPath = BaseDir; Solver.SnapshotsCount = 2; Solver.Epsilon = Epsilon; Solver.ThreadsCount = 6; Solver.IsVerbose = true; Solver.IterationVerbosity = 10000; Solver.MaxIterationCount = 1000000000; if (Configure != null) { Configure(Solver); } Solver.Solve(); StrategyTree[] eqStrategies = new StrategyTree[playersCount]; for (int p = 0; p < playersCount; ++p) { string fileName = Solver.CurrentSnapshotInfo.StrategyFile[p]; eqStrategies[p] = StrategyTree.Read <StrategyTree>(fileName); if (VisualizeTrees) { VisStrategyTree.Show(eqStrategies[p], fileName + ".gv"); } } return(eqStrategies); }