One thing with the if can_harvest() is that the way youre doing it now you just skip over whatever isnt ready even though it will probably be ready soon so it will be at full growth for a while wasting growing time. It also usually works out in a way where you end up getting to the other crops faster that also havent been grown yet. So my conclusion here is that its better to wait until its ready for harvesting in that spot. Now I think the game wants you to use the do_flip thing there but what actually works best in my experience is doing this: while not can_harvest(): quick_print("waiting") harvest() Who knows maybe you end up doing something like this later in the video its so long :) but if not i hope it helps! edit: you do have to check can_harvest but you dont have to with planting pumpkins, if there is already a pumpkin you dont use seeds and nothing happens.
This game is what they should use in school to teach kids programming. Even if it’s just a subset of Python, they would get immediate feedback and success and learn a lot of logic and general problem solving in code while having fun. Best way to learn, in my opinion!
when i was little, like 18 years ago, we used robot karol in school for a short time. pretty similar concept but you only can pick up and place blocks and markers. even has a free online version
I initally was getting mad while watching, thinking you are doing things in very inefficient ways. Then I bought the game myself. And I gotta say. Its not as obvious/easy when you write the code yourself. :D Thanks for the entertaining videos :)
Some conceptual things that can help you write better code: - Split your code consciously into "policy" versus "mechanism" code. Mechanisms are functions that *do*, but never *decide*. Policy is code that *decides*, but never (directly) *does*. Mechanisms are things you test the heck out of, policy are things where tests would only replicate the function. - Make functions that *ensure* things. Instead of having a "if carrots < 25: buy_carrots(25 - count(carrots));" have a "ensure_at_least(Items::Carrot, 25);" that does the complexity for you. - Prefer to avoid inversions. Make your functions positively-phrased, if you have an if statement with an else attached, put the positive form first. Inversions make reading harder, multiple inversions make you stop and try again. Think "if (have_enough(carrot))" and not "if (not are_short(carrot))".
Thank you, I needed to hear this. I actually do drafting for a living, but have some coding I've done to help be more efficient. The policy vs mechanism point really sounds helpful for how to approach a rewrite that I've been spinning my gears on.
I absolutely loved the brain breaking with the unified loop for pumpkins, although I did rage a tiny bit with the `return true`. Also, when the drone started just going sideways, I almost hit my head on a counter from laughing. Loving how the game is managing to find new ways of adding complexity to crops
Just as a tip, I made a function called "goto" that takes a coordinate and sends the drone there. With lists that allows you to keep a list of all the coords that have not got a grown pumpkin, and only check them on the next pass rather than traversing the whole farm. So the first and second passes check the whole area and then the drone just jumps between the ones that are yet to grow until all are grown, before harvesting. Super satisfying to watch as a bonus. You do need to also write a function for that which generates a list of all coords in the grid in a sensible order but that's fairly easy! :)
@@OlexaYT Haha amazing! Very much looking forward to that one then. There's some cool optimisations you can do in the goto() to make it decide whether to wrap around or not :) Good luck and loving this series!
Its weirdly actually not that much more efficient, I have that set up and compared them and you get maybe 25% more every minute. Which is great but stil weirdly underwhelming
@@lordthor5951A 25% gain might be quite significant. Let's say that an improvement in something reduced the number of cycles from 5 to 4; that's approximately a 25% gain. In this case, the initial loop and planting take quite some time, which is the same either way. That means the actual gain except the initial loop is even more significant than 25% gain. Even though the drone does not teleport and has to pass the grids, the efficiency gain is less significant. Also, it takes a while for a failed pumpkin grid to regrow. The drone keeps moving to all incomplete grids until they are completed more efficiently, but it's still limited by the growing time.
@@only2sea to put it more into perspective, my current speedrun time for the speedrun function in the game is around 40 minutes, I think i spend 4? minutes of that time on pumpkins. Compared to the naive solutions on the other harvests it also makes it pretty clear how its not that big of an improvements, my maze solution is shitty and like a third the speed of the fast maze solvers. My Cactus sort is pretty close to perfect and maybe double the speed of some of the slower but still competent cactus solves. The 25% on pumpkins are nice but weirdly not that great of an improvement. (Also for talk about the initial loop the 25% is based on pumpkins per minute, on a 10x10 grid, you go roughly from 80k to roughly 100k, the initial loop doesn't really matter in this)
i love that having a ruby background lets me understand python perfectly fine. also, you stumbling around a giant nested bowl of noodles and missing colons and stuff actually makes it even more believable that you do this professionally lmao
I don't know if you were already aware of the automation potential and the intention for a fully automated run (from zero) for the leaderboards at this point, but I really appreciate that you seem to already be thinking about how to force it to change tactics to produce what you need as you need it rather than doing it all manually. Bravo!
Bought this because of these vids and ended up playing about 8 hours. I have solutions I'm fairly happy with for all the crops (including Sunflowers which were pretty tricky), but I think I might just give up without doing mazes lol. These are so much fun to watch!
Mazes were really hard for me, but technically if you're willing to wait a bunch of time for every solution, you can solve them by making a while loop that moves the drone in a random direction and then stops when it's on the treasure
i just made my drone stick to the RHS as much as possible. similar to how i would solve a maze irl. only tricky thing is knowing the direction you came from as that affects what’s on the RHS. but you can do it with just lists. it’s not the MOST efficient but it’s not random and it does it as quick as i could think of
Yeah, the Maze was horrible. A naive "LHS' (or RHS) rule will just get you stuck in funny corridors and make no progress. I had to make about 3 distinct attempts before I finally got something semi-decent and actually reliable. I genuinely wish there was a can_move(dir) I could use to test if a path is blocked, instead of doing the solution I settled on of moving them moving back to test for forks in the path. For my last attempt, I made a recursive solver. Basically every time I detect more than 1 path (excluding the direction the drone came from), it will recurse the solver down each path. If there's 1, it just travels. And if it reaches a dead end, it just undoes all the steps that specific iteration did (by popping a list), so the caller can try the other forks. It still got stuck in loops, so I tracked the already visited tiles in a set once i unlocked those... There is another possibly faster one I want to try, but it basically would just make every step recursive, instead of only when reaching a fork. There's also some funny tricks you can do with dictionaries to make a path resolver, if you refertilise the treasure to solve the maze again (since you know where it warps to), but that requires contingencies if the maze moves walls.
Solved it using a BFS implementation, requierd me to create data structure for graphs, sad it takes it a little while to get quickest path thru the maze, but it can handel all level of mazes even after ferterlizing the chest to gain more loot.
Bought this game because of your videos. It's been super fun. I'm a software engineer in my day job. I'll probably have my kids play with this some too since they've been interested in learning to program. Thanks for bringing some attention to the game. :)
My thoughts, for 3 options: 1 - just making this code nicer by checking if you planted in the loop rather than the checks you have now. change it so it starts as planted=true, while planted, planted=false, and then if it needs to plant, planted=true; 2 - keep track of the last square you planted, or count down from how far ago you did. e.g. set it so when you plant, you set a variable to the size of the grid, then each time you move, count down. When the counter hits 0 (checked inside the part where you see the fully grown pumpkin) you harvest. May have an off by 1 error so double check. 3 - An alternative and likely slowly approach, stay on the square continually checking what is there, if nothing, plant the pumpkin, if a pumpkin, check if you can harvest, and if so move onto the next square. When you complete the grid, every square has a fully grown pumpkin, so harvest.
Okay, but in the middle of all the code optimization can we all just stop and admire that a 4*4 pumpkin happened with no pumpkins dying at 47:35 immediately after Tyler solved the pumpking planting code?
@@hamzamotara4304 I can't quite put my finger on it, but that math seems funky to me for some reason. It also might be that I'm just simply wrong (its probably the latter one haha)
Yay my favorite coding series continues! Please keep it going and eventually fully automate the entire game! After watching you initially go over this game, I have since got the game and completely automated it. I currently reset a total of 29 times. My first and only successful timed_reset() took a total of 2:07:15.154, but I'm sure I can get it way faster after figuring out which unlocks to do in what order and optimizing some of my function a bit. Loving the series! I'll ring the ding-a-ling bell next to the subscribe button so I make sure not to miss any future videos in the series! 🔔✌
I'm loving this series and game! It's fun going back to needing to solve things in a CS101 et al. way instead of just importing someone else's (way better) code. As someone who uses OOP as my favorite hammer, not having classes is the real challenge to this game for me! My solution for the pumpkin was just waiting (using fertilizer once unlocked) for the pumpkin to fully grow before moving on, replanting if it dies.
I honestly want to set up doing pumpkins like that, and then setting up a timer to see which way is faster. Bc I thought about that too but the growth just seems too slow
@@OlexaYT Idk when it gets unlocked, but at some point you get a new menu called "Stats" that measures your collection over the last 60s. That does what you want to.
Aren't the functions of the game like classes? I have no clue about coding, but I thought a class is simply a collection of code that always requires predefined variables. If no, what's the difference?
@@Solanaar Disclamer : Junior software engineer here so my knowlege and expirience is limited. But my 2 cents on this is Class is just a chunk of code that creates an Object in memory. Now objects are useful because they have their own variables and functions that you can access when you need. Think of it as an item in RPG, that item has it's stats (variables) and can do things like attack (which you would use do_damage function there). Drone for example is an object, it has its own stats (speed for example) and functions (harvest() for example). Coding for drone in the background of the game would be a class. Not sure what Olexa was thinking to do with classes but my guess would be to define the grid as class and then do some stuff with that, or perhaps define pumpkin as a class and then track how big it is untill it reached desired size. I guess. I dont know, my young junior programer brain is probably not developed enough to comprehend XD
@@OlexaYT It gets more effective the larger your field size. The time and/or fertilizer cost scales linearly with field size, but the harvest amount scales exponentially. Eventually the exponential term dominates and the linear term's contributions can be ignored. I'm not saying it's the optimal solution, but it's good enough for for me to not want to optimize further.
Hey bro just stumbled across your channel on episode 1 and I’m very happy you continued this series. I’m a comp sci student and watching this is so entertaining btw 7 hours and 1k likes on the vid 😁
27:30 you can do a 2-pass system. pass 1: Loop the grid once, and plonk a pumpkin in each space pass 2: this time you baby sit the square until the pumpkin has grown fully before moving on Use something like this for pass 2 while not can_harvest(): if get_entity_type(): #this means there is something on the cell do_a_flip() #this is just to waste time else: plant(Entities.Pumpkin) use_item(Items.Water_Bucket)
One thing you could do to improve pumpkin efficiency, is when you can’t harvest, you can reset checks to 0 then rather than at the end of your loop I think. I know it’ll reset your planting to that empty slot rather than the top left, but you’ll be able to harvest the pumpkins a lot quicker that way, rather than getting to the end of the grid, then checking from the top left to see if all squares are harvestable, since it seems like when pumpkins can be harvested, they won’t die
I don't think that changes anything as its a while loop and will only check if checks is = total_grid at the start of a new loop, which only happens at the top left The idea is good and it would make it more efficient but i think implementing that would require more changes
I think what you want to do is to count up how many pumpkins you have seen since the last planted one? Of course that'll still go through the entire field unless you make a special wait and check loop for the last pumpkin that was missing.
Actually my new favorite group of videos ( cant call them a series because the continuation is based on audience participation, I know) Im glad youre having fun with this and even taking the time to do stuff offline! Also, did I miss where you linked the Python YT Tutorials?
16:30 instead of doing addition checks, use a boolean variable, let's call it "field_full" that starts out true. If at least one cell in a pass cannot be harvested, it's set to false. If `field_full` variable at the end is true, harvest. At the beginning, before both fors, reset it to true. basically: while true: field_full = true for1 for2 if can_harvest pass else field_full = false plant move move if field_full harvest
Just a few pointer 1 you can do a function for each type of plant you want to plant with parameter to water, harvest, etc with an extra to harvest the non type plant you are trying to plant 2 your main can determine the priority you want it to harvest/plant and shift the crops instead of making it recursive, just make a couple of if for each type of harvest you want, or just make them in different panel and call them if you want but managing most of it in the main is easier specially when you dont have all the tech unlocked 3- For the pumpkin efficiency the most you can do is note the line you have them all and skip them instead of restarting from the beginning of doing them but you wont save much... 4- for your trade function just add a if to check the requirement for the trade for each seed you can buy, simple after that to just call and trade for whatever, just define your harvesting priority with the seed trade requirement if you have 1000 of hay, wood and carrot you can buy any seed in decend pack anyway Cant wait to see you get to the next part
I started playing this on Steam Deck away from home after watching you and it was like putting ankle weights on. I got home and I was amazed at my progress and what I remembered from your code-- I basically brute-forced my way past pumpkins but man, I can't wait to see your solutions for the rest! I'm currently stuck in a maze...
@@starwheels8648 I remember spending 5 hours on a level in Shenzhen IO then deciding the game wasn't for me. So far I like how this game gives a bit more freedom and simultaneously has something very close to the real coding language it's based on.
I throughly enjoy empathizing with the head spinning feeling when you run into something that just increases the complexity and all of a sudden all the code needs to be updated. I can’t wait for the further unlocks to make your brain itch like it did mine.
Hey Olexa! This video has actually really made me interested in learning python (which I know nothing about) but I think there’s one spot I might have noticed you could make your code just one line smaller, if you remove the Else command from the pumpkin code and just put the whole trade carrot, plant carrot, etc command under the harvest command in the (If entity is not pumpkin and not nothing) then you have no need for the else, at first I thought you could remove the Elif command but then realized that’s necessary for the check. Great video! I’m definitely downloading this game!
I dont have any coding experience at all but this is really interesting to watch. I can follow the majority of whats happening, though i definitely appreciate when you write things out instead of the proper shorthand.
Finally caught up to where you are in the game. I’ve fully automated grass, wood, and carrots. Pumpkins are on the docket for today so I can make it truly AFK until cacti. (Currently over 1M grass, wood, carrots)
Hell yea man. I learned the basics to python and I’m having a blast watching a pro in their flow state (still with head scratching). Not the advanced yet but soon.
I use the top right quadrant of my farm for pumpkins and only harvest on the top right tile. It's not 100% efficient but it does often give my pumpkins a chance to merge more often than not. I'm not sure if it's more efficient to wait for a mega pumpkin or to just harvest every pass but I like it enough for now
I think that’s definitely an approach. I kinda like the all or nothing more so I can specialize quickly in certain crops but it’s clear there’s many routes to success!
@@OlexaYT With the ability to clear the grid so quickly, why choose anyways? 😂 I should build out more specialized functions for targeted upgrades, I've just been farming everything at once in the background while I read on my other screen
Quick Tip: After planting pumpkins, check your farm for any dead plants. If you find any, replant them and save their locations. To quickly move to any point you need to check, use the Manhattan Distance algorithm. It’s super easy-just subtract your current position from the target position to find the distance.
I think the only way to be more efficient with the pumpkin is for the drone to know what square it is on, (I think it does from you printing indexes somehow in the first video?), and to implement some sort of pathfinding function you can give coordinates to. Then when you get lists, you record the coordinates where you plant and check only those squares to make sure they lived this time.
1:16 Since youʼre leaving the non-tree blocks fallow here, you donʼt need to water them. (I plant bushes there in the equivalent place in my code, on the assumption that if I want wood Iʼll want it from the trees and bushes. For that, water does help.) Edit: Oops. I guess thatʼs what I get for not waiting ten more seconds before commenting.
Just so you know, if Entities.Grass is ever the limiting factor for purchasing carrot seeds, you are creating an infinite recursive loop since your “while not trade_req…” check is not nested inside of an if statement first verifying that the active crop is carrots. If the crop was grass, the check would still be made, still fail, and you would never be able to actually plant carrots. Love these videos, makes me want to try this game out myself.
for the pumpkins i did a first pass where i would plant and water every spot, then on the second pass around i would stay in each empty spot and replant until it was fully grown before moving onto the next spot. seemed way more efficient then sweeping the entire grid every time even if there is just one empty spot left
@@OlexaYT possibly but imagine you have a big board. you are doing a full cycle every single time there is a failed check. your goto solution still has to be the best tho
Love the series and the dev needs to do something with the sound effects. Make it specific type of sound when do some specific action. my brain go nuts atm. xd
interesting thing with the giant pumpkin method of farming is that at the grid size 4x4 and smaller it is actualy slower than just harvesting while on the max size it becomes close to 3 times as efficient as the regular method
35:22 I see a couple issues eith the code. First is that if the world size increases over carrot max. Second is if carrots requirement is met or the wood requirement is finished half way then your losing by over planting.
I got something to say to the people who commented about wasting water and the can_harvest function... can_harvest is to ensure that you don't accidentally harvest an entity that isn't ready. So I agree with you, can_harvest is necessary, especially when the drone moves faster and faster. And the other thing about the comment for "wasting water"... It would be wasting it if not for the fact that the more empty tanks you have the faster you regenerate water, therefore this comment is plain unnecessary. But for those who really think they're wasting water... Put the water_me function under the plant function, simple as that.
Updated from my last code to use space in between for bushes, you just need more water: while True: #Getting world size and repeating for x in range(get_world_size()): for y in range(get_world_size()): #Harversting if can_harvest(): harvest() #Planting if (x+y) % 2: plant(Entities.Tree) else: plant(Entities.Bush) #Watering if get_water()
You can do a lot of shenanigans, including creating a pseudo array with just math to store growth state. Or use a binary flag. Add 2X-1 to the stored value if you can harvest, where X is the grids position, and then check if it's the maximum it can be for the grid size, and if so harvest.
Honestly love this lol Love coding And maybe an idea if you could check lane by lane so some how get the total scale of area Check harvesteble pumkins in one lane if harvest = total lane size "or i gues totaled check area cus lanes could be added up move to next lane, Tho you would need some kind of lane counter btw love the video! xD keep it up
you were discussing theoretically using lists once you get them, and i think the only missing piece from what you described was marking them as pumpkins in the data structure when they return true on can_harvest instead of when you first plant them. of course at that point theres room to develop a function to determine the shortest path to an arbitrary coordinate in order to streamline the replants, but who wants to do that >:3c
the way to minimize the search is to have a subset instead of the full grid, so if a line is full, you can skip it, but you have to basically unroll your inner loop, so it's very ugly without lists.
Most efficient way I got my pumpkins to work is just deleting the for loops, make it so it moves north every time it loops and every time the y = 0 move east Then just reset the checks to 0 when you plant a pumpkin and adding 1 to it every time a pumpkin is harvestable. This way it doesn’t have to check if it’s a big pumpkin separately.
I'm typing this comment before I see what you do. What I did with my pumpkins is I made a variable and incremented it every time the drone moves, then reset it every time the drone plants a pumpkin. Then I set it to harvest when that variable equals the number of tiles in my farm. This way, the drone checks every square to make sure it has a pumpkin in it so I get a perfect mega pumpkin every time. It's not that efficient though since once the mega pumpkin is complete, the drone has to do a complete flyover of the entire farm doing nothing before it harvests. So we'll see if you come up with something less wasteful. Edit 1: Making it calculate the grid size instead of just putting 16 is a great idea. This way it automatically scales up when you enlarge the farm. Edit 2: I don't understand the advantage of making a trade function. I have been simply using trade(Items.Whatever_Seed) directly before planting Edit 3: Yeah, you're pretty much doing what I did until you have lists and dictionaries which I don't know how to use, so I'm looking forward to the next couple of episodes.
I'm interested in seeing you handle sunflower. I wasn't proud of my first script, but I think my current script is decent. Interested to see your approach.
Ok so I was thinking about how I would automatize every crop at once and I have an idea: So you would have a main function that holds a stack of crops, these crops would be popped from the stack and used as the arguments to a function that calls the function that plants each crop. These functions would clear the board, check for the requirements of the crops, and put stuff onto the stack if the requirements are running low, if they run out the function would push the requirements and return. Else continue execution untill you obtained some threshold (relative to the previous amount of resources you had). If the stack is ever emptied you push some arbitrary stuff onto the stack and continue execution like normal.
what would in my opinion help your code is to not think of a n*x grid but a "wherever i am i can move n directions in all sides". and of course i dont know if this is a conscious decision to make it more understandable for your users, but for pumkins you can then think way like "as soon as i moved n*n times and i counted n*n harvestable pumpkins i am done" so whereever you counted the last pumpkin to have fully filled your field (hehe alliterations!) you can immediately harvest. wherever you stopped is your next starting pumpkin patch. also easier for trees in midst of other crops (think of you having a requirement of only needing 3 trees for your wood requirement, you dont want to start at 0x0, or 0x4, but at the first position you can currently plant a tree, then you want to save THIS position) this also then makes small pumpkins possible. hmmmmmmm what i didnt think about is that maybe a 3x3 mega-pumkin that goes "over an edge" doesn't merge together.... so maybe disregard the above for multi-cropping?
I just got this game the other day and I've done pretty much everything but companion planting(not sure if this is even worth it), cactus, dinos, and resetting. I was actually working on optimizing some of my code for pumpkins and sunflowers. I'm not looking forward too much to cactuses as I imagine it'll take many passes, unless I limit the area. Basically it requires writing a sorting algorithm but it's got to sort it in real time(like you actually see every swap) and in 2 dimensions. Not even sure what the dinos involve, I saw something about their being different types? Edit: Okay, I just coded Polyculture and I will say it's good for boosting a single crop if you want a lot, it does give you a 10 times increase if you can plant the companion crop, which you can't really do for /every/ crop so it's not a perfect multiplier but I did get like a ton of hay in a short amount of time.
I'd like to offer some coding suggestions, and please know I'm not trying to back seat game just want to offer some review feedback I've gotten in my own code reviews on the job: 7:35 using while != Can be dangerous because if anything causes you to increment over the limiter, it will continue infinitely. For instance if you want 300 but you buy seeds in pairs later on and get 301 then it will just keep purchasing forever. It's just good practice to use
@@OlexaYT I thought I would have more comments for you but honestly this was pretty solid. It's actually hard to do a proper code review for you because you are missing some core entry level programming concepts (arrays, lists, dictionaries). That's not your fault though, so hopefully I can offer some helpful insight once you can finally drop all the crops in your own grid data structure. Keep up the good work! I'm a senior software developer and this game looks very fun to me in a way that most pseudo programming games don't.
@@OlexaYT I know very well that tearing down old code can be even more cathartic than a job well done. Once you start rewriting, my last suggestion is, more comments! Comments take almost no time to read, they will frequently help you while you are coding, and they are invaluable if you have to come back to a project after any length of time. Seriously you will forget how your spaghetti functions even 48 hours after you wrote it.
Yeahh I’m not really concerned about properly commenting my code here because this is just a silly UA-cam series. I get your point but I’m not too concerned
I am smashing my head against the maze one i hope you will continue playing untill you reach that I did my pumpkin in a similar fashion but yours is way better and cleaner I really have no idea how to use alot of the functions available so i end up brute forcing stuff
"If you're not lost here, I'm impressed" Nah, I was just thinking about how I'd nest each resource into the planting > harvesting loop and run it indefinitely
by the way with a grid bigger then 4x4 it might be better to not use the bushes and only use the trees. You will still need to water them but you can also just water the spots where u plant the trees instead of planting on the entire grid if you place the water_me within the if can_harvest():. Atleast that's what i did and it seemed to give more wood then with the bushes yet not consume too much water.
while true: move_to(check_min(grid)); if (not can_harvest()): plant(pumpkin) else: harvest(); plant(); updateTile(grid) idea is move to first potentially empty tile, if you cannot harvest then plant. you need to use a list of tuple to represent a 2d grid, and use min(grid) to get the first tile that's not harvestable. same logic applies to Sunflower, except pumpkin value range is zero or one, and the Sunflower is zero to 16, also you use max(grid) function for finding the sunflower to harvest as opposed to finding the empty soil to plant a pumpkin using min(grid)
if( water/(water+empty) > percent ): water() This way you’re always watering at the equilibrium point when water-in = water-out, or in other words: precisely as much watering as you can sustain.
Man, I have unlocked lists and I am breaking my brain on trying to find a way that it stores the position of tiles with grown pumkins, so I don't have to go through the entire field searching for empty tiles every pass... But I am stuck... I have, however found a way to store the x & y coordiantes in a farmlength*farmlength-long array filled with tuples. But I don't even know where to use it...
You can convert an index in an array/list to xy coordinates on a grid and vice versa, so no need to have tuples inside of the list, but I have no idea of how you'll use it
@@ex2dxpi how so? Genuinely curious, cause I have no idea what I'm doing 😭 And I saw, that later on there will be mazes. I exped they will be generated randomly and it might be useful to store coordinates of tiles where multiple paths emerge... Or even map out the entire path inside that array.
@@Solanaar let W be the width of a rectangle, let H be the height of that rectangle, let A be a list of size W*H and let i be an index of the list A. To obtain the xy coordinates of the rectangle from i we do: x = i % W y = floor(i / H) And to obtain i from some xy we do: i = y * W + x
@@Solanaar let W be the width of a rectangle, let H be the height of that rectangle, let A be a list of size W*H and let i be an index of the list A. To obtain the xy coordinates of the rectangle from i we do: x = i % W y = floor(i / H) And to obtain i from some xy we do: i = y * W + x
It's inefficient but I can't find a better way, drone can only scan tiles one by one and moving to adjacents so even if you store already growns tiles you have to iterate all the matrix to check the ones still growing. (Or code a function to move drone from point A to B the fastest and use stored data but then you should code a way to optimize the rute between given points and so on... not worth imo xD)
Should you not have it be empty tanks and filled tanks because your infinite loop doesnt take into account empty tanks converting into filled tanks. I understand it being a stand alone fuction there isn't a issue but if you try to modular your function.
The only way to make the pumpkin function more efficient would be to exclude fully grown pumpkins from future checks on second pass with a flag, which also means you would have to code pathing for the drone to only move between the tiles that were not excluded, that right there sounds like a fucking nightmare with a lot of math and maybe matrices.
You know the drill... :)
I wonder if we could achieve a thousand likes on this comment of yours?
Black and Decker
One thing with the if can_harvest() is that the way youre doing it now you just skip over whatever isnt ready even though it will probably be ready soon so it will be at full growth for a while wasting growing time. It also usually works out in a way where you end up getting to the other crops faster that also havent been grown yet. So my conclusion here is that its better to wait until its ready for harvesting in that spot. Now I think the game wants you to use the do_flip thing there but what actually works best in my experience is doing this:
while not can_harvest():
quick_print("waiting")
harvest()
Who knows maybe you end up doing something like this later in the video its so long :) but if not i hope it helps!
edit: you do have to check can_harvest but you dont have to with planting pumpkins, if there is already a pumpkin you dont use seeds and nothing happens.
We need Rusty's Retirement python coding
it says 2 days
PAY UP 😅
This game is what they should use in school to teach kids programming. Even if it’s just a subset of Python, they would get immediate feedback and success and learn a lot of logic and general problem solving in code while having fun. Best way to learn, in my opinion!
when i was little, like 18 years ago, we used robot karol in school for a short time. pretty similar concept but you only can pick up and place blocks and markers. even has a free online version
I work tech in a school district and actually showed this to our department who looks into software to use.
I just recommended this game to a friend for that specific reason
My daughter is playing this right now and has learned so many basic programming concepts in such a short period of time.
I initally was getting mad while watching, thinking you are doing things in very inefficient ways. Then I bought the game myself. And I gotta say. Its not as obvious/easy when you write the code yourself. :D Thanks for the entertaining videos :)
That's how he gets you to buy the games.
Welcome to coding. "This should work. Why doesn't it work? What did I even do now? Why does it work now?! Don't touch anything."
It works on my local...
Talk for yourself, I am a programmer.
Some conceptual things that can help you write better code:
- Split your code consciously into "policy" versus "mechanism" code. Mechanisms are functions that *do*, but never *decide*. Policy is code that *decides*, but never (directly) *does*. Mechanisms are things you test the heck out of, policy are things where tests would only replicate the function.
- Make functions that *ensure* things. Instead of having a "if carrots < 25: buy_carrots(25 - count(carrots));" have a "ensure_at_least(Items::Carrot, 25);" that does the complexity for you.
- Prefer to avoid inversions. Make your functions positively-phrased, if you have an if statement with an else attached, put the positive form first. Inversions make reading harder, multiple inversions make you stop and try again. Think "if (have_enough(carrot))" and not "if (not are_short(carrot))".
Thank you, I needed to hear this. I actually do drafting for a living, but have some coding I've done to help be more efficient. The policy vs mechanism point really sounds helpful for how to approach a rewrite that I've been spinning my gears on.
Very helpful for a new programmer.
I've heard of code separation, single responsibility... But mechanism vs policy is very nice
I absolutely loved the brain breaking with the unified loop for pumpkins, although I did rage a tiny bit with the `return true`. Also, when the drone started just going sideways, I almost hit my head on a counter from laughing. Loving how the game is managing to find new ways of adding complexity to crops
Just as a tip, I made a function called "goto" that takes a coordinate and sends the drone there. With lists that allows you to keep a list of all the coords that have not got a grown pumpkin, and only check them on the next pass rather than traversing the whole farm.
So the first and second passes check the whole area and then the drone just jumps between the ones that are yet to grow until all are grown, before harvesting.
Super satisfying to watch as a bonus. You do need to also write a function for that which generates a list of all coords in the grid in a sensible order but that's fairly easy! :)
This is LITERALLY EXACTLY WHAT I THOUGHT OF TODAY haha. Gonna build that next episode
@@OlexaYT Haha amazing! Very much looking forward to that one then. There's some cool optimisations you can do in the goto() to make it decide whether to wrap around or not :) Good luck and loving this series!
Its weirdly actually not that much more efficient, I have that set up and compared them and you get maybe 25% more every minute. Which is great but stil weirdly underwhelming
@@lordthor5951A 25% gain might be quite significant. Let's say that an improvement in something reduced the number of cycles from 5 to 4; that's approximately a 25% gain. In this case, the initial loop and planting take quite some time, which is the same either way. That means the actual gain except the initial loop is even more significant than 25% gain.
Even though the drone does not teleport and has to pass the grids, the efficiency gain is less significant. Also, it takes a while for a failed pumpkin grid to regrow. The drone keeps moving to all incomplete grids until they are completed more efficiently, but it's still limited by the growing time.
@@only2sea to put it more into perspective, my current speedrun time for the speedrun function in the game is around 40 minutes, I think i spend 4? minutes of that time on pumpkins.
Compared to the naive solutions on the other harvests it also makes it pretty clear how its not that big of an improvements, my maze solution is shitty and like a third the speed of the fast maze solvers. My Cactus sort is pretty close to perfect and maybe double the speed of some of the slower but still competent cactus solves.
The 25% on pumpkins are nice but weirdly not that great of an improvement.
(Also for talk about the initial loop the 25% is based on pumpkins per minute, on a 10x10 grid, you go roughly from 80k to roughly 100k, the initial loop doesn't really matter in this)
i love that having a ruby background lets me understand python perfectly fine. also, you stumbling around a giant nested bowl of noodles and missing colons and stuff actually makes it even more believable that you do this professionally lmao
I don't know if you were already aware of the automation potential and the intention for a fully automated run (from zero) for the leaderboards at this point, but I really appreciate that you seem to already be thinking about how to force it to change tactics to produce what you need as you need it rather than doing it all manually.
Bravo!
Bought this because of these vids and ended up playing about 8 hours. I have solutions I'm fairly happy with for all the crops (including Sunflowers which were pretty tricky), but I think I might just give up without doing mazes lol.
These are so much fun to watch!
Mazes were really hard for me, but technically if you're willing to wait a bunch of time for every solution, you can solve them by making a while loop that moves the drone in a random direction and then stops when it's on the treasure
i just made my drone stick to the RHS as much as possible. similar to how i would solve a maze irl. only tricky thing is knowing the direction you came from as that affects what’s on the RHS. but you can do it with just lists.
it’s not the MOST efficient but it’s not random and it does it as quick as i could think of
I'm stuck at mazes currently, I'll clean up the rest of my code before trying that one
Yeah, the Maze was horrible. A naive "LHS' (or RHS) rule will just get you stuck in funny corridors and make no progress.
I had to make about 3 distinct attempts before I finally got something semi-decent and actually reliable.
I genuinely wish there was a can_move(dir) I could use to test if a path is blocked, instead of doing the solution I settled on of moving them moving back to test for forks in the path.
For my last attempt, I made a recursive solver.
Basically every time I detect more than 1 path (excluding the direction the drone came from), it will recurse the solver down each path.
If there's 1, it just travels.
And if it reaches a dead end, it just undoes all the steps that specific iteration did (by popping a list), so the caller can try the other forks.
It still got stuck in loops, so I tracked the already visited tiles in a set once i unlocked those...
There is another possibly faster one I want to try, but it basically would just make every step recursive, instead of only when reaching a fork.
There's also some funny tricks you can do with dictionaries to make a path resolver, if you refertilise the treasure to solve the maze again (since you know where it warps to), but that requires contingencies if the maze moves walls.
Solved it using a BFS implementation, requierd me to create data structure for graphs, sad it takes it a little while to get quickest path thru the maze, but it can handel all level of mazes even after ferterlizing the chest to gain more loot.
Bought this game because of your videos. It's been super fun. I'm a software engineer in my day job. I'll probably have my kids play with this some too since they've been interested in learning to program. Thanks for bringing some attention to the game. :)
My thoughts, for 3 options:
1 - just making this code nicer by checking if you planted in the loop rather than the checks you have now.
change it so it starts as planted=true, while planted, planted=false, and then if it needs to plant, planted=true;
2 - keep track of the last square you planted, or count down from how far ago you did.
e.g. set it so when you plant, you set a variable to the size of the grid, then each time you move, count down. When the counter hits 0 (checked inside the part where you see the fully grown pumpkin) you harvest. May have an off by 1 error so double check.
3 - An alternative and likely slowly approach, stay on the square continually checking what is there, if nothing, plant the pumpkin, if a pumpkin, check if you can harvest, and if so move onto the next square. When you complete the grid, every square has a fully grown pumpkin, so harvest.
Okay, but in the middle of all the code optimization can we all just stop and admire that a 4*4 pumpkin happened with no pumpkins dying at 47:35 immediately after Tyler solved the pumpking planting code?
pretty sick
16/5 = approx. 3, so on average he would only need to get lucky thrice for that.
@@hamzamotara4304 I can't quite put my finger on it, but that math seems funky to me for some reason. It also might be that I'm just simply wrong (its probably the latter one haha)
@@SchPal it probably is wrong, I'm not good at maths, but it feels intuitive.
2.8% chance to succeed all 16 tiles in a row
Yay my favorite coding series continues! Please keep it going and eventually fully automate the entire game! After watching you initially go over this game, I have since got the game and completely automated it. I currently reset a total of 29 times. My first and only successful timed_reset() took a total of 2:07:15.154, but I'm sure I can get it way faster after figuring out which unlocks to do in what order and optimizing some of my function a bit. Loving the series! I'll ring the ding-a-ling bell next to the subscribe button so I make sure not to miss any future videos in the series! 🔔✌
I'm loving this series and game! It's fun going back to needing to solve things in a CS101 et al. way instead of just importing someone else's (way better) code.
As someone who uses OOP as my favorite hammer, not having classes is the real challenge to this game for me!
My solution for the pumpkin was just waiting (using fertilizer once unlocked) for the pumpkin to fully grow before moving on, replanting if it dies.
I honestly want to set up doing pumpkins like that, and then setting up a timer to see which way is faster. Bc I thought about that too but the growth just seems too slow
@@OlexaYT Idk when it gets unlocked, but at some point you get a new menu called "Stats" that measures your collection over the last 60s. That does what you want to.
Aren't the functions of the game like classes? I have no clue about coding, but I thought a class is simply a collection of code that always requires predefined variables. If no, what's the difference?
@@Solanaar Disclamer : Junior software engineer here so my knowlege and expirience is limited.
But my 2 cents on this is Class is just a chunk of code that creates an Object in memory. Now objects are useful because they have their own variables and functions that you can access when you need. Think of it as an item in RPG, that item has it's stats (variables) and can do things like attack (which you would use do_damage function there). Drone for example is an object, it has its own stats (speed for example) and functions (harvest() for example). Coding for drone in the background of the game would be a class.
Not sure what Olexa was thinking to do with classes but my guess would be to define the grid as class and then do some stuff with that, or perhaps define pumpkin as a class and then track how big it is untill it reached desired size. I guess. I dont know, my young junior programer brain is probably not developed enough to comprehend XD
@@OlexaYT It gets more effective the larger your field size. The time and/or fertilizer cost scales linearly with field size, but the harvest amount scales exponentially. Eventually the exponential term dominates and the linear term's contributions can be ignored. I'm not saying it's the optimal solution, but it's good enough for for me to not want to optimize further.
Hey bro just stumbled across your channel on episode 1 and I’m very happy you continued this series. I’m a comp sci student and watching this is so entertaining btw 7 hours and 1k likes on the vid 😁
27:30 you can do a 2-pass system.
pass 1: Loop the grid once, and plonk a pumpkin in each space
pass 2: this time you baby sit the square until the pumpkin has grown fully before moving on
Use something like this for pass 2
while not can_harvest():
if get_entity_type(): #this means there is something on the cell
do_a_flip() #this is just to waste time
else:
plant(Entities.Pumpkin)
use_item(Items.Water_Bucket)
I contributed to getting the like goal, and as long as this game is a series, I will! I love this game
One thing you could do to improve pumpkin efficiency, is when you can’t harvest, you can reset checks to 0 then rather than at the end of your loop I think. I know it’ll reset your planting to that empty slot rather than the top left, but you’ll be able to harvest the pumpkins a lot quicker that way, rather than getting to the end of the grid, then checking from the top left to see if all squares are harvestable, since it seems like when pumpkins can be harvested, they won’t die
I don't think that changes anything as its a while loop and will only check if checks is = total_grid at the start of a new loop, which only happens at the top left
The idea is good and it would make it more efficient but i think implementing that would require more changes
I think what you want to do is to count up how many pumpkins you have seen since the last planted one? Of course that'll still go through the entire field unless you make a special wait and check loop for the last pumpkin that was missing.
Tyler: If youre not lost here Im impressed
I've been lost since episode 2!
Actually my new favorite group of videos ( cant call them a series because the continuation is based on audience participation, I know) Im glad youre having fun with this and even taking the time to do stuff offline! Also, did I miss where you linked the Python YT Tutorials?
Check description!
I'm surprised so many people are turning up for these. Keep it going 😂 i want more
16:30
instead of doing addition checks, use a boolean variable, let's call it "field_full" that starts out true. If at least one cell in a pass cannot be harvested, it's set to false.
If `field_full` variable at the end is true, harvest.
At the beginning, before both fors, reset it to true.
basically:
while true:
field_full = true
for1
for2
if can_harvest
pass
else
field_full = false
plant
move
move
if field_full
harvest
I realy started to learn coding because of your videos. Its very funny to learn with this game. Thanks for your content, love it❤
Just a few pointer
1 you can do a function for each type of plant you want to plant with parameter to water, harvest, etc with an extra to harvest the non type plant you are trying to plant
2 your main can determine the priority you want it to harvest/plant and shift the crops instead of making it recursive, just make a couple of if for each type of harvest you want, or just make them in different panel and call them if you want but managing most of it in the main is easier specially when you dont have all the tech unlocked
3- For the pumpkin efficiency the most you can do is note the line you have them all and skip them instead of restarting from the beginning of doing them but you wont save much...
4- for your trade function just add a if to check the requirement for the trade for each seed you can buy, simple after that to just call and trade for whatever, just define your harvesting priority with the seed trade requirement if you have 1000 of hay, wood and carrot you can buy any seed in decend pack anyway
Cant wait to see you get to the next part
Just started watching. Went from 1k like in 15 hours to 1k pikes and the video has been up 6 hours.
Bolster the videos friends! Need more farm drone
I started playing this on Steam Deck away from home after watching you and it was like putting ankle weights on.
I got home and I was amazed at my progress and what I remembered from your code-- I basically brute-forced my way past pumpkins but man, I can't wait to see your solutions for the rest!
I'm currently stuck in a maze...
this game was my first introduction to coding and it took me 5ish hours of failure to get a working code for mazes
@@starwheels8648 I remember spending 5 hours on a level in Shenzhen IO then deciding the game wasn't for me.
So far I like how this game gives a bit more freedom and simultaneously has something very close to the real coding language it's based on.
good stuff. One small tip, also put the plant logic in the "if can harvest: " block, or your plant() will destroy the growing plant
I throughly enjoy empathizing with the head spinning feeling when you run into something that just increases the complexity and all of a sudden all the code needs to be updated. I can’t wait for the further unlocks to make your brain itch like it did mine.
Hey Olexa! This video has actually really made me interested in learning python (which I know nothing about) but I think there’s one spot I might have noticed you could make your code just one line smaller, if you remove the Else command from the pumpkin code and just put the whole trade carrot, plant carrot, etc command under the harvest command in the (If entity is not pumpkin and not nothing) then you have no need for the else, at first I thought you could remove the Elif command but then realized that’s necessary for the check. Great video! I’m definitely downloading this game!
I dont have any coding experience at all but this is really interesting to watch. I can follow the majority of whats happening, though i definitely appreciate when you write things out instead of the proper shorthand.
Loving this! I’m so glad you’re doing more 😁
Finally caught up to where you are in the game. I’ve fully automated grass, wood, and carrots. Pumpkins are on the docket for today so I can make it truly AFK until cacti. (Currently over 1M grass, wood, carrots)
Love these videos! They are the perfect combo of fun and relaxing
Hell yea man. I learned the basics to python and I’m having a blast watching a pro in their flow state (still with head scratching). Not the advanced yet but soon.
Yay it's back! So glad I shared around the video lol
I use the top right quadrant of my farm for pumpkins and only harvest on the top right tile. It's not 100% efficient but it does often give my pumpkins a chance to merge more often than not. I'm not sure if it's more efficient to wait for a mega pumpkin or to just harvest every pass but I like it enough for now
I think that’s definitely an approach. I kinda like the all or nothing more so I can specialize quickly in certain crops but it’s clear there’s many routes to success!
@@OlexaYT With the ability to clear the grid so quickly, why choose anyways? 😂 I should build out more specialized functions for targeted upgrades, I've just been farming everything at once in the background while I read on my other screen
Quick Tip: After planting pumpkins, check your farm for any dead plants. If you find any, replant them and save their locations. To quickly move to any point you need to check, use the Manhattan Distance algorithm. It’s super easy-just subtract your current position from the target position to find the distance.
I was just finishing the last "episode" of this game and this drops.. Just perfect
Literally same!
Love the series, for someone who is interested in learning to code this game looks great
I think the only way to be more efficient with the pumpkin is for the drone to know what square it is on, (I think it does from you printing indexes somehow in the first video?), and to implement some sort of pathfinding function you can give coordinates to. Then when you get lists, you record the coordinates where you plant and check only those squares to make sure they lived this time.
You know how funny it is watching you talking to a program I’m dying XD
Never thought id be sitting around excited for someone to start using python lists, but here we are.
1:16 Since youʼre leaving the non-tree blocks fallow here, you donʼt need to water them. (I plant bushes there in the equivalent place in my code, on the assumption that if I want wood Iʼll want it from the trees and bushes. For that, water does help.)
Edit: Oops. I guess thatʼs what I get for not waiting ten more seconds before commenting.
Just so you know, if Entities.Grass is ever the limiting factor for purchasing carrot seeds, you are creating an infinite recursive loop since your “while not trade_req…” check is not nested inside of an if statement first verifying that the active crop is carrots. If the crop was grass, the check would still be made, still fail, and you would never be able to actually plant carrots. Love these videos, makes me want to try this game out myself.
Yup, it’s a good catch. It’s fixed in next epi bc I redid that function
for the pumpkins i did a first pass where i would plant and water every spot, then on the second pass around i would stay in each empty spot and replant until it was fully grown before moving onto the next spot. seemed way more efficient then sweeping the entire grid every time even if there is just one empty spot left
I think it’s less efficient because there’s a LOT of dead time waiting
@@OlexaYT possibly but imagine you have a big board. you are doing a full cycle every single time there is a failed check. your goto solution still has to be the best tho
Beauty of code, lotta solutions for something!
Love the series and the dev needs to do something with the sound effects. Make it specific type of sound when do some specific action.
my brain go nuts atm. xd
interesting thing with the giant pumpkin method of farming is that at the grid size 4x4 and smaller it is actualy slower than just harvesting while on the max size it becomes close to 3 times as efficient as the regular method
Father olexa has blessed us once again with a banger video 🙏
None of this is complicated, but I love to watch it. I just don’t know why… But that doesn’t matter, just watchin‘ and enjoying
35:22 I see a couple issues eith the code. First is that if the world size increases over carrot max. Second is if carrots requirement is met or the wood requirement is finished half way then your losing by over planting.
Definitely an issue for both, it’s just something I’m not too concerned about. It’s an extremely minimal concern in the long run
I love this so much! Will be getting the game!
Damn Olexa, bought the game, ahead of you now but still loving the content.
I got something to say to the people who commented about wasting water and the can_harvest function...
can_harvest is to ensure that you don't accidentally harvest an entity that isn't ready. So I agree with you, can_harvest is necessary, especially when the drone moves faster and faster.
And the other thing about the comment for "wasting water"...
It would be wasting it if not for the fact that the more empty tanks you have the faster you regenerate water, therefore this comment is plain unnecessary.
But for those who really think they're wasting water...
Put the water_me function under the plant function, simple as that.
Updated from my last code to use space in between for bushes, you just need more water:
while True:
#Getting world size and repeating
for x in range(get_world_size()):
for y in range(get_world_size()):
#Harversting
if can_harvest():
harvest()
#Planting
if (x+y) % 2:
plant(Entities.Tree)
else:
plant(Entities.Bush)
#Watering
if get_water()
I bought the game because of your playthrough! Made it to 83 in the world leaderboard 😊
Same solution here, and same frustration for the last big pumpkin scan 😄
Yay more code!
You can do a lot of shenanigans, including creating a pseudo array with just math to store growth state. Or use a binary flag. Add 2X-1 to the stored value if you can harvest, where X is the grids position, and then check if it's the maximum it can be for the grid size, and if so harvest.
Honestly love this lol
Love coding And maybe an idea
if you could check lane by lane
so some how get the total scale of area
Check harvesteble pumkins in one lane if harvest = total lane size "or i gues totaled check area cus lanes could be added up
move to next lane, Tho you would need some kind of lane counter
btw love the video! xD keep it up
you were discussing theoretically using lists once you get them, and i think the only missing piece from what you described was marking them as pumpkins in the data structure when they return true on can_harvest instead of when you first plant them.
of course at that point theres room to develop a function to determine the shortest path to an arbitrary coordinate in order to streamline the replants, but who wants to do that >:3c
the way to minimize the search is to have a subset instead of the full grid, so if a line is full, you can skip it, but you have to basically unroll your inner loop, so it's very ugly without lists.
I would love to see you play bitburner!
Pros: Another code-based game
Cons: It's in javascript
JavaScript 🤮
Lovely game. Got to watch you based on this game recommendation.
Most efficient way I got my pumpkins to work is just deleting the for loops, make it so it moves north every time it loops and every time the y = 0 move east
Then just reset the checks to 0 when you plant a pumpkin and adding 1 to it every time a pumpkin is harvestable. This way it doesn’t have to check if it’s a big pumpkin separately.
Please more of this 🎉
Keep it up olexa 💪💪💪💪
I'm typing this comment before I see what you do. What I did with my pumpkins is I made a variable and incremented it every time the drone moves, then reset it every time the drone plants a pumpkin. Then I set it to harvest when that variable equals the number of tiles in my farm. This way, the drone checks every square to make sure it has a pumpkin in it so I get a perfect mega pumpkin every time. It's not that efficient though since once the mega pumpkin is complete, the drone has to do a complete flyover of the entire farm doing nothing before it harvests. So we'll see if you come up with something less wasteful.
Edit 1: Making it calculate the grid size instead of just putting 16 is a great idea. This way it automatically scales up when you enlarge the farm.
Edit 2: I don't understand the advantage of making a trade function. I have been simply using trade(Items.Whatever_Seed) directly before planting
Edit 3: Yeah, you're pretty much doing what I did until you have lists and dictionaries which I don't know how to use, so I'm looking forward to the next couple of episodes.
I'm interested in seeing you handle sunflower.
I wasn't proud of my first script, but I think my current script is decent. Interested to see your approach.
Ok so I was thinking about how I would automatize every crop at once and I have an idea:
So you would have a main function that holds a stack of crops, these crops would be popped from the stack and used as the arguments to a function that calls the function that plants each crop.
These functions would clear the board, check for the requirements of the crops, and put stuff onto the stack if the requirements are running low, if they run out the function would push the requirements and return. Else continue execution untill you obtained some threshold (relative to the previous amount of resources you had).
If the stack is ever emptied you push some arbitrary stuff onto the stack and continue execution like normal.
I think you’re overcomplicating things haha
@@OlexaYT most like yes
@@OlexaYT most like yes
Frankly, I love this, my brain go brr, from working code satisfaction.
I did more coding yesterday in this game then in my entire school year of software development
I can't believe you missed the opportunity to give this game an A++ score.
what would in my opinion help your code is to not think of a n*x grid but a "wherever i am i can move n directions in all sides". and of course i dont know if this is a conscious decision to make it more understandable for your users, but for pumkins you can then think way like "as soon as i moved n*n times and i counted n*n harvestable pumpkins i am done" so whereever you counted the last pumpkin to have fully filled your field (hehe alliterations!) you can immediately harvest. wherever you stopped is your next starting pumpkin patch. also easier for trees in midst of other crops (think of you having a requirement of only needing 3 trees for your wood requirement, you dont want to start at 0x0, or 0x4, but at the first position you can currently plant a tree, then you want to save THIS position) this also then makes small pumpkins possible.
hmmmmmmm what i didnt think about is that maybe a 3x3 mega-pumkin that goes "over an edge" doesn't merge together.... so maybe disregard the above for multi-cropping?
Yeah the plantable grid is not wrapping even though the drone can wrap.
I just got this game the other day and I've done pretty much everything but companion planting(not sure if this is even worth it), cactus, dinos, and resetting. I was actually working on optimizing some of my code for pumpkins and sunflowers. I'm not looking forward too much to cactuses as I imagine it'll take many passes, unless I limit the area. Basically it requires writing a sorting algorithm but it's got to sort it in real time(like you actually see every swap) and in 2 dimensions. Not even sure what the dinos involve, I saw something about their being different types?
Edit: Okay, I just coded Polyculture and I will say it's good for boosting a single crop if you want a lot, it does give you a 10 times increase if you can plant the companion crop, which you can't really do for /every/ crop so it's not a perfect multiplier but I did get like a ton of hay in a short amount of time.
I'd like to offer some coding suggestions, and please know I'm not trying to back seat game just want to offer some review feedback I've gotten in my own code reviews on the job:
7:35 using while != Can be dangerous because if anything causes you to increment over the limiter, it will continue infinitely. For instance if you want 300 but you buy seeds in pairs later on and get 301 then it will just keep purchasing forever. It's just good practice to use
Fair yeah!
@@OlexaYT I thought I would have more comments for you but honestly this was pretty solid. It's actually hard to do a proper code review for you because you are missing some core entry level programming concepts (arrays, lists, dictionaries). That's not your fault though, so hopefully I can offer some helpful insight once you can finally drop all the crops in your own grid data structure. Keep up the good work! I'm a senior software developer and this game looks very fun to me in a way that most pseudo programming games don't.
Yeah I will likely end up completely rewriting 90% of this when I have lists and dictionaries. But we’ll see :)
@@OlexaYT I know very well that tearing down old code can be even more cathartic than a job well done. Once you start rewriting, my last suggestion is, more comments! Comments take almost no time to read, they will frequently help you while you are coding, and they are invaluable if you have to come back to a project after any length of time. Seriously you will forget how your spaghetti functions even 48 hours after you wrote it.
Yeahh I’m not really concerned about properly commenting my code here because this is just a silly UA-cam series. I get your point but I’m not too concerned
I am smashing my head against the maze one i hope you will continue playing untill you reach that
I did my pumpkin in a similar fashion but yours is way better and cleaner
I really have no idea how to use alot of the functions available so i end up brute forcing stuff
You've gotten into the dark magic... Of quadruple negatives!
You can not do classes, but closures do work.
Generally recursions work great.
"If you're not lost here, I'm impressed"
Nah, I was just thinking about how I'd nest each resource into the planting > harvesting loop and run it indefinitely
In plant_trees() move the can_harvest() block out of the modulo since it does not depend on the results of the modulo.
I’d love to have this on the iPad. I rarely use my PC these days.
by the way with a grid bigger then 4x4 it might be better to not use the bushes and only use the trees. You will still need to water them but you can also just water the spots where u plant the trees instead of planting on the entire grid if you place the water_me within the if can_harvest():. Atleast that's what i did and it seemed to give more wood then with the bushes yet not consume too much water.
while true:
move_to(check_min(grid));
if (not can_harvest()):
plant(pumpkin)
else:
harvest(); plant(); updateTile(grid)
idea is move to first potentially empty tile, if you cannot harvest then plant.
you need to use a list of tuple to represent a 2d grid, and use min(grid) to get the first tile that's not harvestable.
same logic applies to Sunflower, except pumpkin value range is zero or one, and the Sunflower is zero to 16, also you use max(grid) function for finding the sunflower to harvest as opposed to finding the empty soil to plant a pumpkin using min(grid)
if( water/(water+empty) > percent ): water()
This way you’re always watering at the equilibrium point when water-in = water-out, or in other words: precisely as much watering as you can sustain.
28:42 "quick and dirty episode" *looks at runtime* 51:24 Oh no.
12:33 the yield of a WHAT?!
900 likes in 6 hours. Looks like you’re gonna be making another episode
I think that you have too many while loops, you need one main loop. Conditions in the main loop check all variables and call functions if true.
Just finished episode 2, will continue tomorrow :)
Let's goo!!
Instead of can_harvest call you can do a:
if (get_entity_type() == None):
to see what entity is below the drone, none means the seed died
Man, I have unlocked lists and I am breaking my brain on trying to find a way that it stores the position of tiles with grown pumkins, so I don't have to go through the entire field searching for empty tiles every pass... But I am stuck...
I have, however found a way to store the x & y coordiantes in a farmlength*farmlength-long array filled with tuples. But I don't even know where to use it...
You can convert an index in an array/list to xy coordinates on a grid and vice versa, so no need to have tuples inside of the list, but I have no idea of how you'll use it
@@ex2dxpi how so? Genuinely curious, cause I have no idea what I'm doing 😭
And I saw, that later on there will be mazes. I exped they will be generated randomly and it might be useful to store coordinates of tiles where multiple paths emerge... Or even map out the entire path inside that array.
@@Solanaar let W be the width of a rectangle, let H be the height of that rectangle, let A be a list of size W*H and let i be an index of the list A.
To obtain the xy coordinates of the rectangle from i we do:
x = i % W
y = floor(i / H)
And to obtain i from some xy we do:
i = y * W + x
@@Solanaar let W be the width of a rectangle, let H be the height of that rectangle, let A be a list of size W*H and let i be an index of the list A.
To obtain the xy coordinates of the rectangle from i we do:
x = i % W
y = floor(i / H)
And to obtain i from some xy we do:
i = y * W + x
@@ex2dxpi uh, that sounds like something I tried to do but couldn't figure out, thank you!
When you plant the pumpkin, it looks like you could just plant twice before moving maybe with a delay
For engagement! Lets goooooooo! 🎉
It's inefficient but I can't find a better way, drone can only scan tiles one by one and moving to adjacents so even if you store already growns tiles you have to iterate all the matrix to check the ones still growing. (Or code a function to move drone from point A to B the fastest and use stored data but then you should code a way to optimize the rute between given points and so on... not worth imo xD)
Should you not have it be empty tanks and filled tanks because your infinite loop doesnt take into account empty tanks converting into filled tanks. I understand it being a stand alone fuction there isn't a issue but if you try to modular your function.
Next you're gonna say, oh start doing a question of the day to farm engagement. 😂
For code availability very reasonable way to do pumpkin
The only way to make the pumpkin function more efficient would be to exclude fully grown pumpkins from future checks on second pass with a flag, which also means you would have to code pathing for the drone to only move between the tiles that were not excluded, that right there sounds like a fucking nightmare with a lot of math and maybe matrices.
Yup, this is basically the only way. I have an idea but it’s super ugly haha. Might write it offline and show it to you guys next time
I think a minX/maxX minY/maxY bounds narrowing would probably do it well enough, scanning smaller subsets of the farm.
I am not 100% sure whats going on but its looks dope