The Python King Returns with Spaghetti Cacti

Ойындар

Program and optimize a drone to automate a farm and watch it do the work for you. Collect resources to unlock better technology and become the most efficient farmer in the world. Improve your problem solving and coding skills.
Check out The Farmer was Replaced here:
-- store.steampowered.com/app/20...
Check out my Python tutorials:
• VARIABLES, TYPES, AND ...
#games #olexa #strategy #farming #automation #programming
Thanks for watching!
-- Extra Olexa Content - / @olexa2
-- Discord: / discord
-- Twitch: / olexastream
-- Twitter: / olexayt
-- Reddit: / olexa
-- My Nexus Gamestore: www.nexus.gg/olexa
-- KZread: / olexayt
-- Business Email: olexakid@gmail.com
-- Join this channel to get access to perks:
/ @olexayt
Music I Use:
-- www.bensound.com/free-music-f...
-- Spring by Ikson
-- Harris Heller Streambeats Lofi Spring by Ikson | ikson.com/tell-your-story
Music promoted by www.free-stock-music.com

Пікірлер: 196

  • @aperturist1019
    @aperturist1019Ай бұрын

    Dont play this game so much that you end up hating it! Its also sad to see interest in this series tapering off as well. I love watching you code. I'm learning so much playing this game in my free time. Im still a cs student, but it makes me want to start grinding some leetcode problems!

  • @fabienso5889

    @fabienso5889

    Ай бұрын

    If a game makes you want to grind out leetcode problem either you got a problem or the game has one

  • @aperturist1019

    @aperturist1019

    Ай бұрын

    @@fabienso5889 haha so true. But its something on the to do list. The game just makes me feel inspired to get it done!

  • @crazyhouston4
    @crazyhouston4Ай бұрын

    The problem in your pumpkin code is that after you're at the last spot to fill you only fill it once and don't account for it might again not fully grow.

  • @ingiford175
    @ingiford175Ай бұрын

    one thing you can do to make your stuff easier is add a direction to the measure call measure (North) as measure does take a direction

  • @phantomofthelpac

    @phantomofthelpac

    Ай бұрын

    It doesn't take a direction, yet. You do unlock that overload when you unlock Dinosaurs.

  • @ingiford175

    @ingiford175

    Ай бұрын

    @@phantomofthelpac Ah, did not know that was a later unlock

  • @Orblets

    @Orblets

    Ай бұрын

    @@phantomofthelpac you can use it before dino's. I dont have dino's unlocked and I'm using it

  • @danielrhouck

    @danielrhouck

    Ай бұрын

    @@Orblets I wish the game said what caused which unlocks. I have a lot of functions I never explicitly unlocked, like `random`, and I wish I knew where I got them.

  • @raysmith34

    @raysmith34

    Ай бұрын

    I found it made cactus very easy

  • @iconica9516
    @iconica9516Ай бұрын

    you know what would be sick? the drone speed upgrade being an upgrade to its max possible speed, and the player being able to set its speed to be a specific number (1-X, increases by 1 for each upgrade) that way some programs that fail if shit goes too fast can stay stable

  • @chlgv

    @chlgv

    Ай бұрын

    The game has that. It is called set_execution_speed(). It is unlocked with the Debug_2 upgrade. I mainly used it so I could see what my drone was doing while I was writing its code.

  • @iconica9516

    @iconica9516

    Ай бұрын

    @@chlgv oh, cool

  • @SkinSolder
    @SkinSolderАй бұрын

    I sincerely respect your transparency. It's a really good thing that you communicate how you feel with us from the creator's point of view. Appreciate you and I just thinking magic computer man with the wizard words is fun watch 🎉

  • @ColeNOXyd2nd
    @ColeNOXyd2ndАй бұрын

    my 3rd and simplest solution for mazes was: go through the maze following the left-hand-to-wall rule, until you have visited all spaces and are back on the start space for every step note the x/y-pos, and the direction you entered it (also make a note where the treasure is) you now have a loop that allows you to move to every space on the board even when a wall disapears find the position you are on in the loop, find the position of the treasure in the loop, move the steps between both this can be optimized in different ways

  • @jeffreygordon7194

    @jeffreygordon7194

    Ай бұрын

    This was the solution I used. I optimized it by attempting to reach the treasure whenever it's in an adjacent square. In the beginning this doesn't help, but as walls disappear, shortcuts are created and it speeds up. If you wanted to optimize it further, you could use a* pathfinding on your map and check the known walls on your paths for gaps, updating the map when you find them. This would be very efficient.

  • @zeiram666
    @zeiram666Ай бұрын

    You can pass a direction to the measure function. So you don't have to move back and forth between adjacent squares to know whether the next cactus is bigger or smaller. 🙂

  • @mathieularocque1953

    @mathieularocque1953

    Ай бұрын

    I think that only work once you have the dinosaur unlocked, when you only have cactus the measure doesnt take an argument...

  • @Icedragonscale

    @Icedragonscale

    Ай бұрын

    I thought you already unlock that with the sunflowers, where you also can measure the sunflower petals on the tiles right next to the one you're on

  • @pelimies5352

    @pelimies5352

    Ай бұрын

    @@mathieularocque1953 That is unlocked when the measure() is, so with sunflowers.

  • @finncher4215

    @finncher4215

    Ай бұрын

    @@mathieularocque1953 you can use it before dinosaurs

  • @jdsims9064
    @jdsims9064Ай бұрын

    Don’t burn out! I do enjoy seeing a return of this game, but moderation is a good thing.

  • @realmaggymage
    @realmaggymageАй бұрын

    I think the problem with the edge cases is because of the corners. If you're in a corner, you end up wrapping around and checking. Let's say you're in the bottom right corner. The part of the code that runs when you're on the bottom edge checks the land to the left, top and right of the land you're on, so when you're up against the right-most edge, it wraps around and checks there. And then you afterwards run the code that happens when you're on the right edge, which checks the land to the top, left and bottom of the land you're on, so when the land you're on is on the bottom edge, it wraps around and checks the land on the very top.

  • @Icedragonscale
    @IcedragonscaleАй бұрын

    I love this series so much. I started to play the game parallel to you after I saw the first video. I always try to find a solution to the challenges before the video, to then see how you approach the problem. But please don't burn yourself out over the game. I'd love to see this series continue, but only as long as you have fun. Also the video doesn't have to come instantly after 1k likes are hit. I think waiting a week is absolutely fine (and it gives me more time optimizing my code xD)

  • @DoctorLipton
    @DoctorLiptonАй бұрын

    Please, we beg of you, continue this series 🙏

  • @OlexaYT

    @OlexaYT

    Ай бұрын

    There’s really only one thing left and that’s Dinos. I don’t think people want it that badly for me to do it tbh

  • @DoctorLipton

    @DoctorLipton

    Ай бұрын

    @OlexaYT :( Ig I understand it seems to take more and more work the more you progresse

  • @JB-fh1bb

    @JB-fh1bb

    Ай бұрын

    ​@@OlexaYTI don't think it's done often on YT, but some of us would watch you going back to zero and doing a "clean room restart"

  • @theKashConnoisseur

    @theKashConnoisseur

    Ай бұрын

    @@OlexaYT not just dinos, the real fun starts when you automate the entire run start to finish. It's a good 40% of the game just getting your first leaderboard entry.

  • @replikvltyoutube3727

    @replikvltyoutube3727

    Ай бұрын

    Why don't you try and do it yourself?

  • @emmaporter8160
    @emmaporter8160Ай бұрын

    I know absolutely nothing about coding but I discovered this channel from the series! Love your stuff love this series.

  • @cookiedoe6068
    @cookiedoe6068Ай бұрын

    I’ve never coded anything in my life, so it looks like you’re performing miracles to me lol This was such a fun series to binge and I found a new channel to watch, so wins all around

  • @idobn11
    @idobn11Ай бұрын

    watching as Tyler writes bugs only to find them 30 minutes later is my new guilty pleasure

  • @br0wn13

    @br0wn13

    Ай бұрын

    No it makes me nervous

  • @schuhbeedu
    @schuhbeeduАй бұрын

    two things regarding the cactus code: measure can take in a direction like measure(North) and this kind of measuring doesn't wrap around the map

  • @OlexaYT

    @OlexaYT

    Ай бұрын

    Oh wow yeah that changes a ton

  • @finncher4215

    @finncher4215

    Ай бұрын

    It does actually wrap

  • @akin0m
    @akin0mАй бұрын

    Hey, I just want you to know I found your channel because of this game, and after watching the first episode I bought and beat the game, and have a nice leaderboard time to boot. I hope you continue this series!

  • @Leftysrev3nge

    @Leftysrev3nge

    28 күн бұрын

    Same.

  • @mathieularocque1953
    @mathieularocque1953Ай бұрын

    To make map just do Map = [] For x in range(get_world_size()): Map.append([]) For y in range(get_world_size()): Map[x].append(whatever value you need) Then just use x and y position to know where you are in the map For the maze you can use another list with direction For the cactus just use the measure in That will let you compare with neighbour without moving If you are out of bound then you are on edge Also consider doing negated edge like If x != 0 : Check(west) If x != Get_world_size()-1: Check(East) Same for y this way you always check a direction only if you are net on the exception

  • @junkjunker842

    @junkjunker842

    Ай бұрын

    "For the maze you can use another list with direction" Something like do a scan of the whole maze, collecting which directions are available from each location? Then instead of continuing on using the left-wall or right-wall methods relying on the physical hedges, use the recorded map of available directions instead? That would get around the problem of the loops appearing in the maze. If you're always using the generated map data without the loops, the drone doesn't know the loops/new hedge gaps are there and flys past them. Maybe not optimal for speed, but yeah that would make it "safe" and would make mazes automatable without needing the manual helpful kicks when stuck in loops.

  • @AP-kl3qe
    @AP-kl3qeАй бұрын

    I have been loving this series. I have learnt so much from your approach to these problems. Thank you! For the cacti I had a totally different strategy to yours. I just sorted all the rows individually first and then all the columns. Worked like a charm for me. I hope you keep on going with this series!

  • @billy65bob
    @billy65bobАй бұрын

    For the cacti I used a map to track the sizes, and then tried to swap with the neighbours (starting with north and east) as I flew across. Probably don't need the map, since I never noticed you can pass a Direction to Measure(). The MVP in my solution was a 'GetNeighbourCoords' function that took a direction and returned None for directions that wrap the map; the coord pair was otherwise a key for the map.

  • @akin0m

    @akin0m

    Ай бұрын

    You cannot measure in a direction when you unlock the cactus, only after you unlock dinosaurs.

  • @wilmofosho
    @wilmofoshoАй бұрын

    I know almost nothing about coding but love playing games and i watched the whole video. Really cool to see your thought process and execution on solving the cactus problem.

  • @DonnyCarroll
    @DonnyCarrollАй бұрын

    Just now noticed that a fully grown farm sized pumpkin looks like a Cheez-It.. 😂

  • @Leftysrev3nge

    @Leftysrev3nge

    28 күн бұрын

    So that's where Taco Bell got their idea from.

  • @jeffreyblack666
    @jeffreyblack666Ай бұрын

    The pumpkin issue really isn't that your guy is too fast. It is that you see a growing pumpking and assume it will grow and not die. You need to keep checking the pumpkins until they are grown.

  • @Leftysrev3nge

    @Leftysrev3nge

    28 күн бұрын

    I built both versions of this to test for timing. One that does multiple passes until the field is fully planted. The other where the drone sits in one spot until the pumpkin is confirmed and then moves on. The difference in times was negligible on average over several iterations. I would have thought keeping the drone moving would cut down on any lost time from having to run several laps. But alas...

  • @jeffreyblack666

    @jeffreyblack666

    28 күн бұрын

    @@Leftysrev3nge I think the issue is that for the one making multiple passes, it wastes a lot of time going over pumpkins which have already grown, as only a small fraction need replanting. In the extreme at the end it passes over all pumpkins and checks them just for one to grow. At least for large enough fields with slow enough drones, the pumpkin has already grown by the time it does a loop. So plant and wait is faster than plant and run through the entire field. With bad enough timing, you just miss it so you go through the entire field seeing them growing, and they finish just after so an entire loop is wasted. I think this could also make it interesting seeing how speed and field size effects it (and if you have power), and hydration levels. Also, what about one which does an initial pass, planting and adding each location to a list, then iterating through the list to go directly to that plant and check it, where if it is still growing or you need to replant it gets added back to the list, otherwise it is removed, and you keep going until the list is empty? For a possible speed boost, at the start of the checking the list, wait until it grows or dies before moving on.

  • @Leftysrev3nge

    @Leftysrev3nge

    27 күн бұрын

    @@jeffreyblack666 To your first point, "wasting" time is deceptive, especially for fast enough drones. Sure, mid-game probably doesn't help much until you get more speed upgrades. Waiting for each or rerunning the field both land at about the same end result. I think early on, the time it takes to find a gap is enough time for the pumpkins to grow and die so nothing is really wasted versus just sitting there. By the time you get zippy, it doesn't really matter that you're running the field again; you already land at the next gap before it actually hurts you. To your second, that's basically what Tyler did here. Problem is: recording to a list, you still have to wait to see if it dies before replanting; by the time you do all that, you might as well just replant for all the "effort" to review and update a gap list. Overall, it largely evens out across each version. I thought about doing a checkerboard, and alternating every other pass, while also checking for gaps, but again, every move costs time and more conditionals (or complexity) just slows you down. I do like your idea of finding the sweet spot where speed and world size and hydration all work in your favor, and then find ways to harness that at different levels.

  • @bumbomumboni4735
    @bumbomumboni4735Ай бұрын

    I've been looking forward to this so thank you

  • @vladdangel
    @vladdangelАй бұрын

    I'm so sad that you don't like doing this... I wish I were on a situation where I could make it so you didn't have to work a job as a main source of income and could just enjoy what you do here. I get so much enjoyment from listening and watching your brain at work, I just wish you did as well.

  • @Leftysrev3nge
    @Leftysrev3nge28 күн бұрын

    It's remarkable to me how our brains evolve as we process new understanding. The way my approach gradually changes and improves over time as i learn new ways to think about different problems and their solutions. Some of them are inefficient of course, but often I'll spot areas that can be optimized and reduced for brevity.

  • @imputhmaximuth1205
    @imputhmaximuth1205Ай бұрын

    for your cactus code I believe that the maximum number of times you would need to loop is the same as the world size, and this is for a case when a size 9 is at (0,0) or a size 0 is at (get_world_size()-1,get_world_size()-1)

  • @Jaden7328
    @Jaden7328Ай бұрын

    I love watching you play this game!

  • @replikvltyoutube3727
    @replikvltyoutube3727Ай бұрын

    Thanks man, what a walkthrough. Working professionally with it I lacks time for games like that :D

  • @shaylevinzon540
    @shaylevinzon540Ай бұрын

    It's the first series I watch in your channel and it's mesmerising. As a dev myself I'd love to see you take those into next level coding, especially with dic already available. I know you probably do that a lot in your day job and it's tiresome to do it again, but the extra value and benefit from it will be invaluable. Think about it 🎉

  • @nsc_notncs
    @nsc_notncsАй бұрын

    I just want to say I love these and I hope you keep doing them👍❤

  • @marcbennett9232
    @marcbennett9232Ай бұрын

    mazes broke me. but I want to take another stab at it. I really hope this does well enough to finish, it helps to have someone as pleasant to listen to as you to help me learn from your successes and mistakes.

  • @boxers41
    @boxers41Ай бұрын

    Hey Olexa I love this series. please keep it up. its such a great series and im loving it. :)

  • @Ehnderz
    @EhnderzАй бұрын

    Getting to this now. i did a similar thing to you. For the count issue, I added to the count every time i swapped, like you did at the beginning, and then I did a check at the end of the x,y range loop to see if the count was larger than 0. If it was i reset it back to zero and the loop repeated. Once count was equal to 0 i break the loop and harvest. Thank for the vids man, very cool to see!

  • @Ehnderz

    @Ehnderz

    Ай бұрын

    Also check you on edge checks, i think you mixed up x and y. for example, your first on edge check is if x == 0. You have it checking West North and East, but x == 0 is the left most column, so you should be checking North East and South, etc. To get the count function to work you need to add exceptions for corners as well, but all that can still go in On Edge to save checks.

  • @jinsawl6055
    @jinsawl6055Ай бұрын

    really loving this series!

  • @whoagainwastaken32times
    @whoagainwastaken32timesАй бұрын

    Yippee!!!! New farming video (its the only videos I watch)

  • @xXpezcoolXx
    @xXpezcoolXxАй бұрын

    Again, I like your video of this game. Brings a second view on problems I have with my code. (I'm early in the video while commenting) You can plant a pumpkin and use fertilizer on it so all squares are planted and grown.

  • @uniaddict
    @uniaddictАй бұрын

    Looks like you’re only checking one edge at the corners! Love the series!

  • @doodwithayoutoob
    @doodwithayoutoobАй бұрын

    I am loving this series! Thinking the previous episode was the last one made me buy and complete the game. Took about 32 hours according to Steam, lol.

  • @Youwanttodream
    @YouwanttodreamАй бұрын

    Love this series !

  • @vladdangel
    @vladdangelАй бұрын

    I like the idea of figuring your code out, then swapping it out for a viewer code if it's more efficient. Show how awesome you are, then show a different approach! It'll really help show appreciation to your commentors for their contributions too =)

  • @Chalo122790
    @Chalo122790Ай бұрын

    Thanks forgetting here, and for the effort. And finally Dinos next time, will be fun to see that

  • @daniel12294
    @daniel12294Ай бұрын

    I find it amusing how Tyler gets stuck in the edge conditions he wrote at the start and refuses to change them to the point of deciding to not check if the field is sorted and just use a number of times. Tyler if you read this, the issue is your edge conditions and checking if it is equal to edge. Instead you can check if it is different to edge and perform that singular change. For example if x0, then swap west. this adds the edge cases to the main code and you will not get stuck infinetly swaping the four corners!

  • @williammoody4950
    @williammoody4950Ай бұрын

    I thought I'd be bored out of my mind by this but I'm so invested

  • @MateusAntonioBittencourt
    @MateusAntonioBittencourtАй бұрын

    I did a simple insertion sort, first in the x axis. After all rows were sorted. I ran the insertion sort in the Y axis. It was surprisingly quick. BTW, you should use a flag to know when all the cactus were sorted. Make a "while flag" loop. Set the flag to false, then when a swap happens, set the flag to true. Next loop, if no swap happens, the loop ends and you can harvest.

  • @Donzw

    @Donzw

    Ай бұрын

    Did you check the time? I've been trying a bunch of stuff but can't seem to get it below 24s (for 10x10) and I'm not sure it makes sense to keep trying or if it's already kinda close to optimal

  • @finncher4215

    @finncher4215

    Ай бұрын

    @@Donzw I got mine to around 17 seconds at 10x10

  • @matthewmitchell1538

    @matthewmitchell1538

    24 күн бұрын

    That’s exactly the solution I implemented

  • @ElectricalInsanity
    @ElectricalInsanityАй бұрын

    I understand your code on a spiritual level; it's what gets written at 3 am because management/customer is in a panic and it's got to get done before you can sleep. You'll fix your sins it in the morning (this is a lie).

  • @junkjunker842

    @junkjunker842

    Ай бұрын

    # Fix this horrific temporary hack for the new feature I was told about 5 minutes before the deadline. (aka this code is now doomed to hit production.)

  • @jamfox971
    @jamfox971Ай бұрын

    Thanks for another one ♥

  • @secretjameser
    @secretjameserАй бұрын

    Have fun with the series!

  • @TheDilla
    @TheDillaАй бұрын

    When I did cacti, I made a 2d list which maps out the grid and all the lengths, then my code first checks if a swap is necessary, and then moves to the spot if it finds one. This makes it a lot faster after the first loop when only a few swaps are necessary. Also there's definitely some problem with your on edge code, cause it should stop swapping and exit the loop. anyways its something like: cacti_length = [ ] for x in range(get_world_size()): cacti_column = [ ] for y in range(get_world_size()): cacti_column.append(measure()) move(North) cacti_length.append(cacti_column) move(East) and then if you call cacti_length[x][y], it will give you the measurement for that coordinate which I think is neat.

  • @Johan-iw6mb
    @Johan-iw6mbАй бұрын

    I know that you may not find this fun or entertaining but I'd really like to see a video where you optimise the code. Yes it is functioning and works most of the time but seeing you breaking down the issues and troubleshoot the code and optimizing it would be a blast.

  • @proudpichu
    @proudpichu14 күн бұрын

    The cactus stuff can be sped up by using a simple sorting algorithm like bubble sorting. I did this and it works perfectly.

  • @MYSTRAS001
    @MYSTRAS001Ай бұрын

    I just sorted each row and column individually for cactuses. If you sort east-west first, you can then sort north-south. Once a row is sorted, you don't have to sort it again! It's also much easier to tell if it's sorted.

  • @VodShod
    @VodShodАй бұрын

    for the maze I just made the simple hug left wall, then once it stopped working I used that to get close and moved to the chest manually. there is a max it reaches where the treasure doesn't move from where it is. It gives 150K when harvested.

  • @pelimies5352
    @pelimies5352Ай бұрын

    I really like watching you play this game, even though your code is way more complicated than it needs to be. Couple of suggestions: first you should replace the check_direction(dir) with measure(dir), as others have already commented. Second, why not just use insertion sorting algorithm for the cactuses? You would first sort in the x direction and then the y direction. I did get a bit fancy with my code for the cacti, I made it always plant in a square and it plants from the bottom left because I couldn't figure out how to modify it to plant from the top. If the field_size variable is set to get_world_size(), it will plant the cactuses from the bottom row and go as long as it has seeds. The code should still work, I hope. Here's the code I made (I modified my function calls to fit your already made code, if there is some I missed, you should be able to replace it for one of yours): def farm_cacti(): goto(0, 0) while num_items(Items.Cactus_Seed) > 0: field_size = min(max(1, num_items(Items.Cactus_Seed) ** 0.5 // 1), get_world_size()) for y in range(field_size): for x in range(field_size): if num_items(Items.Cactus_Seed) == 0: break goto((x, y)) plant(Entities.Cactus) if field_size == 1: while True(): if can_harvest(): break harvest() continue goto(1, 0) for y in range(field_size): sorted = False while not sorted: curr_cactus = measure() if curr_cactus == None: break next_x = (get_pos_x() + 1) % field_size while get_pos_x() != 0 and curr_cactus swap(West) move(West) goto(next_x, y) if next_x == 0: sorted = True goto(0, 1) for x in range(field_size): sorted = False while not sorted: curr_cactus = measure() if curr_cactus == None: break next_y = (get_pos_y() + 1) % field_size while get_pos_y() != 0 and curr_cactus swap(South) move(South) goto(x, next_y) if next_y == 0: sorted = True reset_drone() harvest()

  • @OlexaYT

    @OlexaYT

    Ай бұрын

    Fwiw I think that’s way more complicated than mine lol. Mine is just an inefficient brute force but it’s fairly compact and works well. Beauty of coding, many ways to get to an answer. If I could sit down and think and research and take my time, I’d do a lot of these solutions much differently but restrained to about an hour or less in a video changes how I do things

  • @pelimies5352

    @pelimies5352

    Ай бұрын

    @@OlexaYT This piece of code is an exception, lol. The solution you have just looks very chaotic when it runs, otherwise it is a pretty good one. I don't remember exactly what function it was I was thinking of, but there was at least one where you could shave a lot off of it and make it a lot more unerstandable. But yeah, there is no correct answer to making a function or a program. And I do understand that making a video about this game is way different than playing it otherwise and making the code as efficient as possible. Just keep doing you and having fun!!

  • @Hazychan83

    @Hazychan83

    Ай бұрын

    I implemented a bubble sort, did it in the y direction, then did the same in the x direction. Probably not the fastest algorithm, but it works.

  • @pelimies5352

    @pelimies5352

    Ай бұрын

    @@Hazychan83 I guess mine is bubble sort as well, although I don't really understand the difference

  • @owenatkin3148
    @owenatkin3148Ай бұрын

    I'll happily share my maze farming script with you! good opportunity for me to learn

  • @Adalast
    @AdalastАй бұрын

    My initial take was to sort rows then columns. So long as the rows are sorted properly, once columns are entirely sorted it is done. for row in range(get_world_size()): goto(0, row) rowSorted = False swaps = 0 while not rowSorted: if measure() > measure(East): swap(East) swaps += 1 move(East) if swaps == 0: rowSorted = True continue if get_pos_x() == 0: swaps = 0 Then just do the same thing for columns with moving North and swapping North. Should be fast and straightforward. The for loops only progress once each row/column is completed, so once both for loops are done it is ready to harvest.

  • @braam828
    @braam828Ай бұрын

    The way I did the cactus is by starting at the bottom left and then it’s basically this: Measure Move east Measure If the 2nd measure Then repeat that for worldsize * (worldsize - 1) times and then move north, once you’ve done the whole field do the same vertically. Probably really inefficient but it works

  • @knoxtex08
    @knoxtex08Ай бұрын

    Thank you for choosing to endure for your community ❤

  • @ericslingerland5472
    @ericslingerland5472Ай бұрын

    still at the beginning, if you expand the grid it should balance out the speed issue for pumpkins. faster than fixing the code xD

  • @dillonvandergriff4124

    @dillonvandergriff4124

    Ай бұрын

    Lol. The true programmer's solution 😅

  • @wullivieh

    @wullivieh

    Ай бұрын

    I think he still has a problem if he has to replant only one pumpkin and that one dies (which I think is what happened both times he got stuck in the infinite loop).

  • @ShadowViewsOnly

    @ShadowViewsOnly

    Ай бұрын

    Actually it doesnt. I have full map size, and I virtually use the same algorithm as Olexa does, and it still harvests too early for pumpkins to merge.

  • @ingiford175

    @ingiford175

    Ай бұрын

    There is a call to check what is under the drone, if it is None, then he can plant a seed.

  • @tronikbob4162

    @tronikbob4162

    Ай бұрын

    needs an is entity loop false > plant, > can harvest loop, false > fertilize

  • @flamebeard10339
    @flamebeard10339Ай бұрын

    Semi jank maze code that theoretically solves a maze completely. I make no guarantees, tho it did get me onto the leaderboard. Mazes are more efficient late game so its better to run them to completion. def heappush(heap, sort_value, object, ascending=True): heap.append((sort_value, object)) sift_up(heap, len(heap) - 1, ascending) def heappop(heap, ascending=True): if len(heap) > 1: heapswap(heap, 0, len(heap) - 1) popped_value = heap.pop() sift_down(heap, 0, ascending) else: popped_value = heap.pop() return popped_value def sift_up(heap, index, ascending=True): parent_index = (index - 1) // 2 if ascending: cond = index > 0 and heap[index][0] else: cond = index > 0 and heap[index][0] > heap[parent_index][0] # descending if cond: heapswap(heap, index, parent_index) sift_up(heap, parent_index, ascending) def sift_down(heap, index, ascending=True): left_child_index = 2 * index + 1 right_child_index = 2 * index + 2 smallest = index # ascending if ascending: if left_child_index smallest = left_child_index if right_child_index smallest = right_child_index else: ## descending if left_child_index heap[smallest][0]: smallest = left_child_index if right_child_index heap[smallest][0]: smallest = right_child_index if smallest != index: heapswap(heap, index, smallest) sift_down(heap, smallest, ascending) def heapswap(heap, i, j): heap[i], heap[j] = heap[j], heap[i] def heap_is_empty(heap): return len(heap) == 0 # set_execution_speed(0.5) def spawn_maze(): if get_entity_type() == Entities.Hedge or get_entity_type() == Entities.Treasure: return harvest() plant(Entities.Bush) while get_entity_type() != Entities.Hedge: if num_items(Items.Fertilizer) == 0: trade(Items.Fertilizer, 5) use_item(Items.Fertilizer) def solve_maze_dfs(goal = (0,0)): def get_neighbors(x, y): neighbors = [] directions = [(North, 0, 1), (East, 1, 0), (South, 0, -1), (West, -1, 0)] for idx in range(len(directions)): direction, dx, dy = directions[idx] nx, ny = (x + dx, y + dy) if nx > get_world_size() or ny > get_world_size() or nx continue heappush(neighbors, manhattan_distance(goal[0], goal[1], nx, ny), (direction, nx, ny)) sorted_neighbors = [] while not heap_is_empty(neighbors): v, obj = heappop(neighbors) sorted_neighbors.append(obj) return sorted_neighbors def manhattan_distance(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2) def backtrack(path): while path: direction = path.pop() if direction == North: move(South) elif direction == South: move(North) elif direction == East: move(West) elif direction == West: move(East) def dfs(x, y, visited, path): if get_entity_type() == Entities.Treasure: return True visited.add((x, y)) neighbors = get_neighbors(x, y) for idx in range(len(neighbors)): direction, nx, ny = neighbors[idx] if (nx, ny) not in visited: if move(direction): path.append(direction) if dfs(nx, ny, visited, path): return True backtrack([direction]) return False start_x, start_y = get_pos_x(), get_pos_y() visited = set() path = [] dfs(start_x, start_y, visited, path) def reuse_maze(): while get_entity_type() == Entities.Treasure: if num_items(Items.Fertilizer) == 0: if not trade(Items.Fertilizer, 5): return False use_item(Items.Fertilizer) return True def fully_complete_maze(): spawn_maze() new_pos = (get_pos_x(), get_pos_y()) for i in range(299): # quick_print(i) success = reuse_maze() if not success: quick_print("Completed " + str(i) + " treasure chest finds in the maze") break solve_maze_dfs(new_pos) new_pos = measure() harvest() # while True: fully_complete_maze()

  • @lumek4513
    @lumek451310 күн бұрын

    let's goooooo reinventing bubble sort

  • @thedouchebagofholding980
    @thedouchebagofholding980Ай бұрын

    Nice!

  • @johnydl
    @johnydlАй бұрын

    rediscovering bubble sort :D

  • @MatasVinikaitis
    @MatasVinikaitisАй бұрын

    6 hours and already almost 600 likes, seems like another video will be in the works soon!

  • @brunoianigro61
    @brunoianigro61Ай бұрын

    As others have pointed out you can measure in a direction which should make this much faster, also my solution is basically just like this except to stop I have a flag that increases by one every time it doesn't swap and if it reaches world size to the power of 2(basically if it didn't do any swaps) it harvests, to my knowledge you can't optimize it much more than that because you aren't just moving the cacti you're swapping them

  • @junkjunker842
    @junkjunker842Ай бұрын

    Mmmmm ... 2d bubble sort. Split into separate 2 x 1d bubble sorts might be as effective and easier for people to follow to start. And needs a number of swaps related to the world size, of course. Looking forward to seeing you demonstrate a full selection of alternate sorts in the next video. (Or, you know, whatever is actually practical to do. Maybe scan/list the whole thing, then generate a shortened instruction list of physical swaps needed by sorting the list virtually first? That could be much quicker given there's a time penalty for "real"/drone swaps vs virtual/list swaps.)

  • @FrostedOrgami
    @FrostedOrgamiАй бұрын

    Tyler just measure the first 3 and have them swap if if larger and in that if statement make it so the larger one always ends up on the right, and then have another if statement for the smallest and make sure it's always moved to the left then harvest the middle. Since it's okay for either side to be equal as long as the smallest or largest is in the correct spot

  • @owenatkin3148
    @owenatkin3148Ай бұрын

    Would be fun to see you critique and test other peoples solutions

  • @helicoidcyme
    @helicoidcymeАй бұрын

    this was great! i liked the on_edge function. what if instead of true/false it returns a list indicating what edges its on? that feels like it would be useful in a much wider range of situations, and you could still return false for no edges so "if on_edge():" stays easy and clean

  • @helldwarf
    @helldwarfАй бұрын

    My maze function uses the left hand rule and so breaks entirely when the maze has some sort of loop in it, causing me to have to manually run a function to move through the maze again and harvest when I finally get to the treasure instead of fertilising. I’d love a maze function that fixes this. 😅

  • @aarongoyvaerts438
    @aarongoyvaerts438Ай бұрын

    Yes!!!!! thank you!!!!

  • @TheCastagne
    @TheCastagneАй бұрын

    This is a guess but maybe if the swap function works as the move function does, you could take advantage from the looping from 0 to world size -1

  • @Dylan52meow
    @Dylan52meowАй бұрын

    It appears that you might have x and y switched for the edge cases. If x == 0, you don't need to move WEST, not south.

  • @alexkaplan1136
    @alexkaplan1136Ай бұрын

    A new type of spaghetti western

  • @steveheffner
    @steveheffnerАй бұрын

    I went with the cheese answer. I put my drone at 0,0 and just made sure my north, and east cactus measurements were right. Didn't bother doing the whole farm just those 3 spots I cared about and then harvested. Got 440 with minimal code/effort. Yea hence why I said cheese. That being said.. I need to revisit my code for the treasure. I want a cactus mountain not a cactus puddle.

  • @gabrieldai88
    @gabrieldai88Ай бұрын

    your harvest should yeld 512. at 35:12 its the exact amount of cacti. its correct. cool algorithm

  • @bumbomumboni4735
    @bumbomumboni4735Ай бұрын

    Olexa I'm currently trying to make a Rougelike do you have any ideas about things good Rougelikes have and if you want I can let you know when it's done to see what you think. I think you're the best person I could ask about what makes a good Rougelike because you've played so many. Edit: I will happily respond to any replies I get and might add things recommended and credit your username if it makes it into the game

  • @Blivvy_
    @Blivvy_Ай бұрын

    you can change the keybind for shift+tab in the in-game menu. make it ctrl+tab or something maybe. saves a lot of time.

  • @OlexaYT

    @OlexaYT

    Ай бұрын

    It didn’t work for me unfortunately

  • @robinmaurer2645
    @robinmaurer2645Ай бұрын

    Your Code IS Completely fine: 1. Make it work 2. Clean it up 3. Make it efficient 4. Make it so that you understand your code in a week I have problems starting at step 3

  • @Chaotican362
    @Chaotican362Ай бұрын

    It's back!!!

  • @Donzw
    @DonzwАй бұрын

    Haven't watched the whole video yet so you might've fixed it already but an issue with the pumpkin code is that you're only checking whether you can harvest at the end, not whether there is actually a pumpkin growing there (just always trying to plant at the end might work as a fix as well)

  • @guillaumejutau9649
    @guillaumejutau9649Ай бұрын

    And on_edge measure is missing corner case because you need to omit 2 check when in a corner instead of 1 when on edge

  • @silvahngaming
    @silvahngamingАй бұрын

    Could be totally wrong here but I think when you are on an edge you then check the cactus in the wrong direction like when you are at y=0 you check south when you don't need to. I could be reading it wrong though.

  • @youssefsaleh9220
    @youssefsaleh9220Ай бұрын

    LETS GOOO

  • @user-yd7ug3jb4t
    @user-yd7ug3jb4tАй бұрын

    Yikes - That is definitely some heinous code lol - But it DOES work, and that's all that matters! Your if on_edge(): x y is backwards in the code to swap.

  • @AnthonyLut
    @AnthonyLutАй бұрын

    What about starting each cactus with a list of directions to check and then trimming down that list to consolidate the measures

  • @MindCaged
    @MindCagedАй бұрын

    I've done something similar, though I'm sure my code is not the optimal, I'm just scanning over the whole field over and over until the number of swaps made is 0. I'm sure it could probably be more efficient, not sure if I should sort like one row at a time, then sort vertically if that would work, The 2 dimensional sorting really throws a monkeywrench in my knowledge of sorting algorithms. A one dimensional array is easy to sort, but I've never really encountered a 2 dimensional one.

  • @abandonment
    @abandonmentАй бұрын

    i'm not smart enough to know how to implement this in the context of the game, but i feel like the cactus code's gotta use some kind of recursive divide and conquer technique to sort it most efficiently. too big brain for my coding knowledge at the moment though

  • @Lawondyss
    @LawondyssАй бұрын

    I've been following this series since the beginning and I really like it. I don't think you're using the full potential of functional programming. Functions may require a function in a parameter. For example, write a function that just traverses the grid and calls a function from a parameter on each field. I hope this asPython supports it 😅

  • @deadlykitten4471
    @deadlykitten4471Ай бұрын

    Fixing your maze code is easy, your code works perfectly if there are no loops, which there will not be at the beginning. Instead of trying to reuse the maze, just harvest it and make a new one.

  • @darkwildfire
    @darkwildfireАй бұрын

    As someone who did not get a cs major it looks all fine to me

  • @matyaszdralek6774
    @matyaszdralek6774Ай бұрын

    i was not very clean with this i just bubble sorted all the rows than i sorted all the columns and colected the cactus on 0,0 doing both the directions at once seams like a headache

  • @billy65bob

    @billy65bob

    Ай бұрын

    going all the directions at once isn't very hard, just need to choose if you prioritise East or North. You then just loop the grid with this logic: If North is smaller: Swap with north if East is smaller: Swap with East if South is greater: swap with South If West is greater: swap with West And you're done; the big ones will bubble towards the NE, the smaller ones towards SW. It's not super efficient mind, but it is what it is.

  • @zuzoscorner
    @zuzoscorner19 күн бұрын

    thought that with dictionaries unlocked i could use a dictionary for the sunflowers. but, uh yeah dict.update isn't a thing in the game. in actual python test page I got it to read numbers off a dict but i can't figure out hwo do th in the game. I did manage to use a dictionary for the Cactus checking though. so that nice

  • @guillaumejutau9649
    @guillaumejutau9649Ай бұрын

    What if you only plant 1 in the top right corner and harvest it ?

  • @J9B1-oo7md
    @J9B1-oo7mdАй бұрын

    Just thought I'd comment this, it was bugging me why you kept getting a loop on your Mushroom script and I had to figure it out using your code, it's probably not the best solution but if you add a "move(East)" above the do_a_flip() in the event it gets stuck it should just continue to harvest and I found more times I'd get a full mushroom covering the entire grid this way. while True: move(East) do_a_flip() if can_harvest(): harvest() break break

  • @owenatkin3148
    @owenatkin3148Ай бұрын

    yeeeeeesss

  • @zulaaislynn
    @zulaaislynnАй бұрын

    DINOSAURS! Yay!

  • @bondies777
    @bondies777Ай бұрын

    So essentially the solve for this is a bubble sort?

  • @JG-nm9zk
    @JG-nm9zkАй бұрын

    your on_edge function puts me on edge "if condition: return True else: return False" -> "return condition".

  • @OlexaYT

    @OlexaYT

    Ай бұрын

    I write stuff a bit more drawn out so it’s easier for people who don’t write a lot of code to understand. The majority of the viewers on this series aren’t actually programmers so the if statements make a bit more sense

  • @Bikerbarrie
    @BikerbarrieАй бұрын

    Still watching but feels like your coding a rubix cube

  • @khaledahmed9136
    @khaledahmed9136Ай бұрын

    I think mazes are a massive difficulty spike, would love to have some other things that are simpler before it.

  • @OlexaYT

    @OlexaYT

    Ай бұрын

    I actually agree completely. I unfortunately also think that the mazes just shouldn't have even existed in the game. Would've liked it to be more focused around farming for each little mini challenge. Maybe it's like a thorn path that leads to a rose instead of a treasure chest. The mazes broke the immersion a bit.

  • @khaledahmed9136

    @khaledahmed9136

    Ай бұрын

    @@OlexaYT Yeah, or maybe a corn maze where only 1 corn grows at any given time. Game is still in early access so we can hope that it changes once it's fully released.

  • @OlexaYT

    @OlexaYT

    Ай бұрын

    Honestly corn maze is SUCH a good idea hahaha

  • @khaledahmed9136

    @khaledahmed9136

    Ай бұрын

    @@OlexaYT I'm glad you liked it! I hope this game gets more updates and more vegetables to play around with.

Келесі