Esempio n. 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 = new ExtendedMap(this.map, find.Boxs);

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

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

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

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

            var newMap = new ExtendedMap(this.map, thisStep.Orignal.Boxs);

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

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

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