Computers do all sorts of great things. Unfortunately, taking advantage of a computer’s unique capabilities–pathfinding, generating content mathematically, effortless line-of-sight evaluations, etc.–can involve getting through substantial technical barriers. If you’re being kept from your design goals by one of those walls, I strongly recommend taking a look at Red Blob Games.
Red Blob Games does two things that are very, very useful in providing code help. First, it has lots of examples. Second, and perhaps more importantly, it explains clearly how things work. The examples are all the more useful as a result, and it’s (relatively) easy to envision the changes needed to build the implementation you need for your particular project.
Some ideas hinge on a technical thing that must work. If your technical thing is on Red Blob Games’ pages, that’s a big head start. Give them a look.