See Inside and there are a bunch of good algorithms that you can use.
I got these algorithms from scratch youtubers.