The Farmer Was Replaced

The Farmer Was Replaced

Aperture Jun 4, 2024 @ 9:18pm
Troubles with list.insert() What am I doing wrong?
The insert on the top break point and append on the third break point work, but the insert in the middle break point throws an error saying "This method doesn't exist". The index is in range. I copy and pasted the list name to make sure it wasn't a typo. What am I doing wrong?
https://steamcommunity.com/sharedfiles/filedetails/?id=3261458527
Last edited by Aperture; Jun 4, 2024 @ 9:21pm
< >
Showing 1-6 of 6 comments
owenz Jun 4, 2024 @ 9:55pm 
In normal python you can insert, in this implementation you seem not able to.

You can pop/append though.

For regular python what you are doing is correct though.

a_list = [1, 2, 3, 4, 5] five = a_list.pop() print(a_list) # output: [1, 2, 3, 4] a_list.append(five) print(a_list) # output: [1, 2, 3, 4, 5]
Aperture Jun 4, 2024 @ 10:02pm 
It's in the in game documentation and works in some cases. Is it just bugged then?

https://steamcommunity.com/sharedfiles/filedetails/?id=3261475328
owenz Jun 4, 2024 @ 10:10pm 
As a note, don't bother doing it that way you are going about. You can honestly just store the information inside of a fixed size array/list and just treat the board as a 0 - n^2 array.

Example

*** IMPORTANT NOTE ***
Shadowing does not work as it does in normal python so attempt to not have conflicting variable names

def get_pos(x, y, n): return x + y * n def get_x_y(pos, n): return pos % n, pos // n # Have to use modulus division def move_to(x, y): # Not implemented pass board_info = [] ws = get_world_size() # Init the board any way you see fit, doing a loop here to do so. Default to (None, 0) for i in range(0, n * n): board_info.append((None, 0)) for i in range(0, n * n): ix, iy = get_x_y(i, ws) move_to(ix, iy) ent = get_entity() mval = measure() board_info = (ent, mval)[/code]

The above will init an array with the info that would be useful. It is then possible to go through it to grab the info you want, and see that you are working with sunflowers creating a sub array with the positions of the max measured petals would be very helpful

Example:

# Get the max value max_pos = 0 max_val = 0 for i in range(0, n * n): if board_info[1] > max_val:
max_pos = i

# Now Let us move to the position and harvest and replant
cx, cy = get_pos(max_pos)
move_to(cx, cy)
harvest()
plant(Entities.Sunflower)[/code]

The above are just examples and are not fully implemented or bug free but should give a good show of how to go about using the given data structures to solve this problem.

By all means though attempt to do it in any way you see fit as these are just suggestions.
owenz Jun 4, 2024 @ 10:11pm 
Originally posted by Aperture:
It's in the in game documentation and works in some cases. Is it just bugged then?

https://steamcommunity.com/sharedfiles/filedetails/?id=3261475328


I would go with bugged, it is likely the same issue that is causing shadowing to not work 100% of the time.
Aperture Jun 4, 2024 @ 11:26pm 
My variable insert was what was messing with it.
owenz Jun 4, 2024 @ 11:56pm 
Originally posted by Aperture:
My variable insert was what was messing with it.

So it was shadowing, I would call that a bug as insert should be a method of a class and should not be overridden by a variable name. That means it is somehow getting into the global space.

Overall weird behavior. Cool thing you figured it out though.
< >
Showing 1-6 of 6 comments
Per page: 1530 50