编程农场迷宫代码 — 新迷宫扶墙,再刷金币
按 1.0+ 重写。新迷宫无环,左手扶墙可用。复用迷宫会出环;优先 `measure()`,或冲榜时每架无人机各解一座小迷宫。
1.0+ 迷宫规则
- 给植物施肥赚 `Items.Weird_Substance`(感染收获一半变成奇怪物质)。要先囤物质? 先刷奇怪物质
- 站在灌木上 `use_item(Items.Weird_Substance, n)` 生成 n×n 迷宫(无升级时)。有迷宫升级时,物质需求约每级翻倍——满田可用 `get_world_size() * 2**(num_unlocked(Unlocks.Mazes) - 1)`。
- 对 `Entities.Treasure` `harvest()` → 金币 = 面积 × 迷宫升级。收别处 → 迷宫消失。
- 迷宫内任意位置 `measure()` 返回宝箱坐标(1.0 起)。`can_move` / 失败的 `move` 只花 1 tick 探墙。
- 复用:对宝箱再用奇怪物质会换位(最多 300 次)并可能破墙 → **有环**。单纯扶墙在此已过时。复用**不会**比新建+收割更赚金。
入门:生成新迷宫 + 左手扶墙
python
def spawn_maze():
if get_ground_type() != Grounds.Soil:
till()
harvest()
plant(Entities.Bush)
# Beginner (no / low maze upgrades): n = world size.
# With upgrades, wiki: world_size * 2**(num_unlocked(Unlocks.Mazes) - 1)
n = get_world_size()
use_item(Items.Weird_Substance, n)
def solve_left_wall():
dirs = [North, East, South, West]
facing = 0
while get_entity_type() != Entities.Treasure:
left = (facing - 1) % 4
if can_move(dirs[left]):
facing = left
move(dirs[facing])
elif can_move(dirs[facing]):
move(dirs[facing])
else:
facing = (facing + 1) % 4
harvest()
clear()
while True:
spawn_maze()
solve_left_wall() 复用/有环迷宫:朝 measure() 坐标走
先问宝箱坐标,再带撞墙检测地走过去。冲榜仍不够,但能避免扶墙转圈。
python
def go_toward(tx, ty):
# Greedy step with can_move — enough for teaching
while get_pos_x() != tx or get_pos_y() != ty:
if get_pos_x() < tx and can_move(East):
move(East)
elif get_pos_x() > tx and can_move(West):
move(West)
elif get_pos_y() < ty and can_move(North):
move(North)
elif get_pos_y() > ty and can_move(South):
move(South)
else:
# Blocked — spin with left-wall for a bit
return False
return True
tx, ty = measure()
go_toward(tx, ty)
if get_entity_type() == Entities.Treasure:
harvest() 多无人机刷金(Reddit 2026-09)
- 通常更快:把 32×32 拆成**许多小迷宫**(如 32 个 5×5),每架无人机一座,而不是 32 机挤进一座超大迷宫。
- 路口分叉生成子机(死胡同自杀)很炫,但没法并行很多迷宫——娱乐用,不是最高金/秒。
- 排行榜迷宫目标 ≈ 301 次宝箱 × 满升级 32×32 金币——可复用 300 次**或**新建;社区捷径偏向许多短迷宫。