A* Pathfinding Example - Pygame

Поделиться
HTML-код
  • Опубликовано: 20 дек 2024

Комментарии • 18

  • @mouadmhannee5267
    @mouadmhannee5267 Год назад +1

    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?

  • @andrensegura
    @andrensegura 12 лет назад +6

    Wow! This is great! Is it possible to see the code?

  • @mschrandt
    @mschrandt  11 лет назад +1

    Yeah, exactly. The goal is to throw any map at it, and the block should find a path that avoids obstacles.

  • @mschrandt
    @mschrandt  12 лет назад

    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.

  • @nickheyer
    @nickheyer 2 года назад +1

    Does the algo take the gravity physics into account?! How is it implemented?

    • @mschrandt
      @mschrandt  2 года назад +1

      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 ;)

    • @SanyaBane
      @SanyaBane 2 года назад

      @@mschrandt thanks

    • @CarZyer
      @CarZyer 4 месяца назад

      hi

  • @giantnoah
    @giantnoah 2 года назад

    How does it handle maps that require you to go right then left to get higher?

  • @black_squall
    @black_squall 7 лет назад +1

    Debussy?

  • @mschrandt
    @mschrandt  12 лет назад +1

    Yes you could, but since it's so calculation intensive, you're better off scripting cutscenes so that the paths is precomputed.

  • @mschrandt
    @mschrandt  13 лет назад

    @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

  • @Resulli
    @Resulli 12 лет назад

    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.

  • @ramiBudemaris
    @ramiBudemaris 11 лет назад

    so how did you build the heuristics function ?? just wondering

    • @mschrandt
      @mschrandt  11 лет назад

      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.

  • @GorillaTacticsGames
    @GorillaTacticsGames 11 лет назад

    Do you test the path to make sure the block can avoid obstacles?

  • @ip0dout
    @ip0dout 12 лет назад

    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.

  • @gatetm
    @gatetm 2 года назад

    tas moment