Пример #1
0
        private static IEnumerable <ProjectedMove> AllProjectedMoves(StackTypeMeasurementSet initial,
                                                                     BitMeasurement blocks, bool isRed)
        {
            foreach (var loc in State.AllBoardLocations)
            {
                if (!initial.AnyPiece(loc))
                {
                    continue;
                }

                foreach (var move in Movement.AllMoves)
                {
                    var one   = initial.AnyOneStack(loc);
                    var two   = initial.AnyTwoStack(loc);
                    var three = initial.AnyThreeStack(loc);
                    var four  = initial.AnyFourStack(loc);
                    var five  = initial.AnyFiveStack(loc);

                    if (one || two || three || four || five)
                    {
                        foreach (var pm in MoveGenerator(loc, 1, move, blocks, isRed))
                        {
                            yield return(pm);
                        }
                    }

                    if (two || three || four || five)
                    {
                        foreach (var pm in MoveGenerator(loc, 2, move, blocks, isRed))
                        {
                            yield return(pm);
                        }
                    }

                    if (three || four || five)
                    {
                        foreach (var pm in MoveGenerator(loc, 3, move, blocks, isRed))
                        {
                            yield return(pm);
                        }
                    }

                    if (four || five)
                    {
                        foreach (var pm in MoveGenerator(loc, 4, move, blocks, isRed))
                        {
                            yield return(pm);
                        }
                    }

                    if (five)
                    {
                        foreach (var pm in MoveGenerator(loc, 5, move, blocks, isRed))
                        {
                            yield return(pm);
                        }
                    }
                }
            }
        }
Пример #2
0
        private static BitMeasurement AddDrops(BitMeasurement normalSingles, BitMeasurement blocks, State initialState,
                                               bool isRed)
        {
            var home = isRed ? initialState.RedHome : initialState.BlueHome;

            foreach (var move in Movement.AllMoves)
            {
                var dropTarget = move(home, Movement.Blue.CannotWrap, Movement.Red.CannotWrap, Movement.UnmarkedEdges.CannotWrap);
                if (!Movement.IsValidLocation(dropTarget))
                {
                    continue;
                }
                if (normalSingles[dropTarget] || blocks[dropTarget])
                {
                    continue;
                }
                if (initialState[dropTarget].IsPiece() && initialState[dropTarget].RedPiece() != isRed)
                {
                    continue;
                }
                normalSingles[dropTarget] = true;
            }

            return(normalSingles);
        }
Пример #3
0
        private static StackTypeMeasurementSet Project(StackTypeMeasurementSet initial, BitMeasurement blocks, bool isRed)
        {
            var next = initial;

            foreach (var pm in AllProjectedMoves(initial, blocks, isRed))
            {
                //Returned moves start from a self-owned piece and don't pass over any blockades -- that's all we know.
                //Options are move, merge, split-move, split-merge.
                if (initial.AnyPiece(pm.To))
                {
                }
            }

            return(next);
        }
Пример #4
0
        private static IEnumerable <ProjectedMove> MoveGenerator(Location loc, int size,
                                                                 Movement.Mover mover, BitMeasurement blocks, bool isRed)
        {
            var tPrev = loc;

            for (var i = 1; i <= size; i++)
            {
                var tCur = mover(tPrev, isRed ? Movement.Blue.CanWrap : Movement.Blue.CannotWrap, isRed ? Movement.Red.CannotWrap : Movement.Red.CanWrap, Movement.UnmarkedEdges.CannotWrap);
                if (!Movement.IsValidLocation(tCur) || blocks[tCur])
                {
                    yield break;
                }
                yield return(new ProjectedMove
                {
                    From = loc, Size = size, To = tCur,
                    Wrap = !Movement.IsValidLocation(mover(tPrev, Movement.Blue.CannotWrap, Movement.Red.CannotWrap,
                                                           Movement.UnmarkedEdges.CannotWrap))
                });

                tPrev = tCur;
            }
        }