编程农场手机版介绍
编程农场手机版,英文名称the farmer was replaced,又称农夫被替换了,《编程农场》是一款创意十足的编程模拟经营游戏,玩家需要通过编写代码指挥无人机完成翻土、播种、浇水和收获等农场工作。随着编程农场手机版的进度推进,可以解锁更多资源、种植玩法和自动化功能,还能探索地下矿场、挑战各种编程难题。游戏融合农场经营与编程学习,让玩家在趣味挑战中体验自动化管理的乐趣。
►编程农场手机版官方网站:https://www.metaroot.ch/press-kit/the-farmer-was-replaced
1、鲶鱼软件站下载游戏
2、进入游戏后,点击左侧options;
3、接着找到language,点击右侧English切换语言为简体中文;
4、设置好中文后返回,点击开始,玩家需通过编辑代码的方式来模拟经营农场;
5、点击右上角i可查看相应的编辑代码;
6、另外,玩家还可通过收货的农作物来加点科技树,以此更好地模拟农场发展。
1. 干草
# Hay farm with polyculture and multiple drones
clear()
world_size = get_world_size()
change_hat(Hats.Brown_Hat)
companion_mapping = {}
hay_mapping = {}
def track_companion(curr_x, curr_y):
global companion_mapping
global hay_mapping
result = get_companion()
if result == None:
return False
target_entity, (target_x, target_y) = result
if (target_x, target_y) not in companion_mapping:
companion_mapping[(target_x, target_y)] = target_entity
hay_mapping[(curr_x, curr_y)] = (target_x, target_y)
return True
return False
def drone_hay_task():
global world_size
global companion_mapping
global hay_mapping
while True:
for j in range(world_size):
curr_x = get_pos_x()
curr_y = get_pos_y()
harvest()
if get_ground_type() == Grounds.Soil:
till()
if (curr_x, curr_y) in companion_mapping:
target_entity = companion_mapping[(curr_x, curr_y)]
if target_entity == Entities.Carrot:
if get_ground_type() != Grounds.Soil:
till()
plant(Entities.Carrot)
elif target_entity != Entities.Grass:
plant(target_entity)
else:
if (curr_x, curr_y) in hay_mapping:
companion_pos = hay_mapping.pop((curr_x, curr_y))
if companion_pos in companion_mapping:
companion_mapping.pop(companion_pos)
track_companion(curr_x, curr_y)
move(North)
NUM_DRONES_TO_SPAWN = world_size - 1
for i in range(NUM_DRONES_TO_SPAWN):
while num_drones() >= max_drones():
pass
spawn_drone(drone_hay_task)
move(East)
drone_hay_task()
# Hay farm with only one drone
companion_mapping = {}
hay_mapping = {}
def track_companion():
global companion_mapping
global hay_mapping
target_entity, (target_x, target_y) = get_companion()
while target_entity == Entities.Carrot and num_items(Items.Wood) < 1:
harvest()
target_entity, (target_x, target_y) = get_companion()
if (target_x, target_y) not in companion_mapping:
companion_mapping[(target_x, target_y)] = target_entity
hay_mapping[(x_curr, y_curr)] = (target_x, target_y)
while True:
if num_items(Items.Hay) >= 1000000000000:
break
x_curr = get_pos_x()
y_curr = get_pos_y()
if get_entity_type() == Entities.Grass:
if can_harvest():
harvest()
if (x_curr, y_curr) in hay_mapping:
companion_pos = hay_mapping[(x_curr, y_curr)]
hay_mapping.pop((x_curr, y_curr))
companion_mapping.pop(companion_pos)
if (x_curr, y_curr) in companion_mapping:
target_entity = companion_mapping[(x_curr, y_curr)]
if target_entity not in [Entities.Bush, Entities.Tree]:
till()
plant(target_entity)
else:
track_companion()
else:
if (x_curr, y_curr) not in companion_mapping:
if get_ground_type() != Grounds.Grassland:
till()
else:
harvest()
track_companion()
if y_curr == get_world_size() - 1:
move(East)
move(North)
2. 木材
# Wood farm with polyculture and multiple drones
clear()
world_size = get_world_size()
change_hat(Hats.Brown_Hat)
companion_mapping = {}
tree_mapping = {}
def tree_tile(curr_x, curr_y):
return curr_x % 2 == curr_y % 2
def track_companion(curr_x, curr_y):
global companion_mapping
global tree_mapping
result = get_companion()
if result == None:
return False
target_entity, (target_x, target_y) = result
if (target_x, target_y) not in companion_mapping:
companion_mapping[(target_x, target_y)] = target_entity
tree_mapping[(curr_x, curr_y)] = (target_x, target_y)
return True
return False
def drone_tree_task():
global world_size
global companion_mapping
global tree_mapping
while True:
for j in range(world_size):
curr_x = get_pos_x()
curr_y = get_pos_y()
if tree_tile(curr_x, curr_y):
if can_harvest():
harvest()
plant(Entities.Tree)
else:
pass
if (curr_x, curr_y) in tree_mapping:
companion_pos = tree_mapping.pop((curr_x, curr_y))
if companion_pos in companion_mapping:
companion_mapping.pop(companion_pos)
track_companion(curr_x, curr_y)
if get_water() < 0.40:
use_item(Items.Water)
elif (curr_x, curr_y) in companion_mapping:
target_entity = companion_mapping[(curr_x, curr_y)]
harvest()
if target_entity == Entities.Grass:
if get_ground_type() != Grounds.Grassland:
till()
elif target_entity == Entities.Carrot:
if get_ground_type() != Grounds.Soil:
till()
plant(target_entity)
else:
harvest()
plant(Entities.Bush)
move(North)
NUM_DRONES_TO_SPAWN = 31
for i in range(NUM_DRONES_TO_SPAWN):
while num_drones() >= max_drones():
pass
spawn_drone(drone_tree_task)
move(East)
drone_tree_task()
# Wood farm with polyculture and only one drone
world_size = get_world_size()
target_num = 10000000000
companion_mapping = {}
tree_mapping = {}
def track_companion(curr_x, curr_y):
global companion_mapping
global hay_mapping
target_entity, (target_x, target_y) = get_companion()
if not tree_tile(target_x, target_y) and (target_x, target_y) not in companion_mapping:
companion_mapping[(target_x, target_y)] = target_entity
tree_mapping[(curr_x, curr_y)] = (target_x, target_y)
return True
return False
def tree_tile(curr_x, curr_y):
return curr_x % 2 == curr_y % 2
while True:
curr_x = get_pos_x()
curr_y = get_pos_y()
if tree_tile(curr_x, curr_y):
if (curr_x, curr_y) in tree_mapping:
while not can_harvest():
use_item(Items.Fertilizer)
harvest()
plant(Entities.Tree)
if (curr_x, curr_y) in tree_mapping:
companion_pos = tree_mapping[(curr_x, curr_y)]
tree_mapping.pop((curr_x, curr_y))
companion_mapping.pop(companion_pos)
if track_companion(curr_x, curr_y) and get_water() < 0.10:
use_item(Items.Water)
elif (curr_x, curr_y) in companion_mapping:
target_entity = companion_mapping[(curr_x, curr_y)]
curr_entity = get_entity_type()
harvest()
if target_entity == Entities.Grass:
if get_ground_type() != Grounds.Grassland:
till()
elif target_entity == Entities.Carrot and get_ground_type() != Grounds.Soil:
till()
plant(target_entity)
else:
plant(target_entity)
else:
harvest()
plant(Entities.Bush)
if num_items(Items.Wood) >= target_num:
break
move(North)
curr_y = get_pos_y()
if curr_y == world_size - 1:
move(East)
# Simple Tree Farm (from SpaceLover)
clear()
for i in range(2**20):
for j in range(get_world_size()):
harvest()
till()
plant(Entities.Tree)
move(North)
move(East)
move(East)
move(East)
3. 胡萝卜
# Carrot farm with polyculture and multiple drones
clear()
world_size = get_world_size()
change_hat(Hats.Brown_Hat)
companion_mapping = {}
carrot_mapping = {}
def track_companion(curr_x, curr_y):
global companion_mapping
global carrot_mapping
result = get_companion()
if result == None:
return False
target_entity, (target_x, target_y) = result
if (target_x, target_y) not in companion_mapping:
companion_mapping[(target_x, target_y)] = target_entity
carrot_mapping[(curr_x, curr_y)] = (target_x, target_y)
return True
return False
def prepare_and_plant(entity_type):
if entity_type in (Entities.Carrot, Entities.Bush, Entities.Tree) and get_ground_type() != Grounds.Soil:
till()
plant(entity_type)
def drone_carrot_task():
global world_size
global companion_mapping
global carrot_mapping
while True:
for j in range(world_size):
curr_x = get_pos_x()
curr_y = get_pos_y()
harvest()
if (curr_x, curr_y) in companion_mapping:
target_entity = companion_mapping[(curr_x, curr_y)]
prepare_and_plant(target_entity)
if target_entity == Entities.Carrot and get_water() < 0.10:
use_item(Items.Water)
elif (curr_x, curr_y) in carrot_mapping:
prepare_and_plant(Entities.Carrot)
if get_water() < 0.10:
use_item(Items.Water)
companion_pos = carrot_mapping.pop((curr_x, curr_y))
if companion_pos in companion_mapping:
companion_mapping.pop(companion_pos)
track_companion(curr_x, curr_y)
else:
prepare_and_plant(Entities.Carrot)
if get_water() < 0.10:
use_item(Items.Water)
track_companion(curr_x, curr_y)
move(North)
NUM_DRONES_TO_SPAWN = world_size - 1
for i in range(NUM_DRONES_TO_SPAWN):
while num_drones() >= max_drones():
pass
spawn_drone(drone_carrot_task)
move(East)
drone_carrot_task()
# Mix between Woods and Carrots
clear()
set_world_size(max_drones() - 1)
change_hat(Hats.Brown_Hat)
hats = [Hats.Green_Hat, Hats.Purple_Hat]
world_size = get_world_size()
def plant_crop(i, j):
if (i + j) % 2 == 0:
plant(Entities.Tree)
else:
plant(Entities.Carrot)
if get_water() < 0.5:
use_item(Items.Water)
def run_drone():
global hats
change_hat(hats[get_pos_x() % 2])
for j in range(get_world_size()):
if get_ground_type() != Grounds.Soil:
till()
plant_crop(get_pos_x(), j)
if can_harvest():
harvest()
plant_crop(get_pos_x(), j)
move(North)
def run_carrots_trees():
global world_size
for i in range(world_size):
spawn_drone(run_drone)
while num_drones() >= max_drones():
pass
move(East)
while True:
run_carrots_trees()
4. 太阳花
# "Sunflower master" achievement script
clear()
def harvest_column():
while True:
if get_pos_y() != 0:
move_to(get_pos_x(), 0)
for _ in range(get_world_size()):
if get_ground_type() != Grounds.Soil:
till()
if get_water() < 0.75:
use_item(Items.Water)
if can_harvest():
harvest()
if get_entity_type() == None:
plant(Entities.Sunflower)
move(North)
def main_loop():
world_size = get_world_size()
for i in range(world_size - 1):
if spawn_drone(harvest_column):
move(East)
harvest_column()
while True:
main_loop()
5. 南瓜
# Standard Pumpkin Code
clear()
change_hat(Hats.Brown_Hat)
world_size = get_world_size()
first_pass = True
def check_pumpkin():
if get_pos_x() != 0:
move(East)
left_id = measure()
move(West)
right_id = measure()
move(East)
return left_id == right_id
def wait_for_drones(drones):
for drone in drones:
wait_for(drone)
def plant_column():
global world_size
global first_pass
for j in range(world_size):
if get_entity_type() != Entities.Pumpkin:
if get_ground_type() != Grounds.Soil:
till()
plant(Entities.Pumpkin)
if not first_pass:
while not can_harvest():
if get_entity_type() == Entities.Dead_Pumpkin:
plant(Entities.Pumpkin)
use_item(Items.Fertilizer)
move(North)
if not first_pass:
for j in range(world_size):
if get_entity_type() == Entities.Dead_Pumpkin:
plant(Entities.Pumpkin)
move(North)
def plant_pumpkins():
global world_size
global first_pass
drones = []
if get_pos_x() != 0:
move(East)
for i in range(world_size - 1):
drones.append(spawn_drone(plant_column))
move(East)
plant_column()
wait_for_drones(drones)
while True:
plant_pumpkins()
first_pass = False
if check_pumpkin():
harvest()
first_pass = True
move(West)
# Optimized Pumpkin Achievement Code (By Arthradax)
clear()
change_hat(Hats.Brown_Hat)
world_size = get_world_size()
needs_till=True
def check_pumpkin():
if get_pos_x() != 0:
move(East)
left_id = measure()
move(West)
right_id = measure()
move(East)
return left_id == right_id
def wait_for_drones(drones):
for drone in drones:
wait_for(drone)
def till_column():
for _ in range(world_size):
till()
move(North)
def plant_first_batch():
for _ in range(world_size):
plant(Entities.Pumpkin)
move(North)
def plant_nth_batch():
for _ in range(world_size):
while not can_harvest():
if get_entity_type() == Entities.Dead_Pumpkin:
plant(Entities.Pumpkin)
use_item(Items.Fertilizer)
move(North)
def check_done():
return measure()==measure(South)
def drone_plant_loop():
if needs_till:
till_column()
plant_first_batch()
while not check_done():
plant_nth_batch()
def plant_pumpkins():
for _ in range(world_size-1):
spawn_drone(drone_plant_loop)
move(East)
drone_plant_loop()
while num_drones()>1:
pass
harvest()
move(East)
while True:
plant_pumpkins()
needs_till=False
6. 仙人掌
# Standard Cactus Sorting Code
clear()
hats = [Hats.Green_Hat, Hats.Purple_Hat]
world_size = get_world_size()
def _shortest_delta(curr, dest):
size = world_size
d = (dest - curr) % size
if d > size / 2:
d -= size
return d
def move_to_x_pos(x_target):
x_curr = get_pos_x()
moves_needed = _shortest_delta(x_curr, x_target)
if moves_needed > 0:
dir = East
else:
dir = West
for i in range(abs(moves_needed)):
move(dir)
def move_to_y_pos(y_target):
y_curr = get_pos_y()
moves_needed = _shortest_delta(y_curr, y_target)
if moves_needed > 0:
dir = North
else:
dir = South
for i in range(abs(moves_needed)):
move(dir)
def wait_for_drones(drones):
for drone in drones:
wait_for(drone)
def drone_action_plant_cacti():
global world_size
change_hat(hats[get_pos_x() % 2])
for j in range(world_size):
if get_ground_type() != Grounds.Soil:
till()
plant(Entities.Cactus)
move(North)
def plant_cacti():
global world_size
move_to_x_pos(0)
move_to_y_pos(0)
drones = []
for i in range(world_size - 1):
drones.append(spawn_drone(drone_action_plant_cacti))
move(East)
drone_action_plant_cacti()
move(East)
move(North)
wait_for_drones(drones)
def shake_row():
global world_size
change_hat(hats[get_pos_y() % 2])
left = 0
right = world_size - 1
while left < right:
move_to_x_pos(left)
loc_last_swap = left
x_curr = get_pos_x()
while x_curr < right:
if measure() > measure(East):
swap(East)
loc_last_swap = x_curr
move(East)
x_curr += 1
right = loc_last_swap
if left >= right:
break
move_to_x_pos(right)
loc_last_swap = right
x_curr = get_pos_x()
while x_curr > left:
if measure(West) > measure():
swap(West)
loc_last_swap = x_curr
move(West)
x_curr -= 1
left = loc_last_swap
def shake_col():
global world_size
change_hat(hats[get_pos_x() % 2])
left = 0
right = world_size - 1
while left < right:
move_to_y_pos(left)
loc_last_swap = left
y_curr = get_pos_y()
while y_curr < right:
if measure() > measure(North):
swap(North)
loc_last_swap = y_curr
move(North)
y_curr += 1
right = loc_last_swap
if left >= right:
break
move_to_y_pos(right)
loc_last_swap = right
y_curr = get_pos_y()
while y_curr > left:
if measure(South) > measure():
swap(South)
loc_last_swap = y_curr
move(South)
y_curr -= 1
left = loc_last_swap
def sort_columns():
global world_size
move_to_x_pos(0)
move_to_y_pos(0)
drones = []
for i in range(world_size - 1):
drones.append(spawn_drone(shake_col))
move(East)
shake_col()
move(East)
move(North)
wait_for_drones(drones)
def sort_rows():
global world_size
move_to_x_pos(0)
move_to_y_pos(0)
drones = []
for i in range(world_size - 1):
drones.append(spawn_drone(shake_row))
move(North)
shake_row()
move(North)
wait_for_drones(drones)
while True:
plant_cacti()
sort_columns()
sort_rows()
harvest()
# "Wrong Order" Achievement Cactus Code
clear()
hats = [Hats.Green_Hat, Hats.Purple_Hat]
set_world_size(6)
world_size = get_world_size()
def _shortest_delta(curr, dest):
size = world_size
d = (dest - curr) % size
if d > size / 2:
d -= size
return d
def move_to_x_pos(x_target):
x_curr = get_pos_x()
moves_needed = _shortest_delta(x_curr, x_target)
if moves_needed > 0:
dir = East
else:
dir = West
for i in range(abs(moves_needed)):
move(dir)
def move_to_y_pos(y_target):
y_curr = get_pos_y()
moves_needed = _shortest_delta(y_curr, y_target)
if moves_needed > 0:
dir = North
else:
dir = South
for i in range(abs(moves_needed)):
move(dir)
def wait_for_drones(drones):
for drone in drones:
wait_for(drone)
def drone_action_plant_cacti():
global world_size
change_hat(hats[get_pos_x() % 2])
for j in range(world_size):
if get_ground_type() != Grounds.Soil:
till()
plant(Entities.Cactus)
move(North)
def plant_cacti():
global world_size
move_to_x_pos(0)
move_to_y_pos(0)
drones = []
for i in range(world_size - 1):
drones.append(spawn_drone(drone_action_plant_cacti))
move(East)
drone_action_plant_cacti()
move(East)
move(North)
wait_for_drones(drones)
def shake_row():
global world_size
change_hat(hats[get_pos_y() % 2])
left = 0
right = world_size - 1
while left < right:
move_to_x_pos(left)
loc_last_swap = left
x_curr = get_pos_x()
while x_curr < right:
if measure() < measure(East):
swap(East)
loc_last_swap = x_curr
move(East)
x_curr += 1
right = loc_last_swap
if left >= right:
break
move_to_x_pos(right)
loc_last_swap = right
x_curr = get_pos_x()
while x_curr > left:
if measure(West) > measure():
swap(West)
loc_last_swap = x_curr
move(West)
x_curr -= 1
left = loc_last_swap
def shake_col():
global world_size
change_hat(hats[get_pos_x() % 2])
left = 0
right = world_size - 1
while left < right:
move_to_y_pos(left)
loc_last_swap = left
y_curr = get_pos_y()
while y_curr < right:
if measure() < measure(North):
swap(North)
loc_last_swap = y_curr
move(North)
y_curr += 1
right = loc_last_swap
if left >= right:
break
move_to_y_pos(right)
loc_last_swap = right
y_curr = get_pos_y()
while y_curr > left:
if measure(South) > measure():
swap(South)
loc_last_swap = y_curr
move(South)
y_curr -= 1
left = loc_last_swap
def sort_columns():
global world_size
move_to_x_pos(0)
move_to_y_pos(0)
drones = []
for i in range(world_size - 1):
drones.append(spawn_drone(shake_col))
move(East)
shake_col()
move(East)
move(North)
wait_for_drones(drones)
def sort_rows():
global world_size
move_to_x_pos(0)
move_to_y_pos(0)
drones = []
for i in range(world_size - 1):
drones.append(spawn_drone(shake_row))
move(North)
shake_row()
move(North)
wait_for_drones(drones)
while True:
plant_cacti()
sort_columns()
sort_rows()
harvest()
7. 恐龙
world_size = get_world_size()
world_size_minus_one = world_size - 1
edge_positions = [0, world_size_minus_one]
offlimit_columns_stage1 = {}
offlimit_columns_stage2 = {}
clear()
change_hat(Hats.Dinosaur_Hat)
apple_pos = measure()
squares_occupied = 1
game_complete = False
aggressive_stage = True
def measure_apple():
global apple_pos
global squares_occupied
global apple_pos_queue
apple_pos = measure()
squares_occupied += 1
def move_and_check_apple(direction):
global apple_pos
if not move(direction):
return False
if (get_pos_x(), get_pos_y()) == apple_pos:
measure_apple()
return True
def move_to_col(target_x_pos, do_measure=True):
global world_size
global apple_pos
curr_x = get_pos_x()
direction = West
if curr_x < target_x_pos:
direction = East
for x in range(abs(target_x_pos - curr_x)):
this_check = move
if do_measure:
this_check = move_and_check_apple
if not this_check(direction):
return False
return True
def move_to_row(target_y_pos, do_measure=True):
global world_size
global apple_pos
curr_y = get_pos_y()
direction = South
if curr_y < target_y_pos:
direction = North
for y in range(abs(target_y_pos - curr_y)):
this_check = move
if do_measure:
this_check = move_and_check_apple
if not this_check(direction):
return False
return True
def transition_to_stage_2():
global offlimit_columns_stage1
global world_size
global world_size_minus_one
move_to_col(world_size_minus_one)
move_to_row(0)
offlimit_columns_stage1 = {}
return False
def transition_to_stage_1():
global offlimit_columns_stage2
global world_size
global world_size_minus_one
move_to_col(0)
move_to_row(world_size_minus_one)
offlimit_columns_stage2 = {}
return False
def stage_1_apple_collect():
global apple_pos
global world_size
global offlimit_columns_stage1
global offlimit_columns_stage2
global world_size_minus_one
apple_pos_x, apple_pos_y = apple_pos
if apple_pos_y == 0 or apple_pos_x in edge_positions or (apple_pos_x in offlimit_columns_stage1 and apple_pos_y <= offlimit_columns_stage1[apple_pos_x]):
return transition_to_stage_2()
else:
apple_x_odd = apple_pos_x % 2
target_x_pos = apple_pos_x
if not apple_x_odd:
target_x_pos = apple_pos_x - 1
if target_x_pos <= get_pos_x():
return transition_to_stage_2()
else:
move_to_col(target_x_pos)
move_to_row(apple_pos_y)
offlimit_columns_stage2[target_x_pos] = apple_pos_y
offlimit_columns_stage2[target_x_pos + 1] = apple_pos_y
move_and_check_apple(East)
move_to_row(world_size_minus_one)
return True
def stage_2_apple_collect():
global apple_pos
global world_size
global offlimit_columns_stage1
global offlimit_columns_stage2
global world_size_minus_one
apple_pos_x, apple_pos_y = apple_pos
if apple_pos_y == world_size_minus_one or apple_pos_x in edge_positions or (apple_pos_x in offlimit_columns_stage2 and apple_pos_y >= offlimit_columns_stage2[apple_pos_x]):
return transition_to_stage_1()
else:
apple_x_odd = apple_pos_x % 2
target_x_pos = apple_pos_x
if apple_x_odd:
target_x_pos = apple_pos_x + 1
if target_x_pos >= get_pos_x():
return transition_to_stage_1()
else:
move_to_col(target_x_pos)
move_to_row(apple_pos_y)
offlimit_columns_stage1[target_x_pos] = apple_pos_y
offlimit_columns_stage1[target_x_pos - 1] = apple_pos_y
move_and_check_apple(West)
move_to_row(0)
return True
def move_to_right_col_wavy():
global world_size
global world_size_minus_one
global offlimit_columns_stage1
for x in range(world_size):
if x % 2:
target_y = 1
if x in offlimit_columns_stage1:
target_y = offlimit_columns_stage1[x] + 1
while get_pos_y() != target_y:
move(South)
move(East)
else:
while get_pos_y() != world_size_minus_one:
move(North)
move(East)
def find_top_left():
global world_size_minus_one
while get_pos_x() > 0:
move(West)
while get_pos_y() < world_size_minus_one:
move(North)
def transition_to_route():
find_top_left()
move_to_right_col_wavy()
while get_pos_y() != 0:
move(South)
while get_pos_x() != 0:
move(West)
move_to_row(world_size_minus_one)
while aggressive_stage:
while stage_1_apple_collect() and get_pos_x() < world_size_minus_one:
pass
while stage_2_apple_collect() and get_pos_x() > 0:
pass
if squares_occupied > (world_size_minus_one) * 4 - 4:
break
transition_to_route()
while True:
for i in range(world_size / 2):
game_complete = not move_to_row(world_size_minus_one, False)
game_complete = game_complete or not move(East)
game_complete = game_complete or not move_to_row(1, False)
if i != world_size / 2 - 1:
game_complete = game_complete or not move(East)
if game_complete:
break
game_complete = game_complete or not move_to_row(0, False)
game_complete = game_complete or not move_to_col(0,)
if game_complete:
break
change_hat(Hats.Straw_Hat)
8.迷宫
# Iterative Search Maze Runner
ALL_DIRECTIONS = [North, South, East, West]
def opposite_direction(direction):
if direction == North:
return South
elif direction == East:
return West
elif direction == South:
return North
elif direction == West:
return East
def explore_option_iterative(start_direction):
global ALL_DIRECTIONS
if not move(start_direction):
return False
path_stack = [(start_direction, 0)]
while path_stack and num_items(Items.Gold) < 9863168000000:
if get_entity_type() == Entities.Treasure:
harvest()
start_maze()
return True
last_move_direction, next_dir_index = path_stack[-1]
while next_dir_index < len(ALL_DIRECTIONS):
explore_direction = ALL_DIRECTIONS[next_dir_index]
path_stack[-1] = (last_move_direction, next_dir_index + 1)
if opposite_direction(explore_direction) != last_move_direction:
if move(explore_direction):
path_stack.append((explore_direction, 0))
break
next_dir_index += 1
if next_dir_index == len(ALL_DIRECTIONS):
path_stack.pop()
move(opposite_direction(last_move_direction))
move(opposite_direction(start_direction))
return False
def start_maze():
plant(Entities.Bush)
substance = get_world_size() * 2**(num_unlocked(Unlocks.Mazes) - 1)
use_item(Items.Weird_Substance, substance)
def search():
global drone_id
global ALL_DIRECTIONS
for _ in range(drone_id):
do_a_flip()
if drone_id % 2:
ALL_DIRECTIONS = ALL_DIRECTIONS[::-1]
if drone_id % 3:
ALL_DIRECTIONS[0], ALL_DIRECTIONS[1] = (ALL_DIRECTIONS[1], ALL_DIRECTIONS[0])
if drone_id % 5:
ALL_DIRECTIONS[1], ALL_DIRECTIONS[3] = (ALL_DIRECTIONS[3], ALL_DIRECTIONS[1])
while True:
for direction in ALL_DIRECTIONS:
if explore_option_iterative(direction):
break
drone_id = 0
start_maze()
for i in range(max_drones()):
drone_id = i
spawn_drone(search)
drone_id = 0
search()
# "Recycling" & "Big Gold Farmer" Achievement Maze Code (Original)
def generate_maze():
plant(Entities.Bush)
substance = get_world_size() * 2**(num_unlocked(Unlocks.Mazes) - 1)
use_item(Items.Weird_Substance, substance)
def maze():
while True:
if num_drones() == 25:
if get_entity_type() == Entities.Treasure:
harvest()
generate_maze()
clear()
set_world_size(5)
list = []
while num_drones() < 26:
pos_x = get_pos_x()
pos_y = get_pos_y()
current = (pos_x, pos_y)
if current not in list:
list.append(current)
spawn_drone(maze)
move(North)
else:
move(East)
# "Recycling" Fix Version 1 (By Arthradax)
set_world_size(5)
times_reused=0
substance = get_world_size() * 2**(num_unlocked(Unlocks.Mazes) - 1)
def generate_maze():
plant(Entities.Bush)
use_item(Items.Weird_Substance, substance)
def maze():
global times_reused
while True:
if num_drones() == 25:
if get_entity_type() == Entities.Treasure:
if times_reused>=300:
times_reused=0
harvest()
generate_maze()
else:
use_item(Items.Weird_Substance, substance)
times_reused+=1
clear()
list = []
while num_drones() < 26:
pos_x = get_pos_x()
pos_y = get_pos_y()
current = (pos_x, pos_y)
if current not in list:
list.append(current)
spawn_drone(maze)
move(North)
else:
move(East)
generate_maze()
# "Recycling" Fix Version 2 (By ᴛᴀᴛᴀʀᴏᴄʜᴋᴀ)
def generate_maze():
plant(Entities.Bush)
substance = get_world_size() * 2**(num_unlocked(Unlocks.Mazes) - 1)
use_item(Items.Weird_Substance, substance)
def maze():
i = 0
end = 300
while True:
if num_drones() == 25:
if get_entity_type() == Entities.Treasure and (i == end):
harvest()
i = 0
elif get_entity_type() == Entities.Treasure:
substance = get_world_size() * 2**(num_unlocked(Unlocks.Mazes) - 1)
use_item(Items.Weird_Substance, substance)
i += 1
generate_maze()
clear()
set_world_size(5)
list = []
while num_drones() < 26:
pos_x = get_pos_x()
pos_y = get_pos_y()
current = (pos_x, pos_y)
if current not in list:
list.append(current)
spawn_drone(maze)
move(North)
else:
move(East)
# Compact Recycling Code (By MobiusPizza)
clear()
def run():
while True:
if get_entity_type() == Entities.Treasure:
create()
def create():
use_item(Items.Weird_Substance, 2 * 2**(num_unlocked(Unlocks.Mazes) - 1))
for dir in [North, East, South, West]:
spawn_drone(run)
move(dir)
plant(Entities.Bush)
create()
编程并不断优化你的无人机,实现农场自动化。
安坐一旁,看它为你打理一切;收集资源,解锁更尖端的科技,
成为全世界效率第一的农场主。
畅享游戏快乐,同时不断提高解决问题和编写代码的能力。
无人机替你种田的编程游戏。用一种类似 Python 的简单语言编写简短程序,按下执行,无人机就会翻土、播种、浇水、收获,效果完全取决于你的代码。
没有关卡限制,随着游戏推进不断成长:收集资源,消耗资源解锁新内容,解决下一个难题。
收获干草、木材和胡萝卜,把南瓜合并成巨型南瓜,给仙人掌排序,找出最好的向日葵,喂养恐龙,还要在树篱迷宫中寻宝。成为世界上最高效的农夫。
专为触屏打造的代码键盘
所需符号尽在一屏。括号和引号成对出现。在任意键上滑动即可移动光标,按住 Shift 滑动即可选中。撤销、重做、注释和粘贴独占一行。
轻松做码农
可选 QWERTY、QWERTZ 或 AZERTY 布局,支持按键音或震动。更喜欢实体键盘?连接蓝牙键盘和鼠标,编写代码更轻松。
学习编程
循环、变量、函数、列表等概念逐一登场。游戏提供工具,但任务要靠你自己解决,这可能相当有挑战性。已经会编程了?快速过一遍基础内容,然后指挥无人机编队。
内含《编程矿场》
让无人机深入地下,解锁八种全新资源,包括煤炭、石英、蘑菇和炸药。完好无损地挖出古代遗迹,给蘑菇分类,在黏土上种水稻,还能玩扫雷而不炸飞你的无人机。
• 真正的编程语言
• 定制代码键盘,并支持蓝牙键盘和鼠标
• 手机和平板均支持竖屏和横屏
• Megafarm:多台无人机并行工作
• 模拟模式,快速且可复现地测试
• 可解锁成就
• 帽子。你的无人机值得拥有。
• 支持 14 种语言
编程游戏,允许玩家通过编写类似Python语言的简单程序,
使用无人机自动化农耕任务。没有等级,玩家通过刷资源、解决挑战和解锁新功能不断进步。
游戏引入了循环和函数等编程概念,适合初学者和有经验的程序员。
玩家可以通过独特的键盘和对外部设备的支持定制编程体验,
同时探索充满活力的农场和地下世界。
编写无人机程序。让农场自动运转。看你的代码包揽一切。
• 修复了教程中的一个问题。
DATA
意见反馈
权限协议
严格遵守法律法规,遵循以下隐私保护原则,为您提供更加安全、可靠的服务:
1、安全可靠:我们竭尽全力通过合理有效的信息安全技术及管理流程,防止您的信息泄露、损毁、丢失。
2、自主选择:我们为您提供便利的信息管理选项,以便您做出合适的选择,管理您的个人信息
3、保护通信秘密:4、合理必要:为了向您和其他用户提供更好的服务,我们仅收集必要的信息。
5、清晰透明:我们努力使用简明易懂的表述,向您介绍隐私政策,以便您清晰地了解我们的信息处理方式。
6、将隐私保护融入产品设计:我们在产品和服务研发、运营的各个环节,融入隐私保护的理念。
本《隐私政策》主要向您说明:我们收集哪些信息 我们收集信息的用途 您所享有的权利
希望您仔细阅读《隐私政策》为了让您有更好的体验、改善我们的服务或经您同意的其他用途,在符合相关法律法规的前提下,我们可能将通过某些服务所收集的信息用于我们的其他服务。例如,将您在使用我们某项服务时的信息,用于另一项服务中向您展示个性化的内容或广告、用于用户研究分析与统计等服务。
若您使用服务,即表示您认同我们在本政策中所述内容。除另有约定外,本政策所用术语与《服务协议》中的术语具有相同的涵义。
如您有问题,请联系我们。
发表评论
COMMENT