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); } } }
public void DoAction(VacuumWorldState state, VacuumWorldAction action) { if (action != VacuumWorldAction.Suck) { throw new InvalidOperationException(); } state.CleanSquare(state.VacuumPos); }
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(); }
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); } }
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); } }
public void DoAction(VacuumWorldState state, VacuumWorldAction action) { var handler = _actionHandlers[action]; handler.DoAction(state, action); }
public void DoAction(VacuumWorldAction action) { _actionHandler.DoAction(State, action); }
public void NonSuckAction_ShouldReturnOneState(VacuumWorldAction action) { var potentialStates = _searchProblem.DoAction(_initialState, action).ToList(); Assert.AreEqual(1, potentialStates.Count); }