- 11
- 23 453
Rust without rust
United Kingdom
เข้าร่วมเมื่อ 1 มิ.ย. 2020
Yo, I do Rust.
Quadtrees: Blazingly Fast Collision Detection
#gamedev #gamedev #2d #coding
Detecting collisions can be done by going through each object for each object, but that'd be fairly slow. A beautiful and efficient way is using quadtrees.
Sound at the end: Noah Barger - Piano Tune.mp3
Demonstration link on GitHub: kul-sudo/quadtrees
Detecting collisions can be done by going through each object for each object, but that'd be fairly slow. A beautiful and efficient way is using quadtrees.
Sound at the end: Noah Barger - Piano Tune.mp3
Demonstration link on GitHub: kul-sudo/quadtrees
มุมมอง: 78
วีดีโอ
Spatial Hashing: Instantly Finding the Closest Neighbor
มุมมอง 18K14 วันที่ผ่านมา
#gamedev #gamedev #2d #coding There's a fairly easy way of finding the closest neighbor among thousands and thousands of objects almost instantly. Today I'll show it. Demonstration link on GitHub: kul-sudo/spatial_hashing
Evolution Simulator: Analysis
มุมมอง 10428 วันที่ผ่านมา
#opensource #github #rustlang #programming #coding In the previous video I demonstrated an evolution simulator I was working on. In this video I'll analyse the overall evolution process and try to explain what happens for what reason. And here's the project itself on GitHub: kul-sudo/eportal
I Built an Evolution Simulator
มุมมอง 889หลายเดือนก่อน
#opensource #github #rustlang #programming #coding In this video I'll demonstrate an evolution project I'm working on. The great song at the end: Noah Barger - it's been a bit. And here's the project itself on GitHub: kul-sudo/eportal
Rust Vectors: How do they work?
มุมมอง 217หลายเดือนก่อน
#rustlang #programming #coding #codingtutorial I think many people really misuse vectors, so in this video I'll show how they're implemented and their cons.
Enums in Rust: Almost Too Good?
มุมมอง 465หลายเดือนก่อน
#rustlang #programming #enums #coding #codingtutorial I think many people heavily underuse enums in Rust, so in this video I'll talk about them.
Rust Tips to Boost your Skill
มุมมอง 1.1K2 หลายเดือนก่อน
#rustlang #programming #coding #codingtutorial Today I'll share with you a few Rust tips that are important to know. I hope you enjoy the video!
Threads in Rust: Parallel Computing
มุมมอง 1.7K2 หลายเดือนก่อน
#rustlang #programming #async #coding #codingtutorial I think many people greatly underrate threads in Rust, so in this video I'll talk about them.
How to disarm Rust
มุมมอง 2112 หลายเดือนก่อน
#rustlang #programming #coding #codingtutorial Hello everyone. I decided to make a video about using `unsafe` in Rust, because most people don't seem to know the power of it and and that it isn't really a crime.
Rust for rookies
มุมมอง 1942 หลายเดือนก่อน
#rustlang #programming #coding #codingtutorial Hello everyone. Recently I've noticed that a lot of people want to learn Rust but don't know what it even is. In this video, I tried to explain that in simple worlds. I'm also working on integrating a donation system into my channel, so I'll probably do it by the next video.
The easiest Rust borrowing guide
มุมมอง 3632 หลายเดือนก่อน
#rustlang #programming #coding #codingtutorial Hey everyone. In this video, I tried to as simply as possible explain borrowing in Rust. I was watching a lot of videos about it when I was learning Rust and was never able to understand it, so I hope this video is especially helpful for beginners. Enjoy!
One of the most recent Minecraft updates introduced this ad an optimization feature.
pog
BLAZINGLY FAST 🔥🔥🔥
it's actually all a scam
I dunno if the effort pays out; but if the overhead from converting to and from hexagonal coordinates doesn't cancel out the benefits; you would have just run the check one time on 12 cells, instead doing one check on 8 and then a second check on up to almost all the additional surrounding 16 cells around that; or if the second check is not that costly, then you would be checking 6 cells, and then up to just another 6 in the worse case scenario as opposed to up to almost 16 with the square grid. The data would still be stored in a square-based grid, but the coordinates would be offset horizontally every other layer and the vertical distances squished accordingly. RedBlobGames got a great article written about various techniques on hexagonal grids, might be worth a read; I was trying to find out if there was specific technical name for this and seems there's a lot of variations on how to handle things; Wikipedia mentioned HECS might be more efficient method for hexagonal coords; I haven't read about this area in while, so I dunno what else is out there and what are the pros and cons of the various alternatives
I am writing a custom replication driver for the Unreal engine, and this might be a useful way to cull the list of actors which need to be replicated to a player. Look up "Replication Graph" if you are interested in how Epic did it. They use the same grid system to create the set of actors which are in visual range of the player, but then they pretty much brute force the selection process. For my game, I need the minions to be able to find a target quickly since there will be hundreds of minions per player near the end of the game and the search has to happen on every frame. Minions which are attacking the player need to be prioritized over everything else so the player can respond. I am writing a custom replication driver because the current implementations don't combine targeting and proximity. Thanks for giving me something to think about.
I'm trying to somewhat do this in pygame, but... I want it to create smooth shapes of the matching colors... even shapes like spirals. Technically... every matching color within a pixel distance of 10 must gravitate into each other until they create a smooth edge. if too small of a number of the same color... then make that small cluster move to the next nearest of the same color.
please make a new version of this video where you go slower and more in depth and from first principles or something like that. thanks
Very cool
real
What's spatial hashing though?
pos.x / cell width, pos.y / cell height is the hash function here for getting the cell by the position. But many seem to criticize me for this terminology.
@@rustwithoutrust You're only listing inputs without explaining the concept you titled this video.
Also try to use quad tree
Oh yes!
did you account for the time it took to lay it out spatially? true that if you are looking up multiple values, that laying them out spatially is faster, this is key
*@Rust without rust* Are you aware of "Quadtree" (and "Octree" (octagonal-tree) for 3D) for spacial partitioning? I think this will be very useful for your purposes? You should look into that more, if you don't already know about it :)
Yes, working on quadtrees right now.
@@rustwithoutrust Good that you know about it 😀👍
1:05 do you just check every single movement transform if you exited cell and then calculate what cell you entered
For the evolution project? Yes I do, but only if there's been a move.
@@rustwithoutrust how would you change algorithm if every single object moved each frame at random direction? collision only with the circles ofc
What do you mean by "collision only with the circles"?
@@rustwithoutrust you know, the moving circles that move towards the triangles. i forgot how you named them in the video
@@rustwithoutrust hi, i woke up and realized that my 1 AM queston made no sense. i'm sorry for that one
That’s an easy to write alternative to quad trees
if you dont want to do a quad tree, then you can sort the bounding box limits on each axis, 2d and 3d. then find which overlap.
I really liked the presentation and how you explained things! However, I do have a problem with this video: It seems like you missed a major premise of the video, being hashing (as others have pointed out in the comments as well). I just googled what "spatial hashing" refers too, and it seems be a strategy for storing the data points that are in the grid. You basically take the floating-point X and Y coordinates, divide them by the spacing, get the floor and feed that into a hash function. The output of the hash function then determines what bucket the data point gets put into. This allows you to instantly access the bucket corresponding to a certain X/Y position in O(1) access time. This means you don't have to pre-allocate a bucket for each cell in the grid, which in turn means the grid can be theoretically infinite, while you only use the memory for the cells that actually contain an entity. I can see your channel isn't very big (yet), so don't let my criticism dissuade you from making more videos like this. It's really just a criticism of the title and premise. The things you did talk about, you explained well IMO! BTW, have you ever tried using a quadtree, and if so, do you know how it compares to fixed subdivisions in terms of performance?
Thanks! Well, in the actual demonstration code I store buckets containing objects in a 2D array and index it by [y][x]. My hash function gives me floor(pos.x / cell width), floor(pos.y / cell height), and I index the correct bucket. Isn't it what we're talking about? Yes, I'm working on quadtrees right now, but I don't yet see how they could be useful for finding the closest neighbor, because the closest neighbor isn't always in the same cell. Subdivisions are just some recursion, so it isn't terrible.
@@rustwithoutrust My previous comment must have gotten delted, maybe because I included a link, but here's the gist: floor(pos.x / cell width), floor(pos.y / cell height) is usually not the hash function for spatial hashing, but rather the INPUT to the hash function. You then take the result of that hash function, modulo it by your array length and that's your index into an array of buckets. You can input any X and Y and don't need to pre-allocate a huge grid of cells. Any X and Y will always map to some bucket in your array. It basically works like a hash map with (cell X,cell Y) as input. Regarding quadtrees, I was only wondering about performance for searching defined areas. It also seems possible to make well-performing implementations for finding the closest neighbor using a quadtree (I found some papers by searching Google), but I haven't tried implementing something like that myself yet.
Btw if you add a limit where it ignores agents that havent moved both recently and enough it cuts processing needs. Also, you can reverse check using only active agents.
I think a quad tree can do it even faster.
I think this really depends on cell size and search area size. I’m sure there’s a ratio between the two that is optimal for this sort of search method.
There's no hashing and the algorithm isn't Instant...
The hash function is pos.x / cell width, pos.y / cell height.
@@rustwithoutrust That's quantizing or binning, not hashing.
Essentially the grid is a hashmap where the key is (x, y) and the value is what is inside the cell. What we hash here is the pos, in order to index the correct cell.
@@rustwithoutrust I understand what you are saying, it just isn't hashing.
Then hashmaps don't involve hashing by that logic, if we get each other.
Also, 31k isn't that much.
1. Nobody's defined what's "isn't that much", for what computer, and for what context. 2. We're talking about the ratios here: 0.1/1.7 ≈ 0.06, so the speed of the version with spatial partitioning is just 6% of the straightforward approach.
where did bro spawn from
real
he's a super advanced AI written in Rust
Yeah... did Your video got cut in half? Or did You forgot to talk about spatial hashing in video titled spatial hashing?
Well, the hash function is `pos.x / cell width, pos.y / cell height`.
@@rustwithoutrust So basically you store all objects in a hash table, and to look up an object in a given cell - you use the hash provided? And you use a hash table instead of an array of indices to save memory because there are many empty cells?
This explained nothing. You spend so much time on explaining how to define distance between squares like that is the hard part instead of talking about the principles of the algorithm like "How do you tie object to a grid element" and the whole 2nd part of the video is absolutely confusing. No idea who can get anything useful from this.
OK, thanks for the feedback.
yeah it didn’t explain much but it got me interested in the topic
The title of the video didn’t exactly say that the video will teach you everything about Spatial Hashing and how to use it. I prefer to look at it as an introduction video to Spatial Hashing. Now it got me interested and want to learn more about it.
This is probably what i would use for a collision engine when i know all the physics objects are within a certain fixed size, although i wonder if there are even better options
Quadtrees, but they're kinda confusing if not used carefully.
@@rustwithoutrust Hm, interesting, i'll look in to those, might come in useful for my 2d game engine project
@@MrTurbo_ They're basically dynamic cells: if a cell has more than X objects in it, it gets recursively split into 4 quadrants.
me randomly getting this in my recommended: "Hmmm... Interesting. I will never use this information ever again, but thanks for telling me"
Yes, it's beautifully simple and fast 👍
Did you mean O(n^2) at the start? You're comparing each cell with each other cell right?
It's sort of O(n.m) because there seem to be a different number of items vs agents. Or to put it another way, it's O(n) "per agent", which is not the whole story. If the items are fixed in the world, you can also consider creating a static space partition (Voronoi diagram), but the non grid-like complexity might not be worth it, and removing an item would incur a recalculation cost.
Oh, I get the confusion. I mean that if we take one object out of the whole collection and go through the rest of the objects for this one object, it's O(n) or O(n-1).
@@rustwithoutrust Ohhh okay I didn't realize you were talking about just for one cell, I thought you meant calculating the entire world.
Yeah, that part could have been kinda confusing.
Checkout how taxi maps works and their algorithms to find the closest objects
I think they send signals or something, but that's a good idea.
Is it anything different to computing a geo hash? E.g using Uber’s H3 library
Using an R-tree next would be quite a fitting choice considering your channel's name 😂
fr
When the thumbs up is both for the creator and the yt algorithm for recommending this
@@David-7815 Yooo! Thanks!
@@rustwithoutrust Github link is broken.
No, it's just that I don't want people to accidentally click a hyperlink.
Very interesting, I'm gonna try to implement it sometime
I allow you.
@@rustwithoutrust thank you, king rust
Did I miss the "hashing" part? I thought that spatial hashing had to do with converting the location of an object into a special hash value that can allow you to easily grab nearest neighbors. Either way, I like where you are going with this, and would love to see an implementation of quad trees
@@pumpkinhead002Well, the hashing is basically (pos.x / cell width, pos.y / cell height), and I agree that's not really the best term for that, but people seem to call it that way.
@@pumpkinhead002Quadtrees is actually exactly what I'm working on right now, so that thing will be big.
Nice video ! Suscribed
@@fabricehategekimana5350 Thanks bud! I'd also really appreciate your review on my latest evolution project series and maybe your opinion on what I could add.
nice
Thanks bud!
nice
@@cobbcodingikr
do more videos about this, maybe about how you used different rust features to make this
Thanks for your feedback! I'll make a video with in-depth analysis of why bodies behave the way they do and demystify certain kinds of behavior they pick. And yes, I'll talk about the implementation too!
Here's the thing with most evolutionary sims, they are self optimizing systems. Meaning after a certain threshold of cycles you mostly end up with the same species for a given environment and it quirks. No matter how often you repeat it, it will end up with the same damn thing with minute variations. It is ultra super hard to design environmental rule sets that allow for a thriving ecosystem with lots of different roles.
@@DerSolinski Well, I agree with you, but I don't think that's necessary a negative. Well, something different here is that the bodies sometimes end up with different properties from run to run due to conditions. Conditions are pseudorandom, so a lot of rains, for example, allow them to have so much food that they can afford everything, but when several droughts in a row take place, they try to have a low vision radius, a low speed, and a minimum amount of skills, so they save up energy. But generally, yes, it's close from run to run.
would be cool to see undefined traits in the beginning, and simulate some form of trait forming. Idk the math for this but would be dope to see initially zero traits (they dont even know how to eat yet) to final traits (what ever these are).
anyways this is dope.
@@samifawcett4246 Hey, this is a pretty good concept that'll definitely spice it all up. I'm currently working on improving performance during rains, but when I'm done with that, I'll try to implement something like that, because the curve of development here is pretty deep.
approximately how long does it take for humans to evolve in this
Well, the closest is all the skills with lower speed and vision distance, I guess.
you should make a video about lifetimes
they're already kinda mentioned in one of the videos, but I agree
@@rustwithoutrust still deserves a dedicated vidya
C in a Rust video :therock:
C mentioned :pog:
thanks! I watched the video and now I have a professional job writing Rust! (just kidding, there's no Rust jobs)
ayo
Based
Cool channel, useful information.
Glad to hear!
uses rwlock and proceeds to only use the write portion of it. you should've grabbed a read first and checked if the number was larger. if it was then you grab a write and write to that number if it isn't then you never grab a write
Right, that wasn't the cleanest way. Actually, thought about it 😅 Great you've noticed that! Edit: No, you actually can't do it, because you can't lock twice at the same time.
that wouldn’t work since it will cause data races, another thread could occupy it when you were going to grab a write.
@@kevz3351 your right. in this case RwLock does not help
@@kevz3351You guys are getting me confused now 🤔 Lemme see who's right later for myself.
best rust channel on youtube
fr fr
write c in rust > write c in c
fax
first
source?
@@rustwithoutrust it came to me in a dream
@@cobbcoding expected
Rust for badookies
:therock: me when I see somebody using unsafe in Rust
Good video, a lot of stuff covered at once. It might be a good idea to make several videos going in-depth on each topic.
@@cobbcoding The next one will be about properly using `unsafe`.
@@rustwithoutrust safely using unsafe
@@rustwithoutrustuse that meme with the crab with the gun
@@noahbarger1 I will.
you should go over the rust basics next video
I will. I'll also make a video for those who are literally just starting to program and explain everything I remember I struggled with when I was a beginner. What do you think?
@@rustwithoutrust yes, good
this is actually a well made video good job
Thanks 👍
@@rustwithoutrust needed more skibidi rizzin up livvy dunn in ohio no cap tho. Other than that it was good.
@@cobbcodingfax
i still don't get it edit: oh now i get it
POG