Optimal Code Doesn't Save You

  Рет қаралды 3,295

Kedrigern

Kedrigern

Күн бұрын

Пікірлер: 24
@leamir0
@leamir0 3 ай бұрын
0:29 true, thats why i only write one liner, unmaintanable code. Thats called job security
@KedrigernGaming
@KedrigernGaming 3 ай бұрын
Are your variables also called ‘a’, ‘b’, ‘c’ and ‘tmp’?
@FoxSlyme
@FoxSlyme 3 ай бұрын
You can "continue" your code if you check for world coordinates using your drone senses instead of the loop variables that are lost when restarting. Something like this: def next_spot(): move(North) if get_pos_y() == 0: move(East) That way you don't even need the for loops or to know the world size
@KedrigernGaming
@KedrigernGaming 3 ай бұрын
I thought about it and then decided not to bother 😂 But it would probably make the code better!
@shavranotheferanox7809
@shavranotheferanox7809 Ай бұрын
i know im late since you already made many more videos, but you could turn the buying and planting of carots into a function, and then just put that function in the code instead of the whole thing
@KedrigernGaming
@KedrigernGaming Ай бұрын
Thank you for the tip! I have done that already...partially. It always seemed like "This is the last I am gonna have to do/write this. Probably no need to make it generalize the idea." But new mechanics just kept popping up and...eh..yeah, I should optimize a bunch!
@OzDeaDMeaT
@OzDeaDMeaT 2 ай бұрын
what is this game called?
@KedrigernGaming
@KedrigernGaming 2 ай бұрын
I say it at 00:39 - The farmer was replaced ;)
@Dyanosis
@Dyanosis 3 ай бұрын
You don't need to specify 0 for your range start. Range defaults to starting at 0 if you only provide 1 parameter. Aka: range(0, worldSize) becomes range(worldSize) It's also fair to mention that the naming conventions for Python and other scripting type languages (except JavaScript) is snake_case (aka all lower and words separated by underscores).
@KedrigernGaming
@KedrigernGaming 3 ай бұрын
I see, that's good to know!
@hellangel28
@hellangel28 3 ай бұрын
a little tip: name your variables more specific to what they contain.. using arbitrary nonsaying variable names requires you to keep a mapping of these in your head at all times... 'i' could easily just be 'x', 'j' could easily just be 'y'.. after all they are x and y coordinates.. for example: a = get_ground_type() wouldnt make much sense, if you dont know the arbitrary mapping you dont know what's in any variable, making it less readable, especially if you come back to it years later when you forgot this mapping.. groundType = get_ground_type(); would make it a lot easier to realize what is in this variable, even without seeing the definition, even a decade later :)
@KedrigernGaming
@KedrigernGaming 3 ай бұрын
I have to agree. I need to change my mindset. This game feels like university used to. Just write some code quickly, it can be unreadable garbage because noone will ever read it anyway and I just need it to work now. BUT! This is a game, not school! This actually matters and surprisingly I want to get back to the code so I need to understand it! It is deceptive how 'easy and short' the code is now though. I don't realize that in 5 minutes I might unlock many new commands and game mechanics making the code grow. Gotta make it clean asap.
@hellangel28
@hellangel28 3 ай бұрын
@@KedrigernGaming exactly, the cleaner your code, the easier you can extend or adapt it.. and yeah this is a game, but in my opinion it's good to get used to some "best practices" because in the end they will make it easier for you and if you "automatically" do these things, you already start out with cleaner and more managable code! :)
@KedrigernGaming
@KedrigernGaming 3 ай бұрын
Sometimes it can be hard not to have that 'I am for sure never getting back to this code again' mentality. For some reason I always get back to my code and curse my past self :D
@realdragon
@realdragon 3 ай бұрын
For now the only use for functions I see is to have everything organized. So they're basically useless
@KedrigernGaming
@KedrigernGaming 3 ай бұрын
Agreed. I feel like sometimes people like to use functions just for the sake of using them. When in my eyes it makes the code in no way better to read and possibly harder to edit (code in multiple places).
@leamir0
@leamir0 3 ай бұрын
@@KedrigernGaming tbf with functions, as long as you have a good ida(click to go to function definition) + good function name it makes stuff more readable In my case in this game, I have a function for planting a line of each plant, a function for watering, and a main. I feel like my code is way more organized than if it was all one file
@KedrigernGaming
@KedrigernGaming 3 ай бұрын
I expect this to be true for me as soon as the code gets larger. What you are saying makes sence, I’m just not there yet 😂
@leamir0
@leamir0 3 ай бұрын
@@KedrigernGaming you definitely aren't there yet, you are close tho. I really want to see how you are going to make the money farm, still haven't figured mine out (it's hard)
@KedrigernGaming
@KedrigernGaming 3 ай бұрын
Hoho…no idea what you are talking about just yet. Sounds fun though. Looking forward to it! But first step for me is to stop forgetting the brackets. That really makes it hard to progress in the game 😂
This Coding Challenge Made Me RAGE
27:22
Kedrigern
Рет қаралды 2,8 М.
My Coding Addiction got Out of Hand
22:58
Kedrigern
Рет қаралды 3,2 М.
Will A Guitar Boat Hold My Weight?
00:20
MrBeast
Рет қаралды 251 МЛН
哈莉奎因怎么变骷髅了#小丑 #shorts
00:19
好人小丑
Рет қаралды 53 МЛН
I Ruined This AAA Flash Game With An Autoclicker
11:43
DangerouslyFunny
Рет қаралды 505 М.
Can I Run Youtube Entirely From My Terminal? (No Browser)
15:31
Do I need a Game Design Document?
5:20
Alchemy Sheep
Рет қаралды 22 М.
Why Do Video Game Studios Avoid Blender?
6:49
The Cantina
Рет қаралды 594 М.
My Python-Automated Pumpkins are Now Efficient...
57:40
Olexa
Рет қаралды 54 М.
God-Tier Developer Roadmap
16:42
Fireship
Рет қаралды 7 МЛН
I was hired to automate farming...
24:17
Real Civil Engineer
Рет қаралды 506 М.
Gaming on a Failed Steam Machine
29:49
Bringus Studios
Рет қаралды 1,4 МЛН
Why Stardew Valley’s Creator Hated His Game
20:17
Nello
Рет қаралды 1 МЛН
The ultimate introduction to Pygame
3:47:58
Clear Code
Рет қаралды 2,8 МЛН