コード例 #1
0
        public KakuBoxMovingStep(KakuBoxState state, int movingBoxIndex, BoxMovingDirection boxMovingDirection)
            : base(state, movingBoxIndex, boxMovingDirection)
        {
            var movingBox = state[movingBoxIndex];

            switch (boxMovingDirection)
            {
            case BoxMovingDirection.Up:
                kakuPushingPoint = new Point(movingBox.X, movingBox.Y - 1);
                break;

            case BoxMovingDirection.Down:
                kakuPushingPoint = new Point(movingBox.X, movingBox.Y + 1);
                break;

            case BoxMovingDirection.Left:
                kakuPushingPoint = new Point(movingBox.X + 1, movingBox.Y);
                break;

            case BoxMovingDirection.Right:
                kakuPushingPoint = new Point(movingBox.X - 1, movingBox.Y);
                break;

            default: break;
            }
        }
コード例 #2
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);
        }
コード例 #3
0
        public override bool Equals(Object obj)
        {
            KakuBoxState s = obj as KakuBoxState;

            if (object.ReferenceEquals(s, null))
            {
                return(false);
            }

            return(kaku == s.kaku && base.Equals(obj));
        }