Well, no matter what parameters exist in the system, the same steps would be followed: A path is generated based on the "laws of physics" (only gravity is present in this simulation). Once this path is generated, it is displayed so we can see it, and then the block attempts to follow the path. I'm not sure if it is clear, but the block is NOT stuck to this line, it is using the game controls (move and jump) to stick as close to the line as possible.
Yes, it does in fact take physics into account! At each iteration of the search, we make a copy of the game state and "simulate" what would happen at each button press (up, down, left, right, jump, do nothing) and that becomes a child node of the graph search. I think I'll make a video on this algorithm with physics involved next ;)
I'd have to dig up the code again, but I'm pretty sure the functions is just rise + run. Keep in mind, it's a weighted heuristic. This makes the resulting path slightly less optimal, but much quicker to generate.
It looks like you just created a path for the box to move, and it just follows it... :/ I thought that you would give certain parameters, such as gravity, air resistance, momentum, and speed, to find the closest possible route to the finish line.
Hey, could i have a look at a code so i can try and comprehend it myself or could you refer me to the resources you have used to learn this?
Wow! This is great! Is it possible to see the code?
Yeah, exactly. The goal is to throw any map at it, and the block should find a path that avoids obstacles.
Well, no matter what parameters exist in the system, the same steps would be followed: A path is generated based on the "laws of physics" (only gravity is present in this simulation). Once this path is generated, it is displayed so we can see it, and then the block attempts to follow the path. I'm not sure if it is clear, but the block is NOT stuck to this line, it is using the game controls (move and jump) to stick as close to the line as possible.
Does the algo take the gravity physics into account?! How is it implemented?
Yes, it does in fact take physics into account! At each iteration of the search, we make a copy of the game state and "simulate" what would happen at each button press (up, down, left, right, jump, do nothing) and that becomes a child node of the graph search. I think I'll make a video on this algorithm with physics involved next ;)
@@mschrandt thanks
hi
How does it handle maps that require you to go right then left to get higher?
Debussy?
Yes you could, but since it's so calculation intensive, you're better off scripting cutscenes so that the paths is precomputed.
@CoderRach Neither had I. It's such a huge part of game dev that I've never really explored, but It's definitely fun and worth looking into :p
Could you potentially use something like this to create a cutscene? I've yet to play with pygame myself so I don't know much about the structure.
so how did you build the heuristics function ?? just wondering
I'd have to dig up the code again, but I'm pretty sure the functions is just rise + run. Keep in mind, it's a weighted heuristic. This makes the resulting path slightly less optimal, but much quicker to generate.
Do you test the path to make sure the block can avoid obstacles?
It looks like you just created a path for the box to move, and it just follows it... :/ I thought that you would give certain parameters, such as gravity, air resistance, momentum, and speed, to find the closest possible route to the finish line.
tas moment