r/TheFarmerWasReplaced

Have you quick or merge sorted 🌻or🌵?? So far I have used the game to teach O(n^2) at school...

Have you quick or merge sorted 🌻or🌵?? So far I have used the game to teach O(n^2) at school...

Hey everyone! I’m a CS teacher, and for this new school year, I decided to change the "static" whiteboards and use The Farmer Was Replaced to teach Python and real coding logic.

The game has proven to be a fantastic sandbox for exploring sorting algorithms. So far, in my classes (and videos), we have successfully implemented both Bubble Sort and Insertion Sort from scratch to optimize the drone's cactus and sunflower harvests, mapping the data using tuples (no dictionaries just yet). You could also easily implement a Selection Sort for this task without much trouble.

However, all of these algorithms have a time complexity of O(n^2). They work perfectly fine for the small grid constraints of the game, but it got me thinking about pushing the limits for huge farms (for example via mod where you can have custom grid sizes)

So, here is my question for the community: Has anyone here managed to implement a Quick Sort or a Merge Sort within the game? If yes, was it worth it?

I'm really curious to know if the O(n \log n) efficiency actually makes a noticeable difference in the game's execution time, or if the overhead makes it impractical for the drone.

Idk if the following lines count as self promotion but.. if you are learning Python, brushing up on your data structures, or just want to see how to code an Insertion Sort purely "by hand", here is the link to the vido explanation (original audio is in spanish, but there is an english translation)

🌻 https://youtu.be/4-M9qHaSa5Q

🌵https://youtu.be/ffkjLm7jPvE

I'd love to read your experienceson the Quick Sort / Merge Sort challenge for the drone.

u/TotalUnlucky2814 — 12 days ago

why my code isn't working consistently ?

https://preview.redd.it/qesn6t376cth1.png?width=1111&format=png&auto=webp&s=47a239ef31294932ea0ad18dc52e316f27c89f3c

https://preview.redd.it/o8yl7gcd6cth1.png?width=334&format=png&auto=webp&s=d43b892c21e30423fda0b44e7cda7cb116406be8

it starts working normally , and then in the second or third run , it starts placing stuff randomly for some reason
it suppose to always make it like the first picture

reddit.com
u/armori5 — 12 days ago

HLEP HOW DO SUNFLOWERS WORK

i am striggling rn. im trying to like measure the size of the flower and the amount of that size and if i run out scan the whole thing but it says my variables aren't defined. please and thank you. also I have no idea if my idea is even good in the first place anyway.

u/marshmallow9570 — 13 days ago

Any tips for spawned drones spawning other drones?

I'm trying to optimize my maze program to spawn a new drone at intersections with multiple paths. For instance, if a left-hugging drone finds an intersection where a right turn is also possible but would be ignored, I'd like to send a new drone off in that direction to hug the right wall. As a bonus, when the next maze is generated, all the drones start on the new maze from where they are.

It's hard or impossible to single-step through a specific spawned drone, but when the sub-drone I'm single-stepping finds an intersection with both left and right choices, every other "sub-drone" suddenly spawns a new drone in that one step, including ones that are just following a long straight path.

Are there rules for spawned drones spawning other drones?

Thanks. I've gotten great help and insights in this sub, and I'm grateful.

reddit.com
u/FetchTheCow — 11 days ago

Need help from a total Newbie

Hi guys, I have done a bit of programming on C++ before and I have done... something on this game; I have made, for now, a system to farm the first three resources that works somewhat well but harvests only on a straight line; how can I develop it so that it also moves sideways?

https://preview.redd.it/uq762quilath1.png?width=1399&format=png&auto=webp&s=b4d38845d15f87ef3fdc2a4279559f8a4b327eda

reddit.com
u/federicio27 — 12 days ago