The Farmer Was Replaced

The Farmer Was Replaced

Pumpkins
Hey all,

I don't know a bunch about Python and sorry if this has been asked before. Seems steam mobile doesn't have a search function for discussions, or I'm blind.

Anyways, I don't have code to share at the moment, but essentially I have my farm set up to keep a running inventory, choose the lowest result of num_items() and prioritize that. Because of that, my mega pumpkin can end up being interrupted, with crops suddenly switching.

Probably not the best way of managing things, but it's where I've ended up.

My question is: is there a way to code a function that will look at what pumpkins are still alive, choose the best n*n pumpkin for the area, move to those specific coordinates and harvest it once done then changing back to the prioritized crop?

I've been doing a bit of back and forth with the Boot.dev AI assistant trying to come up with something, but the amount of variables and statements it came up with considerably slowed my drone down.

Any advice is appreciated!
< >
Showing 1-7 of 7 comments
How I handle it is to add the coordinates of each newly-planted pumpkin to a list, then step through the list going back to those locations to see if the pumpkin can be harvested (in which case it's fully grown and I can take it off the list), or if it's a dead pumpkin (in which case I replant it and add it back to the list to be checked again).

Something like:

def move_to((x, y)): # find shortest route to target position # you'll need to make this one yourself # there are plenty of examples on the forums checklist = [] def plant_pumpkin(): plant(Entities.Pumpkin) checklist.append((get_pos_x(), get_pos_y())) def pumpkin_harvest(): while len(checklist) > 0: move_to(checklist.pop()) if get_entity_type() == Entities.Dead_Pumpkin: plant_pumpkin() elif not can_harvest(): checklist.append((get_pos_x(), get_pos_y())) do_a_flip() harvest() def make_pumpkins(): for x in range(get_world_size()): for y in range(get_world_size()): plant_pumpkin() move(North) move(East) pumpkin_harvest()

Note: this may or may not be correct; I kinda spewed it from memory, and haven't tested it at all. The point was to show the general thought process (ie, the algorithm), not to hand you finished code.
Originally posted by Kinhoshi:
Hey all,
My question is: is there a way to code a function that will look at what pumpkins are still alive, choose the best n*n pumpkin for the area, move to those specific coordinates and harvest it once done then changing back to the prioritized crop?

These pumpkins get harvested anyway, if your next fruit logic starts with harvest() and not simply with clear() or till(). :D
doesn't matter if you pick up the biggest pumpkin or random pumpkins. they all get picked.
Originally posted by Klauß 🍔🍻:
Originally posted by Kinhoshi:
Hey all,
My question is: is there a way to code a function that will look at what pumpkins are still alive, choose the best n*n pumpkin for the area, move to those specific coordinates and harvest it once done then changing back to the prioritized crop?

These pumpkins get harvested anyway, if your next fruit logic starts with harvest() and not simply with clear() or till(). :D
doesn't matter if you pick up the biggest pumpkin or random pumpkins. they all get picked.
I have specific check on all other instances to not harvest a pumpkin so that I can potentially make a mega pumpkin before harvesting. Unless I give up lol then I'll take that check away.
I suppose you could measure() each pumpkin, adding them to a dictionary with their coordinates.

Then when it's time to harvest/abort, go through each of the keys (the pumpkin IDs generated by measure) and find the longest list of coordinates; that should be the largest pumpkin.

Ideally, though (in my opinion), you would not stop in the middle of making pumpkins; the yield is much increased if you simply treat a call to make pumpkins as a "full field" activity, and don't return to the crop selection routine until you have harvested a full-field (or at least 6x6) pumpkin.

You'll want to do the same thing for "dinosaur", so you might as well bite the bullet and figure it out now.
Originally posted by umop-apisdn:
I suppose you could measure() each pumpkin, adding them to a dictionary with their coordinates.

Then when it's time to harvest/abort, go through each of the keys (the pumpkin IDs generated by measure) and find the longest list of coordinates; that should be the largest pumpkin.

Ideally, though (in my opinion), you would not stop in the middle of making pumpkins; the yield is much increased if you simply treat a call to make pumpkins as a "full field" activity, and don't return to the crop selection routine until you have harvested a full-field (or at least 6x6) pumpkin.

You'll want to do the same thing for "dinosaur", so you might as well bite the bullet and figure it out now.
I appreciate your input and I pretty much do have this set up already, but I was/am trying to think of a solution that would essentially work if I ever decided to have multiple crops on the field at once.

I only just unlocked sunflowers (been tackling this for a day or so before unlocking more lol) so I'm not familiar with measure() yet.
Guys, I got it. Don´t know if it is what you are looking for, but works perfectly to me.
harvest()
while True:
if get_ground_type()!=Grounds.Soil:
till()
move(East)
elif get_entity_type()!=Entities.Pumpkin:
harvest()
plant(Entities.Pumpkin)
use_item(Items.Water, 4)
elif get_pos_x()==get_pos_y()==11 and measure(North)==measure(East)==measure():
harvest()
move(South)
elif get_pos_y()==11:
move(East)
move(North)
else:
move(North)

Fully automated, but work as a "scan", going through the whole column over and over until it completes the Pumpkin and harvest it. Don´t need an exact value for measure, just need to be the same on both corners, basically.
The Steam forum's input system breaks formatting. You can use [code] ... [/code] tags to work around it. Also, avoid using variables named i, b, or u, because those are tags, too, and they will get "swallowed" if you access an array, list, or dict with them... and the rest of your text will become italicized, bolded, or underlined.

Originally posted by Gerodex:
harvest() while True: if get_ground_type()!=Grounds.Soil: till() move(East) elif get_entity_type()!=Entities.Pumpkin: harvest() plant(Entities.Pumpkin) use_item(Items.Water, 4) elif get_pos_x()==get_pos_y()==11 and measure(North)==measure(East)==measure(): harvest() move(South) elif get_pos_y()==11: move(East) move(North) else: move(North)
< >
Showing 1-7 of 7 comments
Per page: 1530 50

Date Posted: Oct 26, 2025 @ 7:39pm
Posts: 7