
一个因无聊在一小时内编写的成就合集和一些简单功能 本指南已完成。是的,我没有达成所有成就,但其中一些成就需要花费太多时间来完成(例如,在一分钟内收集2000万干草) 本指南已完成。是的,我还没有完成所有成就,但有些成就完成起来太耗时了(比如在一分钟内收集200,000,000份干草) 这是最终的文件集。所有文件都包含在本指南中

Вот ссылка на все эти файлы / Here's a link to all these files[drive.google.com] Описание / Description [ RU ] [ Не содержит методов решения достижений, связанных со сбором огромного количества ресурсов за минуту ] Все достижения в руководстве разделены на несколько групп: - Посадка. Достижения, связанные с посадкой растений (Посадите куст). - Сбор 1000. Достижения, связанные со сбором 1000 единиц определенного ресурса (Соберите 1000 древесины). - Большой сбор. Достижения, связанные со сбором огромного количества ресурсов (Соберите 100 000 энергии). - Сбор за минуту. Достижения, связанные со сбором большого количества ресурсов за минуту (Соберите 20 000 000 кактусов за минуту). - Другое. Достижения, не связанные со сбором ресурсов (Сделайте сальто) [ EN ] [ Does not contain methods for solving achievements related to collecting a huge amount of resources in a minute ] All achievements in the guide are divided into several groups: - Planting. Achievements related to planting (Plant a Bush). - Collect 1000. Achievements related to collecting 1000 units of a specific resource (Collect 1000 Wood). - Large Collection. Achievements related to collecting a huge amount of resources (Collect 100,000 Energy). - Minute Collection. Achievements related to collecting a large amount of resources in a minute (Collect 20,000,000 Cacti in a Minute). - Other. Achievements not related to resource gathering (Do a somersault) Посадка / Planting clear() plant(Entities.Bush) clear() plant(Entities.Carrot) clear() plant(Entities.Tree) clear() till() plant(Entities.Pumpkin) clear() till() plant(Entities.Sunflower) clear() till() plant(Entities.Cactus) clear() [ RU ] [ Кусты ] Посади куст [ EN ] [ Bushes ] Plant a bush plant(Entities.Bush) [ RU ] [ Морковь ] Посади морковь [ EN ] [ Carrot ] Plant a carrot plant(Entities.Carrot) [ RU ] [ Деревья ] Посади дерево [ EN ] [ Trees ] Plant a tree plant(Entities.Tree) [ RU ] [ Тыквы ] Посади тыкву [ EN ] [ Pumpkins ] Plant a pumpkin plant(Entities.Pumpkin) [ RU ] [ Подсолнухи ] Посади подсолнух [ EN ] [ Sunflowers ] Plant a sunflower plant(Entities.Sunflower) [ RU ] [ Кактусы ] Посади кактус [ EN ] [ cacti ] Plant a cactus plant(Entities.Cactus) Сбор 1000 / Collecting 1000 print("Collect 1000 hay") print("Collect 1000 wood") print("Collect 1000 carrots") print("Collect 1000 pumpkins") print("Collect 1000 sunflowers") print("Collect 1000 cacti") print("Collect 1000 gold") print("Collect 1000 bones") [ RU ] [ Сбор сена ] Собери 1000 сена [ EN ] [ Hay collection ] Collect 1000 hay while True: clear() for i in range(get_world_size()): for j in range(get_world_size()): if can_harvest(): harvest() move(East) move(North) [ RU ] [ Сбор древесины ] Собери 1000 древесины [ EN ] [ Wood collection ] Collect 1000 wood while True: clear() for i in range(get_world_size()): for j in range(get_world_size()): plant(Entities.Bush) move(East) move(North) for i in range(get_world_size()): for j in range(get_world_size()): if can_harvest() harvest() move(East) move(North) [ RU ] [ Сбор моркови ] Собери 1000 моркови [ EN ] [ Carrot collection ] Collect 1000 carrots clear() while True: for i in range(get_world_size()): for j in range(get_world_size()): till() plant(Entities.Carrot) move(East) move(North) for i in range(get_world_size()): for j in range(get_world_size()): if can_harvest() harvest() move(East) move(North) [ RU ] [ Сбор тыкв ] Собери 1000 тыкв [ EN ] [ Pumpkin collection ] Collect 1000 pumpkins [ RU ] [ Огромная тыква ] Собери тыкву размером 32х32 [ EN ] [ Big pumpkin ] Harvest a pumpkin measuring 32x32 for i in range(get_world_size()): for j in range(get_world_size()): till() plant(Entities.Pumpkin) move(East) move(North) while True: dead_pumpies = 0 for i in range(get_world_size()): for j in range(get_world_size()): if get_entity_type() == Entities.Dead_Pumpkin: harvest() plant(Entities.Pumpkin) dead_pumpies += 1 move(East) else: move(East) move(North) if dead_pumpies == 0: break [ RU ] [ Сбор энергии ] Собери 1000 энергии [ EN ] [ Energy collection ] Collect 1000 energy def planting_sunflowers(): for i in range(get_world_size()): for j in range(get_world_size()): till() plant(Entities.Sunflower) move(East) move(North) def harvesting(): for i in range(get_world_size()): for j in range(get_world_size()): harvest() move(East) move(North) planting_sunflowers() harvesting() [ RU ] [ Сбор кактусов ] Собери 1000 кактусов [ EN ] [ Cacti collection ] Collect 1000 cacti def checking_pos_row(): while True: move(West) if get_pos_x() == 0: break def planting_cactus(): for i in range(get_world_size()): for j in range(get_world_size()): till() plant(Entities.Cactus) move(East) move(North) def sorting_cactuses_min(): n = get_world_size() for i in range(0, n): checking_pos_row() drone_pos = 0 while drone_pos < i: move(East) drone_pos += 1 key = measure() move(West) drone_pos -= 1 j = i - 1 while j >= 0: val = measure() if val > key: if drone_pos > n: break swap(East) move(West) drone_pos -= 1 j -= 1 else: break while drone_pos < i: move(East) drone_pos += 1 def harvesting(): for i in range(get_world_size()): for j in range(get_world_size()): harvest() move(East) move(North) [ RU ] [ Лабиринт ] Создай лабиринт [ EN ] [ Labyrinth ] Create a labyrinth [ RU ] [ Сбор золота ] Собери 1000 золота [ EN ] [ Gold collection ] Collect 1000 gold [ RU ] [ Охота за сокровищами ] Пройди лабиринт, который занимает всю ферму [ EN ] [ Treasure hunt ] Go through the maze that takes up the entire farm [ RU ] [ Переработка ] Используй один и тот же лабиринт 300 раз [ EN ] [ Recycling ] Use the same maze 300 times left_turn = { North: West, West: South, South: East, East: North } right_turn = { North: East, East: South, South: West, West: North } back_turn = { North: South, South: North, East: West, West: East } def follow_left_wall(): direction = North while get_entity_type() != Entities.Treasure: left_dir = left_turn[direction] if can_move(left_dir): move(left_dir) direction = left_dir continue if can_move(direction): move(direction) continue right_dir = right_turn[direction] if can_move(right_dir): move(right_dir) direction = right_dir continue back_dir = back_turn[direction] if can_move(back_dir): move(back_dir) direction = back_dir continue break if get_entity_type() == Entities.Treasure: harvest() set_world_size(12) plant(Entities.Bush) substance = get_world_size() * 2**(num_unlocked(Unlocks.Mazes) - 1) use_item(Items.Weird_Substance, substance) [ RU ] [ Сбор костей ] Собери 1000 костей [ EN ] [ Bone collection ] Collect 1000 bones [ RU ] [ Длинный динозавр ] Создай динозавра, который займет всю ферму [ EN ] [ Long dinosaur ] Create a dinosaur that will take over the entire farm [ RU ] [ Размер имеет значение ] Увеличь длину динозавра до 1000 [ EN ] [ Size matters ] Increase the dinosaur's length to 1000 def moving_so_strange_one(): a = 0 while a < (get_world_size() // 2): for i in range(2): move(South) move(East) for i in range(2): move(North) move(East) a += 1 move(North) def moving_so_strange_two(): a = 0 while a < (get_world_size() // 2): for i in range(get_world_size() - 4): move(North) move(West) for i in range(get_world_size() - 4): move(South) move(West) a += 1 move(South) move(South) move(South) change_hat(Hats.Traffic_Cone) clear() change_hat(Hats.Dinosaur_Hat) while True: moving_so_strange_one() moving_so_strange_two() Другое / Other [ RU ] [ Привет, мир ] Запусти первую программу [ EN ] [ Hello, world ] Run your first program harvest() [ RU ] [ Бесконечный цикл ] Создай бесконечный цикл [ EN ] [ Infinite loop ] Create an infinite loop while True: if can_harvest(): harvest() move(East) [ RU ] [ Заметный рост ] Расширь ферму [ EN ] [ Noticeable growth ] Expand your farm unlock(Unlocks.Expand) [ RU ] [ Ошибка ] Вызови ошибку программы [ EN ] [ Error ] Cause a program error harvest(180) [ RU ] [ Акробат ] Сделай сальто [ EN ] [ Acrobat ] Do a somersault do_a_flip() [ RU ] [ На стиле ] Надень новую шляпу [ EN ] [ On style ] Put on a new hat change_hat(Hats.Brown_hat) [ RU ] [ Приятное чувство ] Погладь свинку [ EN ] [ Pleasant feeling ] Pet the pig pet_the_piggy() [ RU ] [ Программирование высшего порядка ] Передай функции другую функцию в качестве аргумента [ EN ] [ Higher Order Programming ] Pass another function as an argument to a function def collecting(num): for i in range(num): for j in range(num): harvest() move(East) move(North) def some_number(): return random() collecting(some_number()) [ RU ] [ Заливные поля ] Подними уровень воды на всей ферме выше 0,5 [ EN ] [ Flood fields ] Raise the water level on the entire farm above 0.5 for i in range(get_world_size()): for j in range(get_world_size()): for u in range(5): use_item(Items.Water) move(East) move(North) [ RU ] [ Динозавры ] Надень шляпу динозавра [ EN ] [ Dinosaurs ] Put on a dinosaur hat change_hat(Hats.Dinosaur_hat) [ RU ] [ Мегаферма ] Задействуй несколько дронов [ EN ] [ Megafarm ] Use multiple drones clear() set_world_size(7) def sun(): for i in range(get_world_size()): till() plant(Entities.Sunflower) use_item(Items.Water) use_item(Items.Water) use_item(Items.Water) use_item(Items.Water) move(East) def har(): for i in range(get_world_size()): harvest() move(East) while True: clear() for i in range(7): if spawn_drone(sun): move(North) do_a_flip() do_a_flip() do_a_flip() for j in range(7): if spawn_drone(har): move(North) do_a_flip() [ RU ] [ Лекарь ] Вылечи зараженное растение [ EN ] [ Doctor ] Cure the infected plant while True: plant(Entitites.Weird_substance) harvest() [ RU ] [ Большая ферма ] Расширь ферму до максимального размера [ EN ] [ Big farm ] Expand your farm to its maximum size for i in range(1, 9): unlock(Unlocks.Expand) [ RU ] [ Виртуозный акробат ] Сделай 1000 сальто [ EN ] [ Virtuoso acrobat ] Do 1000 somersaults def drone_function(): move(North) do_a_flip() while True: if spawn_drone(drone_function): move(East) [ RU ] [ Неверный порядок ] Отсортируй поле кактусов в неправильном порядке [ EN ] [ Wrong order ] Sort the cactus field in the wrong order def harvesting(): for i in range(get_world_size()): for j in range(get_world_size()): harvest() move(East) move(North) def planting_cactus(): for i in range(get_world_size()): for j in range(get_world_size()): till() plant(Entities.Cactus) move(East) move(North) def sorting_cactuses(): n = get_world_size() for i in range(0, n): checking_pos_row() drone_pos = 0 while drone_pos < i: move(East) drone_pos += 1 key = measure() move(West) drone_pos -= 1 j = i - 1 while j >= 0: val = measure() if val < key: if drone_pos > n: break swap(East) # Вот тут убрал движение дрона #move(East) # Here I removed the drone movement drone_pos -= 1 j -= 1 else: break while drone_pos < i: move(East) drone_pos += 1 set_world_size(3) planting_cactus() do_a_flip() # Чтобы дрон не начинал сортировку и дождался роста всех кактусов for i in range(get_world_size()): for j in range(get_world_size()): sorting_cactuses() move(North) do_a_flip() do_a_flip() # Тут они не нужны, я их просто оставил для проверки состояния кактусов do_a_flip() # They are not needed here, I just left them to check the condition of the cacti harvesting() [ RU ] [ Хаос ] Открой 20 окон кода одновременно [ EN ] [ Chaos ] Open 20 code windows at once print("Откройте новое окно, используя кнопку с символом + в правом верхнем углу") print("Open a new window using the + button in the upper right corner") [ RU ] [ Циклический импорт ] Создай циклический импорт [ EN ] [ Cyclic import ] Create a cyclic import helping.py from carrots import planting_and_har def carroting(): for i in range(get_world_size()): for j in range(get_world_size()): if can_harvest(): harvest() move(East) move(North) planting_and_har() carrots.py from helping import carroting def planting_and_har(): for i in range(get_world_size()): for j in range(get_world_size()): till() plant(Entities.Carrot) move(East) move(North) carroting() [ RU ] [ Переполнение стека ] Вызови переполнение стека [ EN ] [ Stack overflow ] Cause a stack overflow def rec(): return rec() rec() [ RU ] [ Рой ] Задействуй 32 дрона сразу [ EN ] [ Swarm ] Deploy 32 drones at once def harvesting(): for i in range(get_world_size()): harvest() move(North) while True: if spawn_drone(harvesting): move(East) [ RU] [ Дефиле ] Надень 5 разных шляп на 5 дронов [ EN ] [ Fashion show ] Put 5 different hats on 5 drones def hat_one(): change_hat(Hats.Brown_Hat) do_a_flip() def hat_two(): change_hat(Hats.Cactus_Hat) do_a_flip() def hat_three(): change_hat(Hats.Carrot_Hat) do_a_flip() def hat_four(): change_hat(Hats.Gold_Hat) do_a_flip() def hat_five(): change_hat(Hats.Green_Hat) do_a_flip() clear() spawn_drone(hat_one) move(East) spawn_drone(hat_two) move(East) spawn_drone(hat_three) move(East) spawn_drone(hat_four) move(East) spawn_drone(hat_five) move(East) [ RU ] [ Соревнования фермеров ] Попади в рейтинг [ EN ] [ Farmer's competition ] Get into the rating print("idk") [ RU ] [ Что дальше? ] Разблокируй всё [ EN ] [ What's next? ] Unlock everything print("") [ RU ] [ Полная автоматизация ] Попади в рейтинг полного сброса [ EN ] [ Full automation ] Get into the full reset rating print("impossible") Вспомогательные функции / Helping functions [ RU ] Четность числа. Проверяет, является ли число четным. Если да, возвращает True, в противном случае False. Взята из справочника игры. [ EN ] Evenness of a number. Checks whether a number is even. If so, returns True; otherwise, False. Taken from the game's manual. def is_even(n): return n % 2 == 0 [ RU ] Проверка позиции дрона по x. Данную функцию сделал для того, чтобы дрон улетал в левую часть поля (x:0) и начинал сортировку кактусов. [ EN ] Checking the drone's position by x. I made this function so that the drone would fly to the left side of the field (x:0) and start sorting cacti. def checking_pos_row(): while True: move(West) if get_pos_x() == 0: break [ RU ] Сбор. Собирает растения, движется вправо до конца и вверх на следующую колонку. Не учитывает не выращенные растения, так как к времени посадке, прошлые уже вырастут. [ EN ] Collection. Collects plants, moves to the right to the end and up to the next column. Doesn't count ungrown plants, as by the time they're planted, the old ones will already be grown. def harvesting(): for i in range(get_world_size()): for j in range(get_world_size()): harvest() move(West) move(North) Сбор сена / Collecting hay [ RU ] Первый метод собирает сено по всему полю [ EN ] The first method collects hay from across the entire field def harvesting(): for i in range(get_world_size()): for j in range(get_world_size()): harvest() move(East) move(North) [ RU ] Второй метод спавнит 31 дрон, которые собирают сено [ EN ] The second method spawns 31 drones that collect hay #7.11 миллионов сена за минуту #7.11 million hay per minute def harvesting(): for i in range(get_world_size()): harvest() move(North) while True: if spawn_drone(harvesting): move(East) #4.42 миллиона сена за минуту #4.42 million hay per minute def checking_pos_start(): while True: if get_pos_x() == 0: if get_pos_y() == 0: break elif get_pos_y() != 0: move(North) elif get_pos_x() != 0: move(West) set_world_size(3) plant_type, (p_x, p_y) = get_companion() while True: x = get_pos_x() y = get_pos_y() if p_x > x: move(East) elif p_x < x: move(West) if p_y > y: move(North) elif p_y < y: move(South) x = get_pos_x() y = get_pos_y() if (x, y) == (p_x, p_y): till() plant(plant_type) checking_pos_start() harvest() clear() plant_type, (p_x, p_y) = get_companion() Сбор кустов / Collecting bushes [ RU ] Считывает количество ячеек на поле, сажает кусты и движется вправо до конца и вверх на следующую колонку. Когда time_a доходит до 10, поливает растение. Функция немного сломана, так как иногда переменная превышает 10 и доходит до бесконечности, не поливая растения. Я ее почти не использовал, так как купил деревья и сажаю их. [ EN ] Reads the number of cells in the field, plants bushes, and moves to the right until the end and up to the next column. When time_a reaches 10, it waters the plant. The function is a bit broken, as sometimes the variable exceeds 10 and goes to infinity without watering the plants. I've hardly used it since I bought trees and am planting them. def collecting_wood(): time_a = 0 while True: for i in range(get_world_size()): for j in range(get_world_size()): plant(Entities.bush) if can_harvest(): harvest() move(West) if time_a == 10: use_item(Items.Water) time_a = 0 move(West) else: move(West) time_a += 1 quick_print(time_a) move(North) [ RU ] 31 дрон сажают и собирают кусты [ EN ] 31 drones plant and harvest shrubs def planting_bush(): for i in range(get_world_size()): till() for i in range(3): use_item(Items.Water) plant(Entities.Bush) move(North) def harvesting_bush(): for i in range(get_world_size()): harvest() move(North) while True: set_world_size(31) clear() for i in range(31): if spawn_drone(planting_bush): move(East) while num_drones() > 1: pass for j in range(31): if spawn_drone(harvesting_bush): move(East) while num_drones() > 1: pass Сбор деревьев и моркови / Collecting trees and carrots [ RU ] Считывает количество ячеек на поле, а также проверяет, является ли текущая ячейка по x и y четной или нет. [ x - Четная, y - Четная ] - Сажает дерево, поливает его и движется вправо. [ x - Нечетная, y - Нечетная ] - Сажает дерево, поливает его и движется вправо. [ x - Нечетная, y - Четная ] - Вспахивает землю, сажает морковку, поливает ее и движется вправо. [ x - Четная, y - Нечетная ] - Вспахивает землю, сажает морковку, поливает ее и движется вправо. [ EN ] Counts the number of cells on the field and checks whether the current cell is even or odd based on x and y. [ x - Even, y - Even ] - Plants a tree, waters it, and moves to the right. [ x - Odd, y - Odd ] - Plants a tree, waters it, and moves to the right. [ x - Odd, y - Even ] - Plows the ground, plants a carrot, waters it, and moves to the right. [ x - Even, y - Odd ] - Plows the ground, plants a carrot, waters it, and moves to the right. def collecting_trees_and_carrots(): for i in range(get_world_size()): for j in range(get_world_size()): if is_even(get_pos_x()) == True and is_even(get_pos_y()) == True: plant(Entities.Tree) use_item(Items.Water) move(East) elif is_even(get_pos_x()) == False and is_even(get_pos_y()) == False: plant(Entities.Tree) use_item(Items.Water) move(East) elif is_even(get_pos_x()) == False and is_even(get_pos_y()) == True: till() plant(Entities.Carrot) use_item(Items.Water) move(East) elif is_even(get_pos_x()) == True and is_even(get_pos_y()) == False: till() plant(Entities.Carrot) use_item(Items.Water) move(East) else: move(East) move(North) [ RU ] 31 дрон сажает морковку и деревья в шахматном порядке. [ EN ] 31 drones plant carrots and trees in a checkerboard pattern. def is_even(n): return n % 2 == 0 def planting_tree_carrots(): for i in range(get_world_size()): if is_even(get_pos_x()) == True and is_even(get_pos_y()) == True: plant(Entities.Tree) for i in range(3): use_item(Items.Water) move(North) elif is_even(get_pos_x()) == False and is_even(get_pos_y()) == False: plant(Entities.Tree) for i in range(3): use_item(Items.Water) move(North) elif is_even(get_pos_x()) == False and is_even(get_pos_y()) == True: till() plant(Entities.Carrot) for i in range(3): use_item(Items.Water) move(North) elif is_even(get_pos_x()) == True and is_even(get_pos_y()) == False: till() plant(Entities.Carrot) for i in range(3): use_item(Items.Water) move(North) else: move(East) def harvesting_treecar(): for i in range(get_world_size()): harvest() move(North) while True: set_world_size(31) clear() for i in range(31): if spawn_drone(planting_tree_carrots): move(East) while num_drones() > 1: pass for j in range(31): if spawn_drone(harvesting_treecar): move(East) while num_drones() > 1: pass Сбор тыкв / Collecting pumpkins [ RU ] Считывает количество ячеек на поле, вспахивает землю, сажает тыкву и движется вправо. [ EN ] Counts the number of cells on the field, plows the land, plants a pumpkin and moves to the right. def planting_pumpkins(): for i in range(get_world_size()): for j in range(get_world_size()): till() plant(Entities.Pumpkin) move(East) move(North) [ RU ] Если дрон увидит мертвую тыкву, то посадит новую и повысит переменную dead_pumpies на единицу. Если переменная равна нулю, цикл обрывается и функция заканчивается. [ EN ] If the drone sees a dead pumpkin, it will plant a new one and increment the dead_pumpies variable by one. If the variable is zero, the loop breaks and the function ends. def collecting_dead_pumpkins(): while True: dead_pumpies = 0 for i in range(get_world_size()): for j in range(get_world_size()): if get_entity_type() == Entities.Dead_Pumpkin: harvest() plant(Entities.Pumpkin) dead_pumpies += 1 move(East) else: move(East) move(North) if dead_pumpies == 0: break Сбор подсолнухов / Collecting sunflowers [ RU ] Первый метод сажает подсолнухи и собирает их. [ EN ] The first method is planting sunflowers and harvesting them. def planting_sunflowers(): for i in range(get_world_size()): for j in range(get_world_size()): till() plant(Entities.Sunflower) move(East) move(North) [ RU ] Второй метод выставляет размер поля на 31х31, спавнит 31 дрон, которые сажают подсолнух и собирают их. Вы можете изменить размер поля и количество итераций в цикле на количество ваших дронов минус 1 [ EN ] The second method sets the field size to 31x31, spawns 31 drones that plant sunflowers and collect them. You can change the field size and the number of iterations in the loop to the number of your drones minus 1 def planting_sun(): for i in range(get_world_size()): till() for i in range(3): use_item(Items.Water) plant(Entities.Sunflower) move(North) def harvesting_sun(): for i in range(get_world_size()): harvest() move(North) while True: set_world_size(31) clear() for i in range(31): if spawn_drone(planting_sun): move(East) while num_drones() > 1: pass for j in range(31): if spawn_drone(harvesting_sun): move(East) while num_drones() > 1: pass Сбор кактусов / Collecting cacti [ RU ] Первая функция сажает кактусы на всём поле. [ EN ] The first function plants cacti across the entire field. def planting_cactus(): for i in range(get_world_size()): for j in range(get_world_size()): till() plant(Entities.Cactus) move(East) move(North) [ RU ] Вторая функция сортирует кактусы, используя сортировку вставками. Сначала получает размер карты (по координате x), далее с помощью другой функции перемещает дрон в левую часть (checking_pos_row(), x:0). В цикле от 0 до n (размер карты по x) перебирает все кактусы, двигая дрон и проверяя состояние. Если состояние кактуса больше прошлого, передвигает в начало, пока не переместит все кактусы по возрастанию (слево направо). Данный метод не просчитывает состояние кактусов по координате y (возможно в будущем исправлю). [ EN ] The second function sorts the cacti using insertion sort. First, it gets the map size (by the x coordinate), then uses another function to move the drone to the left (checking_pos_row(), x:0). In a loop from 0 to n (the map size by x), it iterates through all the cacti, moving the drone and checking their state. If the state of a cactus is greater than the previous one, it moves it to the beginning, until it has moved all the cacti in ascending order (from left to right). This method doesn't calculate the state of the cacti by the y coordinate (this may be fixed in the future). def sorting_cactuses(): n = get_world_size() for i in range(0, n): checking_pos_row() drone_pos = 0 while drone_pos < i: move(East) drone_pos += 1 key = measure() move(West) drone_pos -= 1 j = i - 1 while j >= 0: val = measure() if val > key: if drone_pos > n: break swap(East) move(West) drone_pos -= 1 j -= 1 else: break while drone_pos < i: move(East) drone_pos += 1 Сбор костей (Змейка) / Bone Collection (Snake) [ RU ] Надевает шляпу динозавра, ищет яблоко и собирает его. Как только соберет 20 яблок, завершает цикл и надевает шляпу с подсолнухом. Ломается, как только дойдет до края поля, либо столкнется сама с собой. [ EN ] Puts on a dinosaur hat, searches for an apple, and collects it. Once it's collected 20 apples, it completes the cycle and puts on a sunflower hat. It breaks as soon as it reaches the edge of the field or collides with itself. change_hat(Hats.Dinosaur_Hat) def moving_strange(): next_x, next_y = measure() a = 0 while a < 20: dino_x = get_pos_x() dino_y = get_pos_y() if next_x > dino_x: move(East) elif next_x < dino_x: move(West) if next_y > dino_y: move(North) elif next_y < dino_y: move(South) dino_x = get_pos_x() dino_y = get_pos_y() if (dino_x, dino_y) == (next_x, next_y): next_x, next_y = measure() a += 1 change_hat(Hats.Sunflower_Hat) [ RU ] Также можно написать код, который просто проходит по всей карте и в любом случае собирает все яблоки. [ EN ] You can also write code that simply goes around the entire map and collects all the apples anyway. def moving_so_strange_one(): a = 0 while a < (get_world_size() // 2): for i in range(2): move(South) move(East) for i in range(2): move(North) move(East) a += 1 move(North) def moving_so_strange_two(): a = 0 while a < (get_world_size() // 2): for i in range(get_world_size() - 4): move(North) move(West) for i in range(get_world_size() - 4): move(South) move(West) a += 1 move(South) move(South) move(South) change_hat(Hats.Traffic_Cone) clear() change_hat(Hats.Dinosaur_Hat) while True: moving_so_strange_one() moving_so_strange_two() Сбор клада (Лабиринт) / Treasure Hunt (Labyrinth) [ RU ] Тут я уже не спец. Я сделал функцию по подсказкам в игре, которая просто идет по левому пути и в конце концов добирается до клада. Словарики сделал для того, чтобы дрон поворачивал влево, вправо и обратно при столкновении со стеной. Вторая функция делает то же самое, но только идет по правой стенке. [ EN ] I'm no expert here. I created a function based on in-game hints that simply follows the left path and eventually reaches the treasure. I created dictionaries so the drone turns left, right, and back when it hits a wall. The second function does the same thing, but follows the right wall. left_turn = { North: West, West: South, South: East, East: North } right_turn = { North: East, East: South, South: West, West: North } back_turn = { North: South, South: North, East: West, West: East } def follow_left_wall(): direction = North while get_entity_type() != Entities.Treasure: left_dir = left_turn[direction] if can_move(left_dir): move(left_dir) direction = left_dir continue if can_move(direction): move(direction) continue right_dir = right_turn[direction] if can_move(right_dir): move(right_dir) direction = right_dir continue back_dir = back_turn[direction] if can_move(back_dir): move(back_dir) direction = back_dir continue break if get_entity_type() == Entities.Treasure: harvest() plant(Entities.Bush) substance = get_world_size() * 2**(num_unlocked(Unlocks.Mazes) - 1) use_item(Items.Weird_Substance, substance) def follow_right_wall(): direction = North while get_entity_type() != Entities.Treasure: right_dir = right_turn[direction] if can_move(right_dir): move(right_dir) direction = right_dir continue if can_move(direction): move(direction) continue left_dir = left_turn[direction] if can_move(left_dir): move(left_dir) direction = left_dir continue back_dir = back_turn[direction] if can_move(back_dir): move(back_dir) direction = back_dir continue break if get_entity_type() == Entities.Treasure: harvest() plant(Entities.Bush) substance = get_world_size() * 2**(num_unlocked(Unlocks.Mazes) - 1) use_item(Items.Weird_Substance, substance) clear() plant(Entities.Bush) use_item(Items.Weird_Substance, 6) while True: follow_left_wall() [При получении новых дронов] [When you get new drones] clear() plant(Entities.Bush) substance = get_world_size() * 2**(num_unlocked(Unlocks.Mazes) - 1) use_item(Items.Weird_Substance, substance) while True: spawn_drone(follow_left_wall) spawn_drone(follow_right_wall) Множество дронов / Lots of drones [ RU ] Вот метод, который выставляет размер поля на 7x7, спавнит 7 дронов, которые сажают подсолнухи и они же их собирают. Код очень сырой, я не прям думал о нем. [ EN ] Here's a method that sets the field size to 7x7, spawns seven drones that plant sunflowers, and then harvests them. The code is very rough, I haven't really thought about it. clear() set_world_size(7) def sun(): for i in range(get_world_size()): till() plant(Entities.Sunflower) use_item(Items.Water) use_item(Items.Water) use_item(Items.Water) use_item(Items.Water) move(East) def har(): for i in range(get_world_size()): harvest() move(East) while True: clear() for i in range(7): if spawn_drone(sun): move(North) do_a_flip() do_a_flip() for j in range(7): if spawn_drone(har): move(North) do_a_flip() Автоматизация / Automation [ RU ] Все функции можно чередовать через while True, чтобы каждая из них выполнялась, пока вы занимаетесь другими делами. [ EN ] All functions can be interleaved using while True so that each one runs while you do other things. while True: clear() checking_pos_start() harvesting() collecting_trees_and_carrots() harvesting() harvesting() clear() planting_pumpkins() collecting_dead_pumpkins() harvesting() clear() planting_cactus() for i in range(get_world_size()): for j in range(get_world_size()): sorting_cactuses() move(North) harvesting() break
2026-02-18 01:00:20 发布在
编程农场
说点好听的...
收藏
0
0
