Example #1
0
        public bool Check(BoxMovingStep movingStep)
        {
            KakuBoxState state = (KakuBoxState)movingStep.Final;

            var finds = queue.FindSameBoxState(state);

            if (finds.Count > 0)
            {
                foreach (var find in finds)
                {
                    if (find.Kaku.Equals(state.Kaku))
                    {
                        return(false);
                    }
                    else
                    {
                        var newMap = map.Clone();

                        newMap.Barriers.AddRange(find.Copy());

                        PointToPointPathFinder pathFinder = new PointToPointPathFinder(newMap, find.Kaku);

                        if (pathFinder.HasPath(state.Kaku))
                        {
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
Example #2
0
        public bool Check(BoxMovingStep movingStep)
        {
            KakuBoxMovingStep thisStep = movingStep as KakuBoxMovingStep;

            if (thisStep == null)
            {
                throw new InvalidOperationException("KakuMovingCheckPolicy only check KakuBoxMovingStep.");
            }

            if (((KakuBoxState)thisStep.Orignal).Kaku == thisStep.KakuPushingPoint)
            {
                return(true);
            }

            var newMap = map.Clone();

            newMap.Barriers.AddRange(thisStep.Orignal.Copy());

            if (!newMap.IsValidPoint(thisStep.kakuPushingPoint))
            {
                return(false);
            }

            PointToPointPathFinder pathFinder = new PointToPointPathFinder(newMap, ((KakuBoxState)thisStep.Orignal).Kaku);

            return(pathFinder.HasPath(thisStep.KakuPushingPoint));
        }