过了35-40岁,软件开发人员真的就步入死胡同了吗?

一位即将步入35岁的软件架构师分享了他的求职经历。他发现随着年龄增长,尽管拥有丰富的经验和全面的技能,但在求职市场上却面临重重挑战。许多公司只关注特定技能,而忽视了候选人的整体价值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文链接点击打开链接

20岁出头年轻有闯劲儿,工作靠激情,哪怕工资很低也所谓;30岁出头,有阅历,有家庭,工作要靠理智,再也不能像年轻时那样无所顾忌的去拼,去闯。

本文作者 Deepak Karanth(软件架构师,敏捷开发&DevOps实践者,导师)一个刚步入而立之年的技术人员,分享了自己最近的求职经历以及自己的所得所悟。


注意限定词,是35-40岁之后。毫无疑问,对在这个年龄段之前的年轻人来说,这是一个伟大的领域。但我们都清楚的知道,阳光不会每天普照,岁月也不会永远不老。

我还没到35岁,但那也不过是一眨眼的事。

所以,也不奇怪我会想这个问题:软件开发真没什么前途了吗?

对此我想了很多,并且觉得目前为止我的事业还算成功。我一开始是做开发的,现在是做软件架构师。我做过开发,架构师,项目经理,也有团队领导经验。非技术方面,我组建过团队,亲自招过人,并对他们的弱项亲自培训等。

总之,我在软件开发领域的专业技能还是不错的,工作经验也还是挺丰富的。我喜欢参与到软件开发周期过程中的每个方面,并且帮助团队推进项目的进展(无论在技术方面,还是管理团队、创建正确的开发流程,并为开发者创造一个良好的开发氛围上)。

这些经历可以让我在找任何工作的时候都不费吹灰之力吗?你肯定想:“当然,为什么不会呢?我几乎掌握了所有技能。”好吧,开始我也是这样认为的。

最近我在找工作的时候,申请了很多家公司的职位,但大部分公司都没有发来面试邀请。通过将招聘人员的工作规范中的关键字匹配到我的简历中是很费劲的。

面试官:从事 Java?

我:是的。

面试官:使用过 Spring,J2EE?

我:Spring,是的。2004年是 J2EE,从那以后是 JavaEE。

面试官[困惑,继续面试]:Spring 的哪方面?

我:MVC,数据,安全,Spring Boot,和许多其他的[我指定列表]。

面试官:XML呢?

我[有点恼火,因为我意识到这是怎么回事了]:是的。

面试官:Wildfly 应用服务器的什么版本?

我:我用过很多天的 JBoss天,我现在在用 Wildfly 8。

面试官:哦,但你没用过 Wildfly 9?对不起,我们只找有 Wildfly 9 经验的人。[挂断电话]

对于大多数的工作,我的技能不能准确匹配他们的关键字,所以你可以想象这有多糟糕。而他们也不明白我的实际价值要比他们列出来的工作规范中的关键字要大的多。

在我接到的屈指可数的面试电话中,其中有一家只愿开很可怜的工资,找一个“只会写代码”的就行(“just the coding ”)。

也有一些公司,他们要求我进行编码测试,要我“打印一个梯子”并“找出重复的数字”。我拒绝了这些测试,不是因为傲慢,而是因为我的技能超越了他们想要找的。是的,这些角色是为软件架构师设定的。然而,他们却要我在屏幕上打印一个梯子,而不是测试我的架构和逻辑技能。

其余的公司都太远了,要花费很长时间在上下班路上,每天我都要花费5个小时的时间在火车上。因为目前我和我的家人在城镇定居,拖家带口搬家不大可能,因此我拒绝了这些面试邀请。

还没有面试我便被99%的公司拒绝了。在剩下的1%中,我找到了更多拒绝的理由。

现在,让我们回到10-12年前,那时候我才20出头。那时候我还是一个初级开发人员,单身,自由,想去看世界就去看世界,我可以选在世界上的任何工作,一份“只开发”(“just development” ),薪水又低的工作我也会做的很开心。

那么,这个故事是想告诉你什么呢?告诉你在我二十岁出头的时候是一个较好的软件工程师吗?天呐,当然不是!

现在,我三十多岁,对自己的工作总是吹毛求疵。我更关心我给公司带来的影响。我也很在乎和家人在一起的时间。

不幸的是,公司不懂。他们想要一个具备特定技能的人,而不是一个在许多领域都有着很多经验的人。我相信这是由很多因素导致的,你被公司雇来是代替之前离职的那个人的,公司希望你能够做好之前那个人的工作,仅此而已。你大部分的“额外”技能对于你所申请的角色来说是无用的。

所以,是的,在某种程度上,这个职业的人在他们三十岁以后的职业生涯中是很艰难的,至少不是因为我们缺乏能力,而是因为我们在做出每一个行动之前,有更多的事情需要考虑。不过,它是否会成为一个没有前途的工作,还要取决于你的个人情况,或者看你处事有多灵活了

<think>为了改进贪吃蛇AI以避免陷入死胡同,我们可以引入一个策略:在移动之前,检查每个安全方向移动后,蛇头周围是否有足够的空间(即自由格子数)来保证蛇能够继续存活。我们可以使用BFS(广度优先搜索)来计算某个位置周围的自由空间大小。如果某个方向移动后,蛇头周围的自由空间小于一个阈值(比如蛇的长度),那么我们就避免选择这个方向,即使它可能更靠近食物。 改进思路: 1. 在安全方向的基础上,增加一个自由空间检查。 2. 计算每个安全方向移动后蛇头位置周围的自由空间(不包括蛇的身体)。 3. 如果自由空间小于蛇的长度(或一个设定的阈值),则避免选择该方向,除非没有其他选择。 4. 在剩下的安全方向中,选择最靠近食物的方向。 注意:由于贪吃蛇的移动特性,蛇尾会移动,所以自由空间的计算可以相对宽松。但为了避免进入封闭区域,我们仍需要一定的安全空间。 步骤: 1. 定义自由空间计算函数(使用BFS)。 2. 在决策过程中,对每个安全方向进行自由空间检查。 3. 根据自由空间大小过滤方向。 4. 如果所有安全方向自由空间都不足,则选择自由空间最大的方向(避免立即死亡)。 我们将修改`SnakeAI`类,添加一个`calculate_free_space`方法,并在`decide_direction`方法中使用它。 由于计算自由空间可能比较耗时,我们设定一个最大搜索步数(例如,我们不需要计算整个地图,只需要计算一定范围内的格子,比如最大步数为蛇的长度或地图大小的一半)。 以下是改进后的代码:</think># 改进贪吃蛇AI以避免陷入死胡同 要改进贪吃蛇AI以避免陷入死胡同,我们需要实现更智能的路径规划和风险评估。以下是几种有效的方法及其实现代码: ## 1. 死胡同检测算法 ```python def is_dead_end(self, position, snake_positions): """检测当前位置是否是死胡同""" # 计算当前位置周围的可用空间 visited = set() queue = [position] free_spaces = 0 while queue: x, y = queue.pop(0) if (x, y) in visited: continue visited.add((x, y)) free_spaces += 1 # 如果找到足够空间,提前退出 if free_spaces >= self.snake.length: return False # 检查四个方向 for dx, dy in [(0, 1), (1, 0), (0, -1), (-1, 0)]: new_x = (x + dx) % GRID_WIDTH new_y = (y + dy) % GRID_HEIGHT new_pos = (new_x, new_y) # 如果新位置安全且未访问过 if new_pos not in snake_positions and new_pos not in visited: queue.append(new_pos) # 如果可用空间不足,则认为是死胡同 return free_spaces < self.snake.length ``` ### 算法解释: 1. 使用BFS算法计算从给定位置可达的网格数量 2. 如果可达网格数量小于蛇的长度,则认为是死胡同 3. 在决策时避免进入死胡同区域 ## 2. 增强的AI决策算法 ```python def enhanced_decide_direction(self, food_pos): """增强的AI决策算法,避免死胡同""" head = self.snake.get_head_position() safe_directions = self.get_safe_directions() # 如果没有安全方向,保持原方向 if not safe_directions: self.snake.decision_reason = "无安全方向,保持原方向" return self.snake.direction # 1. 尝试直接吃到食物 for direction in safe_directions: new_pos = self.calculate_new_position(head, direction) if new_pos == food_pos: self.snake.decision_reason = "直接吃到食物" return direction # 2. 评估每个方向的安全性 direction_scores = {} for direction in safe_directions: new_pos = self.calculate_new_position(head, direction) score = 0 # 计算食物距离分数 food_dist = self.calculate_distance(new_pos, food_pos) score += (GRID_WIDTH + GRID_HEIGHT - food_dist) * 2 # 距离越近分数越高 # 计算自由空间分数 free_space = self.calculate_free_space(new_pos) score += free_space * 1.5 # 死胡同惩罚 if self.is_dead_end(new_pos, self.snake.positions + [new_pos]): score -= 100 # 避免靠近身体 body_dist = min(self.calculate_distance(new_pos, body) for body in self.snake.positions[1:] if body != new_pos) score += max(0, body_dist - 2) * 0.5 direction_scores[direction] = score # 3. 选择最高分数的方向 best_direction = max(direction_scores, key=direction_scores.get) self.snake.decision_reason = f"最佳选择 (分数: {direction_scores[best_direction]:.1f})" return best_direction ``` ### 算法特点: 1. **多因素评分系统**:考虑食物距离、自由空间、身体距离等因素 2. **死胡同检测**:使用`is_dead_end`方法避免进入死胡同 3. **自由空间计算**:评估移动后的可用空间 4. **安全距离**:保持与身体的安全距离 ## 3. 完整改进的AI类 ```python class EnhancedSnakeAI: def __init__(self, snake): self.snake = snake self.path = [] # 存储计算出的路径 def get_safe_directions(self): """获取所有安全的方向(不会立即撞到自身)""" head = self.snake.get_head_position() safe_directions = [] for direction in [UP, DOWN, LEFT, RIGHT]: new_pos = self.calculate_new_position(head, direction) if new_pos not in self.snake.positions[1:]: safe_directions.append(direction) return safe_directions def calculate_new_position(self, position, direction): """计算移动后的新位置""" x, y = position dx, dy = direction return ((x + dx) % GRID_WIDTH, (y + dy) % GRID_HEIGHT) def calculate_distance(self, pos1, pos2): """计算两点之间的曼哈顿距离(考虑边界循环)""" dx = min(abs(pos1[0] - pos2[0]), GRID_WIDTH - abs(pos1[0] - pos2[0])) dy = min(abs(pos1[1] - pos2[1]), GRID_HEIGHT - abs(pos1[1] - pos2[1])) return dx + dy def calculate_free_space(self, position): """计算从给定位置开始的自由空间大小""" visited = set() queue = [position] while queue: x, y = queue.pop(0) if (x, y) in visited: continue visited.add((x, y)) # 检查四个方向 for dx, dy in [(0, 1), (1, 0), (0, -1), (-1, 0)]: new_x = (x + dx) % GRID_WIDTH new_y = (y + dy) % GRID_HEIGHT new_pos = (new_x, new_y) # 如果新位置安全且未访问过 if (new_pos not in self.snake.positions and new_pos not in visited): queue.append(new_pos) return len(visited) def is_dead_end(self, position, snake_positions=None): """检测当前位置是否是死胡同""" if snake_positions is None: snake_positions = self.snake.positions # 计算自由空间 free_space = self.calculate_free_space(position) # 如果自由空间小于蛇的长度,认为是死胡同 return free_space < self.snake.length * 0.8 def find_path_to_food(self): """使用A*算法寻找食物路径""" head = self.snake.get_head_position() food_pos = self.food.position # 使用A*算法寻找路径 open_set = [] heapq.heappush(open_set, (0, head)) came_from = {} g_score = {head: 0} f_score = {head: self.calculate_distance(head, food_pos)} while open_set: current = heapq.heappop(open_set)[1] if current == food_pos: # 重建路径 path = [] while current in came_from: path.append(current) current = came_from[current] return path[::-1] # 反转路径 for dx, dy in [(0, 1), (1, 0), (0, -1), (-1, 0)]: neighbor = ((current[0] + dx) % GRID_WIDTH, (current[1] + dy) % GRID_HEIGHT) # 跳过蛇身位置 if neighbor in self.snake.positions: continue # 计算新的g分数 tentative_g_score = g_score[current] + 1 if neighbor not in g_score or tentative_g_score < g_score[neighbor]: came_from[neighbor] = current g_score[neighbor] = tentative_g_score f_score[neighbor] = tentative_g_score + self.calculate_distance(neighbor, food_pos) heapq.heappush(open_set, (f_score[neighbor], neighbor)) return None # 没有找到路径 def decide_direction(self, food_pos): """最终决策算法""" self.food = food_pos # 存储食物位置 # 尝试寻找路径到食物 path = self.find_path_to_food() if path and len(path) > 1: next_pos = path[0] head = self.snake.get_head_position() # 确定方向 dx = (next_pos[0] - head[0]) % GRID_WIDTH dy = (next_pos[1] - head[1]) % GRID_HEIGHT # 映射到方向常量 if dx == 1 or dx == -GRID_WIDTH + 1: direction = RIGHT elif dx == -1 or dx == GRID_WIDTH - 1: direction = LEFT elif dy == 1 or dy == -GRID_HEIGHT + 1: direction = DOWN else: direction = UP # 检查方向是否安全 if direction in self.get_safe_directions(): self.snake.decision_reason = "A*路径规划" return direction # 如果路径规划失败,使用增强的评分系统 return self.enhanced_decide_direction(food_pos) ``` ## 4. 算法整合与优化 ### 4.1 路径规划与风险评估结合 ```python def enhanced_decide_direction(self, food_pos): """结合路径规划和风险评估的决策算法""" head = self.snake.get_head_position() safe_directions = self.get_safe_directions() # 如果没有安全方向,保持原方向 if not safe_directions: self.snake.decision_reason = "无安全方向,保持原方向" return self.snake.direction # 1. 尝试直接吃到食物 for direction in safe_directions: new_pos = self.calculate_new_position(head, direction) if new_pos == food_pos: self.snake.decision_reason = "直接吃到食物" return direction # 2. 评估每个方向的安全性 direction_scores = {} for direction in safe_directions: new_pos = self.calculate_new_position(head, direction) score = 0 # 食物距离分数(距离越近分数越高) food_dist = self.calculate_distance(new_pos, food_pos) score += (GRID_WIDTH + GRID_HEIGHT - food_dist) * 2 # 自由空间分数(空间越大分数越高) free_space = self.calculate_free_space(new_pos) score += min(free_space, 50) * 1.5 # 限制最大加分 # 死胡同惩罚 if self.is_dead_end(new_pos, self.snake.positions + [new_pos]): score -= 100 # 身体距离奖励(保持安全距离) if self.snake.length > 5: min_body_dist = min(self.calculate_distance(new_pos, body) for body in self.snake.positions[1:-5] # 忽略尾部 if body != new_pos) score += max(0, min_body_dist - 3) * 0.8 # 路径平滑度(避免频繁改变方向) if direction == self.snake.direction: score += 5 direction_scores[direction] = score # 3. 选择最高分数的方向 best_direction = max(direction_scores, key=direction_scores.get) reason = f"评分选择 ({direction_scores[best_direction]:.1f})" # 4. 最终安全检查 if direction_scores[best_direction] < 0: # 如果所有方向分数都很低,选择最安全的方向 best_direction = max(safe_directions, key=lambda d: self.calculate_free_space( self.calculate_new_position(head, d))) reason = "紧急避险" self.snake.decision_reason = reason return best_direction ``` ### 4.2 关键优化点 1. **路径规划**:使用A*算法寻找最优路径 2. **自由空间计算**:评估移动后的可用空间 3. **动态风险评估**:根据蛇的长度调整策略 4. **多因素评分系统**:综合考虑食物距离、自由空间、身体距离等因素 5. **紧急避险机制**:当所有方向评分都很低时,选择自由空间最大的方向 ## 5. 实际应用效果 这种改进的AI系统能够: 1. 有效识别并避免死胡同 2. 在复杂环境中找到安全路径 3. 平衡食物获取和安全移动 4. 适应不同长度的蛇身 5. 在无法找到理想路径时执行安全策略
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值