static int Main(string[] args) { if (!Parser.ParseArgumentsWithUsage(args, _cmdLine)) { return(1); } if (_cmdLine.DebuggerLaunch) { Debugger.Launch(); } if (_cmdLine.ChanceTrees.Length != 2) { Console.WriteLine("Can compare 2 chance trees, but was specified {0}", _cmdLine.ChanceTrees.Length); return(1); } ChanceTree[] chanceTrees = new ChanceTree[2]; for (int i = 0; i < 2; ++i) { chanceTrees[i] = ChanceTree.Read <ChanceTree>(_cmdLine.ChanceTrees[i]); } CompareChanceTrees cmp = new CompareChanceTrees { AllowDifferentStructure = _cmdLine.AllowDifferentStructure, IsVerbose = true }; cmp.Compare(chanceTrees[0], chanceTrees[1]); return(0); }
static int Main(string[] args) { if (!Parser.ParseArgumentsWithUsage(args, _cmdLine)) { return(1); } if (_cmdLine.DebuggerLaunch) { Debugger.Launch(); } ChanceTree ct = ChanceTree.Read <ChanceTree>(_cmdLine.ChanceTree); if (_cmdLine.Verify) { Console.Write("Verifying tree ..."); VerifyChanceTree.VerifyS(ct); Console.WriteLine(" OK"); } AnalyzeChanceTree.AnalyzeS(ct); return(0); }
static int Main(string[] args) { if (!Parser.ParseArgumentsWithUsage(args, _cmdLine)) { return(1); } if (_cmdLine.DebuggerLaunch) { Debugger.Launch(); } GameDefinition gd = XmlSerializerExt.Deserialize <GameDefinition>(_cmdLine.GameDef.Get(Props.Global)); string chanceTreeFile = _cmdLine.ChanceTree.Get(Props.Global); ChanceTree ct; if (string.IsNullOrEmpty(chanceTreeFile)) { ct = CreateChanceTreeByGameDef.Create(gd); } else { ct = ChanceTree.Read <ChanceTree>(chanceTreeFile); } ActionTree at = CreateActionTreeByGameDef.Create(gd); double [] values; StrategyTree [] st = EqLp.Solve(at, ct, out values); if (st == null) { Console.WriteLine("Cannot find solution"); return(1); } string output = _cmdLine.Output.Get(Props.Global); string basePath = string.IsNullOrEmpty(output) ? gd.Name : output; string baseDir = Path.GetDirectoryName(basePath); string baseName = Path.GetFileNameWithoutExtension(basePath); for (int p = 0; p < st.Length; ++p) { string fileName = Path.Combine(baseDir, string.Format("{0}-{1}.dat", baseName, p)); Console.WriteLine("Eq value pos {0}: {1}, file: {2}", p, values[p], fileName); st[p].Write(fileName); } return(0); }
static int Main(string[] args) { if (!Parser.ParseArgumentsWithUsage(args, _cmdLine)) { return(1); } if (_cmdLine.DebuggerLaunch) { Debugger.Launch(); } if (_cmdLine.DiagUnmanagedMemory) { UnmanagedMemory.IsDiagOn = true; Console.WriteLine("Unmanaged memory diagnostics is on"); } ActionTree at = ActionTree.Read <ActionTree>(_cmdLine.ActionTree); Console.WriteLine("Action tree: {0}", at.Version.ToString()); ChanceTree ct = ChanceTree.Read <ChanceTree>(_cmdLine.ChanceTree); Console.WriteLine("Chance tree: {0}", ct.Version.ToString()); StrategyTree oppSt = StrategyTree.Read <StrategyTree>(_cmdLine.OppStrategy); Console.WriteLine("Opp strategy: {0}", oppSt.Version.ToString()); // Create and configure Br solver Br br = new Br { HeroPosition = _cmdLine.HeroPosition, ChanceTree = ct, ActionTree = at, }; br.Strategies = new StrategyTree[ct.PlayersCount]; for (int opp = 0; opp < ct.PlayersCount; ++opp) { if (opp == _cmdLine.HeroPosition) { continue; } br.Strategies[opp] = oppSt; } DateTime startTime = DateTime.Now; // Solve Br br.Solve(); double time = (DateTime.Now - startTime).TotalSeconds; Console.WriteLine("Done in {0:0.0} s, BR value for hero pos {1}: {2}", time, br.HeroPosition, br.Value); string outFile = Path.Combine(Path.GetDirectoryName(_cmdLine.OppStrategy), Path.GetFileNameWithoutExtension(_cmdLine.OppStrategy)); outFile += "-br.dat"; Console.WriteLine("Writing br to {0}", outFile); br.Strategies[_cmdLine.HeroPosition].Write(outFile); return(0); }