Program Your Knights To Escape Treacherous Dungeons - Selfless Heroes (Northernlion Tries)
The full transcript of Program Your Knights To Escape Treacherous Dungeons - Selfless Heroes (Northernlion Tries), a 34-minute Northernlion video (Selfless Heroes) uploaded on April 29, 2020: 64 timestamped lines, about 4,900 words. Press any timestamp to play the video from that moment.
- 0:00 everybody and welcome to northernlion tries, selfless heroes. you know what i'm gonna tell you right off the bat? this is one of those very rare northernlion tries. pc egg. nintendo switch ps4 egg.
- 0:15 i don't know what game engine the game was made in so it doesn't capture with window capture or game capture in obs so i gotta use display capture to look at my other monitor egg. it's gonna be one of those um, selfless heroes is a game that was recommended to me by the steam labs recommender i just bought it for myself for six dollars and seventy cents canadian because it seems like a game that is very much up my alley
- 0:35 it is a puzzle game in the algorithmic programming sub genre, if that makes sense. so very much all the steam reviews were like, this is a lot like 7 billion humans, and i'm like, 7 billion humans? great game. i like zachtronics games, i like all the programming puzzle games, even the ones that ended up not being particularly, you know, interesting for more than a couple hours or something like that. i'd... i'd...
- 0:58 i've taken some programming computer science classes. i'm a little bit out of the game. let's see how we fared having not programmed in probably like 16 months. first steps, solution one. help the heroes walk on the switches. secondary objectives, you gotta do it in three steps with three lines. okay. well if you'll excuse me, i've evolved so i'm gonna put my camera down here.
- 1:24 secondary objectives can be very difficult and it's often impossible to achieve both with the same solution. it is advisable to follow this tutorial carefully. click on the arrow to launch the tutorial. the heroes follow these instructions step by step. drag new instructions from here to change heroes behavior. to see the level objective click here. when your program is ready click here to run it. if you need more help or want to see this tutorial again click here. okay. so we got two downward steps.
- 1:54 they don't quite make it. they fell asleep before completing the objective. okay, here's what i'm thinking. sorry, it's still a little early here. here's what i'm thinking. how about three downward steps? would you look at that? your solution is tested to make sure it works every time. we did it in three of three steps with three of three lines. all right. i mean, i'm not saying you can't improve that, but i don't think we can improve that until we get loops or something like that. so we'll just keep going here. step aside. let's do it.
- 2:25 trigger all the switches with two steps in two lines i mean if we can only have steps i don't see you know what we can obviously do it in two steps if you'll excuse me i'm very dumb you take a diagonal step you take a downward step. i forgot that there were diagonals available here that's a very advanced programmatic concept
- 2:53 look, we already know we got three stars on that one. it's one of the very few times, and this is why you'll always see me gravitate towards these, like, programming puzzle games, is like, at least on the first ten levels, i'm not gonna get bodied, which is very rare for me in a puzzle game on this series. trigger all the switches. check to help about if to understand how it works. two steps, three lines. okay. so, if stepping right equals a switch, then step right. okay.
- 3:23 otherwise, step left. i mean, i think you pretty much got it right. if stepping right would hit a switch, step right. otherwise, step to the left. we can use a little hack here. and would you look at that. my man is a genius. i told you! you don't mess with me in a programming game like this. i'll have you know i've made a jdbc, json compliant
- 3:50 what am i trying to... what's the... when you build the api and it's got the put and the pull and the pop and the... i forgot what it's called. you know what i'm saying. maybe you don't know what i'm saying. maybe i don't know what i'm saying clearly. you know where you do all the apis with the gets and the node.jses and the full stack and the mongodb? that's probably a little bit out of date, but okay, trigger all the switches.
- 4:18 four steps, six lines. if to your right is a hero, step left forever. can you wait with and okay or i see, i see, i see. well okay, if to your right is a hero, step left. that will only move this left one, one space and then it will stop. so i'm going to tell you right off the bat, i think that is stupid. i don't respect it. so if you'll do me a favor, please delete this. is there a delete button?
- 4:48 can i drag this to the ether? okay. hmm. so we have to figure out how we're gonna do you take a sip of water first. all good design starts with mapping where you want to go. it doesn't necessarily start with just hacking it out unless you're in a game jam or something like that. so here's what i'm thinking. obviously, we need one to move to the right one to move to the left. let's explore the parameters we have available here. if to your left, you know what i think we should actually do it the way that they were intending. if
- 5:28 your right is a hero then step well left so that we've reconstructed it your heroes fell asleep before completed the objective i'm just trying to think of it has gotten slightly more devilish as time goes on i wish because all i want to do is create you know what hold on step left can we can we just hard code it step left step left? i mean this is
- 6:07 very hacky way to do it. there's an implied else otherwise step right step right i mean that's one way to do it it doesn't feel nice. it feels like there's some kind of like john carmack way that i can maybe do that way better we did use too many lines and we only got a two star performance there, which is a little embarrassing, but you know what for the sake of agility we'll move on trigger all the switches and don't let your dudes fall in the hole okay if
- 6:44 to your left is a switch. then what you're gonna do is very simple, step left. otherwise, can i, excuse me, can i have an else if please? if, wait no no no, this is, i've done it backwards, sorry it's been a while! while you recognize that some of you are watching this while doing some software development or tech support from home, i hope you're enjoying the schadenfreude here. okay, otherwise, if to your up is a switch, then you're just gonna step up to the streets. otherwise,
- 7:21 if to your right is a switch, you're going to step to the right. uh oh, we've nested this. yeah, if to your right is a switch, you're going to step to the right. else, and we can save one line here, we're going to have you step in, excuse me, please delete this else. it's trash. toss it, toss it. step to the left. now this should work.
- 7:54 when i said step to the left, what i meant to say is step down. that's why you debug. okay, your solution is tested to make sure it works every time. look at that and we even got a three star performance. okay, i'm ready for some real stuff now. i think this whole world is the tutorial, but still. use the fireball to light the bonfires. okay, how about this? fireball up.
- 8:20 you need to move first. okay, i thought it was a double objective. or i thought i could go at range, i should say. so we already know this one's gonna work. that one is just... i get it. it's a tutorialization. give me a sharp turn here. let's start programming some lego robots. light all bonfires. warning, all heroes must survive. okay, so you don't want to shoot your own heroes with fireballs.
- 8:52 so two of them are kind of they have the same behavior. here's that here's how i would look at this if we're going to do this in the most hacky way possible. all right. so if there is a wall on your right, then what you're going to do is step left, step down, there you go. and then we're going to include another if statement after that, that is, if there is
- 9:23 well, no it shouldn't matter. we could just do a fireball down i think. i don't think we need to check if there's a hero beside us. i could be wrong. um, fireball down. but just make sure i'm having a little trouble getting it into the nest there, but that might be my own personal problem. these guys must use spaces instead of tabs. hahahaha. yeah, i mean this seems right. and then the other guy here. else.
- 9:49 we could do a check. well, we don't even need to do it. hold on, here's what you do. if you're not in the group that has walls on your right, and clowns to the left of you and jokers to the right, what you're gonna do then is you're gonna step to the right, and then you're gonna step up to the streets, and then you're gonna test and see if there is... these are not in and outs. oh, i don't think it matters. maybe it does, i don't know.
- 10:21 if above you is not a hero, fireball above you. okay, let's try this. one of your heroes is dead. that's correct. it's the guy on the right, he's blasting, right? yeah, okay. so we do have to perform a check and i am a fool. stop me on this one. hit me with an if below does not equal hero. okay, so this is way too verbose.
- 11:01 and if you'll excuse me, i think i've made another mistake. this needs to be inside of that block. there we go. um, my god. they've done it. now it's way it's slower than it has to be. we got one star and used double the lines. but hey, that's called, uh, defensive coding. even if it's verbose, as long as it's readable, that might be more important for maintenance in the future. um, light all bonfires, use a jump to repeat actions. okay.
- 11:31 understand so we have a loop essentially so what do you want to do inside of your loop you want to? try to see if there's a better way to do it. you definitely want to test like if below you is a bonfire fireball below you else fireball above and then this should just work look at that. we have just made a
- 12:04 a while loop. now it took so much longer. six of four lines. we can definitely get rid of that else, but for now i'm like, get me to the real puzzles that are not as tutorialized and we'll have a fun time together. light all bonfires. i'd like to use my creative thinking once we get out of this tutorial is what i'm trying to say so you can see how stupid i truly am. okay.
- 12:27 this is let's start and just hack this out. if to the right is a floor, then you're going to step to the right under under all circumstances. that's just step nowhere, step to the right there you go. otherwise, so we'll nest this in and out in an ounce. if below you is a floor, then walk below or walk down.
- 12:56 otherwise, and we again we could dump these elses probably if above you is a floor step up otherwise if to the left we don't need to move to the left so this should be fine so if hold on step down step up step, but we got all those conditions all right get that trash out of here so now they should at least move through the maze and it's all sorry, we needed a loop in there
- 13:33 so the loop should happen at the end and cause you to jump to the start. so this is a very simple like, forgive my hoity toity term for this, this is our very simple pathfinding algorithm here that should allow everybody to make it through the maze pretty easily in a readable and you know, understandable series of instructions. so i think the only other thing we would look for honestly is right at the top
- 14:03 we could write this better. but right at the top is if to our right is a bonfire fireball right and then this would be in an else and then this should work. it's a little bit more verbose than it needs to be but i think it's pretty much locked in.
- 14:24 as long as they use the fireball there at the start, we got nothing to worry about. or at the end i should say. look at that. now it's very slow, don't get me right. as you can see, we're not doing great on the distribution on the graph.
- 14:36 but all these computer algorithmic games, they're all about can you design the most elegant algorithm ever? i got a computer is 4000 times more powerful than nasa used to land three men on the moon in 1969. you think i'm worried about the efficiency of my pathfinding algorithm? this thing can run crisis. i'm not worried about oh, i use the it's using too many clock cycles.
- 15:02 understand that's me. i'm mostly just cracking a joke. please don't give me the real reason for why that's important i understand you got to inline all of your functions so that as well. you're not my professor blah blah i understand okay warning all the heroes must survive copy paste the code from the previous level to go faster switch to code editor what if i have no idea if
- 15:35 space to the i mean what is this written in i is this like a saved action. oh your code is ready to be run move walk step right does this work your code is that your code will not compile use one of the following and said step fireball step right look we got to read the documentation to try to make this work anyway. i guess that's not an enum um well
- 16:15 i don't know how to copy paste our code from a previous level. maybe they're asking me to actually go back in the level editor and go, hey, this one? play it. and then use the code editor. ahhh! there you go. if e equals bonfire, step e. oh, east! okay, i see.
- 16:43 and then take me back out please. by the way, if you ever take a programming class this is probably the most important skill you will ever learn which is going and looking at other people's code that had the same issue you did and then fitting it into your own project. so there's your code from the previous one and dude the fact that it automatically maps to the visual is hilarious. so what's our problem here? well really the only thing we have to change is if
- 17:11 n equals bonfire, fireball n. and then in theory this should just work, cause all we're changing is the direction that we want to shoot the fireball. we know the pathfinding is gonna work cause we already, you know, grokked that out. look at that. i mean that's not that impressive, but the fact that we're doing it in the code window is funny. feels good, feels good to be back. and again, it's so slow i'm embarrassed. but let's see, be brave, run away.
- 17:40 run, run, run little thing. let's see who's the fastest. these two ogres are after you. get rid of them before they catch up to you. okay, i understand what you're doing here. so you are... you gotta hit the switch so this guy gets through. so here's the easy step. we only want them to move right if it's safe. is the best way to describe this, i think. so i think it's like, if there is a spike... hold on. if there is not...
- 18:20 spike on your rights then i mean for now we'll just say step to the right and then this should allow us to run sorry i didn't put a loop in here all right now this should allow us to run okay i have to be standing on the switch okay i understand it's a little bit more complicated okay if i
- 19:01 to your right is not spikes then you're gonna step. however, if your right is a switch, i don't know, there's like no wait, at least for now. we might have to be a little bit more creative. so if to your right is not a spike, you're gonna move to the right unless, if on your right, okay, no, no, hold on. if you are on a switch, i'm just gonna put step in the same, oh we can't.
- 19:34 what if we just put a step nothing? oh, it won't compile. okay. for lack of a better word. if you're standing on a switch, stay there forever. this is definitely not gonna work. yeah, however, okay, this is a little bit more interesting. for sure. so please dump this garbage.
- 20:05 so the problem is this guy gets killed by the frickin' spikes, dude. i wish there was like, wait one second. i wonder if we had, uh, if we did this, if we just programmed it like in the most hacky way possible. so if, if, uh, to the right is not spikes, you're gonna step. what about if to your right is a switch, then what you're gonna do is step right, step left, and then step right again.
- 20:41 let's see how this works. it's a little spice, don't get me wrong. i did get caught because i think our program is too slow. you know what? scrap this whole thing. get it out. get it out of here. there's a puzzle solving component to this, you know? there's no way for us, at least as of right now, to pass information back and forth. so we have to kind of use a hacky solution. you know what? here's a hacky solution for you. if to your left,
- 21:16 oh, i was gonna say if to your left is an ogre always go right? we don't want you to get killed by an ogre so unfortunately we can't do that we really just need you to slow down slightly well. i really think maybe the best way to do this is if to your right is a is spikes then you're just gonna wait a turn so you're just gonna do that otherwise and we'll put that in the else block here if to your right is
- 21:51 a floor, then you're just going to step to the right. maybe we were putting that behavior on the switch when we should be putting on the spikes instead. hold on, i didn't put another loop in here. now this is pretty slow code, so i worry we will get caught. we are getting caught.
- 22:15 i gotta be honest, this boss battle, i think we're better off going down here and maybe trying to take on some of the slightly more straightforward levels. put all the eggs into the cauldrons. but you got me thinking, obviously my sore spot right now is writing an efficient algorithm. we're not doing a very good job of that, but i think we had the principle of it if we were not getting chased at least. put the eggs into the cauldron. take and drop, okay. well, everybody is gonna take from the right, step down too.
- 22:50 and then drop to the right. this should work. yep. okay. i mean, that's like after what we just tried to accomplish. that's... oh, you know what? we're sorry. we're done. why don't you take from the right step down this way? delete this and then drop downwards. now we're talking. look at that. we came in right at the industry average. i can live with that. dinner's ready. dinner for sean. these eggs were randomly scattered throughout the room. put one egg in each cauldron to prepare the dinner.
- 23:26 okay, can we drop one? one egg in each cauldron. i think it's okay. so it's very simple. if there's an egg below you, you're going to pick it up. if there is an egg, if there is an egg below you, then you are going to take down. otherwise, you are going to step otherwise work with me on this one. oh no, he's having a real real big brain hour. otherwise,
- 24:07 what if we could dump this? get this else out of here, dude. i want an implied else so our code is faster. that's not how that works. you're a fool. if there is a cauldron below you, then you're gonna drop below. otherwise, you're just gonna step down, dude. and then at the very end of this, we're gonna put a sweet little jump there. but this...
- 24:39 i think when you pick up an egg, you're no longer going to move, which means we need to put the loop in a different spot. yes, okay. so instead of putting it within the block, we put it outside of the block and everything should function according to the way we have designed it here. oh, they're all in sync too, that's nice. it took so long. twice as many lines too? well,
- 25:16 efficiency is not my strong suit apparently, but i can fizz buzz with the best of them. put the egg into the cauldron. okay. if there is an egg on your left, take left, drop right. no, no, no, no. if there is an egg on your left and there is a wall below you, take left, drop right. otherwise, like this is the tricky one.
- 26:06 otherwise, take left, drop down. yo... yo, this, i'm coming for you, zachtronics! i didn't put a freaking loop in it! okay. wrap the whole thing in a... in a try one... in a try catch block. excuse me. ah, yes, hold on. these guys are not taking up. there's a wall, but like... take... this guy needs to take left and drop down. that's the problem. i mean, we could build that in pretty easily.
- 26:48 you know i kind of hate my code here. just work with me. take left, drop right is totally fine. otherwise you're not going to take left and drop down. you know what? i think it's if right does an equal wall. but you're not... no, these guys aren't going to take left. they're going to take up fool. can you do an l? you can do an else if. else if up equals wall. then you want this in there. and then the final else is just take up
- 27:27 drop down, i think. however, i think that doing that take up, drop down when there's nothing around you is gonna be tedious. excuse me, sir. why are you not dropping to the right? let's step through it. left is egg, right does not equal wall. how did i do that? he's picking up, he's throwing it. he's picking up, he's throwing it. he's picking up, he's picking up, he's throwing it. the moment of truth. okay, we should be good then. don't, i don't even wanna see this graph anymore.
- 28:09 please remove this graph from the game, i'm embarrassed. huh? put one egg which is less than four into each cauldron. if you want to test the value of an egg, you can have them play a puzzle game on northern land tries. your heroes are smart enough to understand that you're talking about the egg. okay. my only question is like, how do i get them all to the cauldron when this thing is full of eggs? can you walk over an egg? so i mean if down, well, what about this? if
- 28:55 can't you do like if i have no egg? if my item is nothing, then if below is anything, well if below is an egg, pick it up. well no no no, if, well okay hold on, hold on, get rid of this. if below is an egg and below, because they said this would work, is less than the number four, take below. otherwise, so now if you're standing
- 29:41 add an egg and it's not... hold on. i know i've said hold on a thousand times. if below you is an egg... well, the other solution here is if below you is not an egg. we're just gonna have you step down one. and then in theory, i think this should lead... get this out of here. to... i mean the very basic behavior here.
- 30:15 that if there's nothing if you've got nothing and an egg less than four is below you take that egg that's yours now otherwise step down one and then check the next egg and then just continue it so here we go we're gonna step there's nothing below you so you're gonna step down all right here we go this is the real test if your items nothing yes if below you is an egg oh heck yeah if the value is less than four take otherwise step
- 30:45 now, they're not gonna drop it off, i just wanted to see if this would work. what i'm concerned about really is the idea that maybe in some situations, they may never encounter an egg less than four if the values are randomly changing, in which case they'd have to go search for one maybe, if that's the way you wanted this program to work anyway. okay, so this is like, if you've got nothing, do this. so really i think it should be like this. yeah, yeah, yeah, if you've got nothing, constantly do this.
- 31:22 yeah, yeah, otherwise you've got something. what do you do then if? below you is a cauldron drop down otherwise step down i'm not saying this is a guaranteed fit. why are you not dropping down hold on take it take it down to speed for here? i want to see what you're all picking up eggs. i'm very happy to see it step forward one
- 32:08 you're jumping back up here. if below you is an egg, it's not, so get out of that. eltz, step down. there's your problem and then you're done. alright, okay, okay, i see your concern here. so be ahhh! you gotta jump here, dude. you gotta jump there.
- 32:25 will that work right off the bat? we might need one more tweak, but for now that's such an easy solution i thought it's worth it to try. oh, ladies and gentlemen! only twice as many cycles as we're supposed to use and more than two times as many lines. anyway, this is good. selfless, uh, selfless nights.
- 32:47 but all those wait, selfless heroes is what it's called. it's available on steam! if you like these programmatic games and you can't get enough of this type of puzzle solving, give it a try. i recommend it, even though it made me feel like a fool. i think it's got a good vibe. it's a cheap puzzle game, it's a lot of fun, and i hope you guys had fun watching it. number one thing, if you enjoyed the episode, go check out the game on steam.
- 33:07 it's cheap, even if you don't pick it up, you can wishlist it and be notified of when it goes on sale in the future. if you enjoyed the episode, click the like button. if you watched up to this point, i'm assuming you did, or you're tearing your hair out with frustration that one of canada's top polytechnic institutes would dare give me an associate's degree in software development.
- 33:26 if you enjoyed the episode, click the like button. it sends a message to youtube. hey, i like this video. other people should see it. that helps me out a great deal. if you only do one thing to support the video, that's the number one thing. apart from that, subscribe if you want to see more in the future and i'll be in the comments getting your debugging advice from stack overflow. for now, thanks for watching. i'll see you next time. see ya!