TFWR. Spawn drones.

In "The Farmer Was Replaced" game there is quite an interesting option - one can spawn drones in order to operate the farm more efficiently. This option is advanced because of language tricks and game limitations. Nevertheless, the problems and opportunities are quite similar to those which "adult" programmers have with multithreading and multiprocessing. Therefore, it's quite an interesting topic to master.

In this post, I just want to show the very basic use of this technology. I drew a small smiley on a piece of paper and put the coordinates of pixels in this simple picture into a list of tuples. Then I ask one drone to visit these places one by one and call the spawn_drone() function at each place. This spawn_drone function requires a function as a parameter - hello, metaprogramming - and executes this function in the new drone. This time the function is very simple: wait_forever. It just does nothing. But an infinite loop inside the function keeps the drone alive. When the function ends, the corresponding drone ceases to exist.

All in all, you can now see a smiling face made of drones. Happy hacking!

Code on github