public void DoAction(VacuumWorldState state, VacuumWorldAction action) { if (action != VacuumWorldAction.Suck) { throw new InvalidOperationException(); } state.CleanSquare(state.VacuumPos); }
private void CleanRandomDirtyNeighbour(VacuumWorldState state) { var adj = state.AdjacentSquares(state.VacuumPos).Where(state.SquareIsDirty).ToList(); if (adj.Count == 0) { return; } var squareToClean = _random.Choice(adj); state.CleanSquare(squareToClean); }