Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Fun activity The Farmer Was Replaced

simong1993

Diamond Coder
Staff Team
Guardian
Hey All has anyone here ever player The Farmer Was Replaced?

At the moment i am at the sun flower stage but for the life of me i cannot work out how im going to beat this. So i need to remember where the sunflowers are, store there value and only harvest the one with the most sun in it or i destory the lot :S

current code 😀


Code:
def main():
    height = location()
    
    while True:
            
        if can_harvest() or get_entity_type() == None:
            harvest()
            plant(whattoplant())
            move(North)
        else:
            move(North)
            
        previouspos = get_pos_y()
            
        
        if height == get_pos_y(): 
            if can_harvest():
                harvest()
            move(East)

def location():
    maxheight = 0
    while True:
        if get_pos_y() > maxheight or get_pos_y() == maxheight:
            maxheight = get_pos_y()
            move(North)
        elif maxheight > get_pos_y():
            return maxheight

def whattoplant():
    watering()
    if num_items(Items.Hay) < 30000:
        
        if get_ground_type() != (Grounds.Soil):
            pass
        else:
            till()
        return Entities.Grass
    
    elif num_items(Items.wood) < 30000:
          
        totallocaction = get_pos_y() + get_pos_x()
            
        if is_even(totallocaction):
            return Entities.Tree
        else:
            return Entities.bush
        
    elif num_items(Items.Carrot) < 20000:
        
        if get_ground_type() == (Grounds.Soil):
            pass
        else:
            till()
        trade(Items.Carrot_Seed)
        return Entities.Carrots   
    
    elif num_items(Items.Pumpkin) < 20000:
        
        if get_ground_type() == (Grounds.Soil):
            pass
        else:
            till()
        trade(Items.Pumpkin_Seed)
        return Entities.Pumpkin

def is_even(n):
    return n % 2 == 0

def watering():
    if num_items(Items.Water_Tank) < 50:
        trade(Items.Empty_Tank)
    
    if get_water() <= 1:
        use_item(Items.Water_Tank)

Lets have a chat and see if we can beat this and heck does anyone else play this or have any code based game sugestions 😀
 
Back
Top Bottom