protected override int GetHandledCaseNumber(SuperSlimBoard b, BreakerChoiceInfo bc)
        {
            var childBoard = new SuperSlimBoard(b._trace, bc.Alpha, bc.Beta, bc.Response, b._stackCount);

            if (Cases[0].Boards.Contains(childBoard))
            {
                return(1);
            }

            return(Cases.Skip(1).IndicesWhere(cc => cc.Boards.SelectMany(bb => new[] { bb }.Union(_permutationLinked[bb].Select(tup => tup.Item2))).Contains(childBoard)).First() + 2);
        }
Ejemplo n.º 2
0
        public static string ToPartitionId(this SuperSlimBoard board, List <List <int> > partition)
        {
            var xyz = board.Stacks.Value.Select(stack =>
            {
                var s = stack.ToXYZ();
                if (s.Length <= 0)
                {
                    return("*");
                }
                return(s);
            }).ToList();

            return(xyz.ToPartitionId(partition));
        }
Ejemplo n.º 3
0
        public Graphs.Graph BuildWinTree(Graphs.Graph g, SuperSlimMind mind, SuperSlimBoard board, Bijection <int, string> numbering)
        {
            var tree = mind.BuildGameTree(board, true);
            var gg   = g.Clone();

            foreach (var v in gg.Vertices)
            {
                v.X = v.X / Scale;
                v.Y = v.Y / Scale;
            }

            var bounds  = new Bounds(gg);
            var potSize = board.Stacks.Value.SelectMany(l => l.ToSet()).Distinct().Count();
            var treeG   = BuildWinTree(tree, g, mind, bounds, 0, numbering, new Choosability.Utility.Permutation(Enumerable.Range(0, potSize).ToList()), null, potSize);

            return(treeG);
        }
Ejemplo n.º 4
0
        static string GetProgolStatement(SuperSlimBoard b)
        {
            return("good(" + string.Join(",", b.Stacks.Value.Select(l => string.Join("", l.ToSet()))
                                         .Where(s => s.Length == 2)
                                         .Select(s =>
            {
                switch (s)
                {
                case "01":
                    return "0";

                case "02":
                    return "1";

                case "12":
                    return "2";
                }

                return "?";
            })) + ").");
        }
Ejemplo n.º 5
0
 public void AddBoard(SuperSlimBoard board)
 {
     Boards.Add(board);
 }
Ejemplo n.º 6
0
        protected virtual int GetHandledCaseNumber(SuperSlimBoard b, BreakerChoiceInfo bc)
        {
            var childBoard = new SuperSlimBoard(b._trace, bc.Alpha, bc.Beta, bc.Response, b._stackCount);

            return(Cases.IndicesWhere(cc => cc.Boards.Contains(childBoard)).First() + 1);
        }
        string ToListString(SuperSlimBoard b, out Permutation pp)
        {
            var stacks = b.Stacks.Value.Select(l => l.ToSet()).Where(s => s.Count < _maxPot).ToList();

            return(ApplyOrderFilter(string.Join("|", stacks.Select(s => string.Join("", s.OrderBy(x => x)))), out pp));
        }
        string ToListString(SuperSlimBoard b)
        {
            Permutation pp;

            return(ToListString(b, out pp));
        }
        List <int> ToListIndices(SuperSlimBoard b)
        {
            var stacks = b.Stacks.Value.Select(l => l.ToSet()).Where(s => s.Count < _maxPot).ToList();

            return(stacks.Select(s => _possibleLists.FirstIndex(ss => ss.SequenceEqual(s))).ToList());
        }
Ejemplo n.º 10
0
        string GetChildBoardName(SuperSlimBoard b, BreakerChoiceInfo bc)
        {
            var childBoard = new SuperSlimBoard(b._trace, bc.Alpha, bc.Beta, bc.Response, b._stackCount);

            return(ToListString(childBoard));
        }
Ejemplo n.º 11
0
 public static int GetXYZIndex(this int i, SuperSlimBoard b)
 {
     return(b.Stacks.Value.Take(i + 1).Count(ss => ss.PopulationCount() == 2) - 1);
 }
Ejemplo n.º 12
0
        public static string ToCompactedPartitionId(this SuperSlimBoard board, List <List <int> > partition)
        {
            var xyz = board.Stacks.Value.Select(ToXYZ).ToList();

            return(xyz.ToPartitionId(partition));
        }
Ejemplo n.º 13
0
 public static List <int> To012(this SuperSlimBoard board)
 {
     return(board.Stacks.Value.Select(To012).Where(x => x >= 0).ToList());
 }
Ejemplo n.º 14
0
 public static string ToXYZ(this SuperSlimBoard board)
 {
     return(string.Join("", board.Stacks.Value.Select(ToXYZ)));
 }
Ejemplo n.º 15
0
 public static int GetActiveListIndex(this int i, SuperSlimBoard b, int maxPot)
 {
     return(b.Stacks.Value.Take(i + 1).Count(ss => ss.PopulationCount() < maxPot) - 1);
 }