private void MakeMove() { var neighourhood = new Neighbourhood(board[x, y + 1], board[x, y - 1], board[x + 1, y], board[x - 1, y], board[x, y]); void MakeMove(Move move) { switch (move) { case Move.North: if (neighourhood.North == Cell.Wall) { score -= 5; } else { y += 1; } return; case Move.East: if (neighourhood.East == Cell.Wall) { score -= 5; } else { x += 1; } return; case Move.South: if (neighourhood.South == Cell.Wall) { score -= 5; } else { y -= 1; } return; case Move.West: if (neighourhood.West == Cell.Wall) { score -= 5; } else { x -= 1; } return; case Move.Pickup: if (neighourhood.Current == Cell.Can) { score += 10; } else { score -= 1; } board[x, y] = Cell.Empty; return; case Move.Stay: return; case Move.Random: MakeMove(MoveHelpers.GetRandomDirection()); return; default: throw new ArgumentOutOfRangeException(nameof(move), move, null); } } MakeMove(cleaner.Move(neighourhood)); }