Esempio n. 1
0
        public void DoAction(VacuumWorldState state, VacuumWorldAction action)
        {
            if (action != VacuumWorldAction.Suck)
            {
                throw new InvalidOperationException();
            }

            var squareWasClean = !state.SquareIsDirty(state.VacuumPos);

            _decoratedHandler.DoAction(state, action);

            if (squareWasClean)
            {
                if (_random.TrueWithProbability(_makeDirtyProbability))
                {
                    state.MakeSquareDirty(state.VacuumPos);
                }
            }
            else
            {
                if (_random.TrueWithProbability(_cleanExtraProbability))
                {
                    CleanRandomDirtyNeighbour(state);
                }
            }
        }
Esempio n. 2
0
        public void DoAction(VacuumWorldState state, VacuumWorldAction action)
        {
            if (action != VacuumWorldAction.Suck)
            {
                throw new InvalidOperationException();
            }

            state.CleanSquare(state.VacuumPos);
        }
Esempio n. 3
0
        public void DoAction_ShouldCallActionHandler()
        {
            var actionHandler = A.Fake <IVacuumWorldActionHandler>();
            var vacuumWorld   = new VacuumWorld(new VacuumWorldState(3), actionHandler);
            const VacuumWorldAction action = VacuumWorldAction.Up;

            vacuumWorld.DoAction(action);

            A.CallTo(() => actionHandler.DoAction(A <VacuumWorldState> ._, action)).MustHaveHappened();
        }
Esempio n. 4
0
        public void DoAction(VacuumWorldState state, VacuumWorldAction action)
        {
            if (action != VacuumWorldAction.Right)
            {
                throw new InvalidOperationException();
            }

            if (state.VacuumPos.X < state.WorldSize - 1)
            {
                state.VacuumPos = new Point2D(state.VacuumPos.X + 1, state.VacuumPos.Y);
            }
        }
Esempio n. 5
0
        public void DoAction(VacuumWorldState state, VacuumWorldAction action)
        {
            if (action != VacuumWorldAction.Up)
            {
                throw new InvalidOperationException();
            }

            if (state.VacuumPos.Y > 0)
            {
                state.VacuumPos = new Point2D(state.VacuumPos.X, state.VacuumPos.Y - 1);
            }
        }
Esempio n. 6
0
        public void DoAction(VacuumWorldState state, VacuumWorldAction action)
        {
            var handler = _actionHandlers[action];

            handler.DoAction(state, action);
        }
Esempio n. 7
0
 public void DoAction(VacuumWorldAction action)
 {
     _actionHandler.DoAction(State, action);
 }
Esempio n. 8
0
        public void NonSuckAction_ShouldReturnOneState(VacuumWorldAction action)
        {
            var potentialStates = _searchProblem.DoAction(_initialState, action).ToList();

            Assert.AreEqual(1, potentialStates.Count);
        }