The most interesting data structure I've learned

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

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

  • @lengors7327
    @lengors7327 12 дней назад +44

    Just as added note for those interested: the version of this for 3d is called octree

    • @WebDevCody
      @WebDevCody  12 дней назад +5

      very cool, I'm sure that's used a lot for 3d games

    • @afailable
      @afailable 12 дней назад +1

      Octrees are really fun to make

  • @bar-e-tom
    @bar-e-tom 12 дней назад +22

    so that's basically a 2D binary tree, pretty neat.

  • @scarlatum
    @scarlatum 11 дней назад +6

    One remark: It's good only for static objects that don't move a lot, otherwise you should rebuild your quad tree each time on object position changes to hold it in actual state. For dynamic objects the Spatial Hashing more preferable if you ask

  • @shannenmr
    @shannenmr 11 дней назад +4

    Unless coded incorrectly a Hierarchical Spatial Hash Grid should be way more performant then a Quad Tree, especially for moving objects because insertions/deletions have a reasonable cost (especially if using balanced tree) on top of the traversal and AABB check cost.

  • @butwhothehellknows
    @butwhothehellknows 12 дней назад +14

    You’re killin it babe!!! Love it

  • @DivjotSingh
    @DivjotSingh 12 дней назад +1

    This is so cool! Inspires me to make something like this

  • @fille.imgnry
    @fille.imgnry 12 дней назад +9

    What was the performance gain? Did you measure before and after? Or was it just for fun?

    • @WebDevCody
      @WebDevCody  12 дней назад +5

      Just for fun, no measurements

    • @shannenmr
      @shannenmr 11 дней назад +3

      Unless coded incorrectly a Hierarchical Spatial Hash Grid should be way more performant then a Quad Tree, especially for moving objects because insertions/deletions have a reasonable cost (especially if using balanced tree) on top of the traversal and AABB check cost.

  • @wlockuz4467
    @wlockuz4467 12 дней назад +5

    what tech stack are you using to build your game?

    • @WebDevCody
      @WebDevCody  12 дней назад +6

      Typescript, from scratch

    • @wlockuz4467
      @wlockuz4467 11 дней назад +1

      Oh that's amazing, this explains why none of the package.json has any dependencies in the repo lol
      Are you following some guide or course or other resources?

  • @superchillh3o
    @superchillh3o 12 дней назад +2

    Haven’t watched yet, but guessing quad trees from diagram, 🍿 time

  • @caydev2010
    @caydev2010 10 дней назад

    I think Albion online does this but in scale to support open world gameplay. Each cell has a corresponding servers that manages it. Imagine each cell is mapped to a single region, e.g. Asia, US, Europe.

  • @user-sb5vt8iy5q
    @user-sb5vt8iy5q 12 дней назад +1

    Before watching, I'm guessing it's a quadtree based of the thumbnail, it's commonly used in gamedev, for collisions and other things

  • @benjaminhon86
    @benjaminhon86 11 дней назад +1

    You can convert the x,y to a geohash string and do O1 lookup

  • @aaronmark3930
    @aaronmark3930 11 дней назад +2

    I would be surprised if a quadtree performed better than a spatial hash for this type of game.

    • @WebDevCody
      @WebDevCody  11 дней назад

      it's hard to say without benchmarking. a quad tree is good for non uniformly distributed game objects. when playing this game, I've noticed many zombies will group together as they try to path find to the player. IMO this means non uniform distribution. Additionally, the collidable trees in the game are a little non uniform.
      it's one of those things where you won't know unless you benchmark, and after you benchmark I would be the difference isn't that great after all.

  • @theyayaa
    @theyayaa 11 дней назад

    What if a data point falls in two quadrants? What do you do then?

    • @WebDevCody
      @WebDevCody  11 дней назад

      From when I’ve read online, you put it in the parent Cell if it overlaps two of the boundary boxes. I think this would mean that the capacity can go over if you have a bunch of objects that lay on line between two cells.

  • @LawZist
    @LawZist 12 дней назад

    This is great stuff right here

  • @samiullahsheikh5015
    @samiullahsheikh5015 12 дней назад

    Can you please make a video how to download a csv on FE with very large data?
    Can you please show the production level approach?

  • @sfBlackFox
    @sfBlackFox 11 дней назад

    Looks like it's a collision map that uses breadth first search

  • @worldbest3097
    @worldbest3097 12 дней назад +2

    wow, how algorithms works in frontend and game..

  • @anasouardini
    @anasouardini 12 дней назад

    I didn't follow your series from the beginning, but why not have a map of position as the key and content as the value and then you just add/subtract 1 from the player's position and see if it exists on the map which would mean that the player is about to touch the thing in that position, IDK how the "touching" approximation work in your game.
    - Good Game

    • @afailable
      @afailable 12 дней назад

      The quad tree is used to reduce the checks required to see what objects are colliding in the game. Having a map where every object that can move constantly updating keys is ridiculously inefficient in comparison.

    • @opposite342
      @opposite342 11 дней назад

      @@afailable to be fair, what they're suggesting is essentially (at least conceptually) what a spatial hash is. I feel like both are valid depending on how spread out the enemies are (quadtree probably performs better on average if they're spread out equally) and whatnot. From some searches there seems to be benchmark and study comparing these two so you can look at that and use them depending on your scenarios.

  • @hghmnds
    @hghmnds 11 дней назад

    that's kinda smart

  • @str225-f1z
    @str225-f1z 12 дней назад

    How would you recommend balancing building side projects with a full time job?

    • @WebDevCody
      @WebDevCody  12 дней назад +7

      work on your side project 30 minutes to an hour a day. Everyone can at least find 30 minutes of free time a day, some choose to use it on tv or gaming, I choose to code with that time.

    • @hghmnds
      @hghmnds 11 дней назад

      do your side projects at work

  • @burgermancan
    @burgermancan 12 дней назад

    also the most interesting way to show WASD 👀

  • @hmellahi
    @hmellahi 12 дней назад

    Siick!

  • @CELESTEisdead
    @CELESTEisdead 11 дней назад

    using chatgpt is gay