public static bool Verify(ActionTree at, ChanceTree ct, StrategyTree[] strategies, double epsilon, out string message) { message = ""; // No need to check preconditions, GameValue does it GameValue gv = new GameValue { ActionTree = at, ChanceTree = ct, Strategies = strategies }; gv.Solve(); for (int p = 0; p < at.PlayersCount; ++p) { StrategyTree[] strategiesCopy = (StrategyTree[])strategies.Clone(); Br br = new Br { ActionTree = at, ChanceTree = ct, Strategies = strategiesCopy, HeroPosition = p }; br.Solve(); if (!FloatingPoint.AreEqual(gv.Values[p], br.Value, epsilon)) { message = String.Format("Unequal values for pos {0}: eq: {1}, br: {2}, eps: {3}", p, gv.Values[p], br.Value, epsilon); return(false); } } return(true); }
public static void Show(Br solver, string fileName) { StrategyTree t = solver.Strategies[solver.HeroPosition]; using (TextWriter w = new StreamWriter(File.Open(fileName, FileMode.Create))) { Vis vis = new Vis { Output = w, Solver = solver }; vis.Show(t); } }